Terraform Flashcards

1
Q

What is

Resource?

A

Resource block describes one or more infrastructure objects, such as virtual networks, compute instances, or higher-level components such as DNS records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is

Provider?

A

Plugin form cloud provider that allow to manage infra specific for cloud.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is

Module?

A

Modules are containers for multiple resources that are used together.
Each main.tf in folder is module on it own.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to

How to call Module and why?

A
module "bigquery_datasets" {
  source  = "<source_path>"
}

You can call it to reuse configuration from another module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is

What are sources of the module?

A
  1. From local file
  2. Github
  3. Http
  4. Cloud Storage Buckets
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to

How to change resoucre argument value when importing whole module? like

module "bigquery_datasets" {
  source  = "../modules/bigquery_datasets"
}
A
  1. Move OG name to variables
  2. Then dirrecly change this var in module file
    ~~~
    module “bigquery_datasets” {
    source = “../modules/bigquery_datasets”
    dataset_name = “offers”
    }
    ~~~
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to

How to make resource creation dependend on another resource?

A

Use

depends_on = [
    resource_type.resource_name
  ]

Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to

How to make multiple resources via one block?
(there is 2 methods)

A
resource "aws_iam_user" "the-accounts" {
  for_each = toset(["Todd", "James", "Alice")
  name     = each.key
}

OR
~~~

resource “aws_iam_user” “the-accounts” {
count = 4
name = “Server ${count.index}”
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to - console

How to show dependency grap?

A
terraform graph
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to

How to declare variables?

A

In variables.tf file declared like

variable "project" {
  type    = string
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to

How to set variables?

A

1.In variables.tf file like

variable "project" {
  type    = string
  default = "sc-9369-dataengineering-dev"
}

2.terraform apply -var="project=sc-9369-dataengineering-dev"
3.In terraform.tfvars file and running terraform apply -var-file="terraform.tfvars"

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly