part two Flashcards

(10 cards)

1
Q

what is a resource block in terraform ?

A

It defines a specific infrastructure component, such as a virtual machine, storage bucket, or a database, that Terraform will manage.

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

how do you run the terraform destroy command to destroy just a specific resource ?

A

use the -target flag. (terraform destroy -target resource_type.local_resource_name)

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

what is an attribute in terraform ?

A

Attributes define the details or configuration of a resource and can also include information Terraform retrieves after the resource is created

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

what is string interpolation ?

A

string interpolation is used when you want to merge or combine variables (or expressions) with plain text (defined directly in the string).

eg variable “username” {
default = “Alice”
}
“Welcome, ${var.username}!”

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

what is the function of an output block in terraform ?

A

it makes information about your infrastructure available on the command.

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

what are variables in terraform ?

A

A variable in Terraform is like a container for storing data that can be reused throughout your configuration

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

what are the different ways you can define variables in terraform ?

A
  • variable defaults
  • variable definition file (*.tfvars)
  • Environment variables
  • setting variables in the command line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

which variable takes precedence in terraform ?

A
  • Command-line flags (-var or -var-file)
  • Environment variables (TF_VAR_)
  • terraform.tfvars or terraform.tfvars.json
  • Automatically loaded .auto.tfvars files
  • Default values in variables.tf (Lowest Priority)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is data type in terraform ?

A

In Terraform, data types define the kind of values a variable or output can hold. eg string bool number list set map null

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

what are the different meta arguments in terraform ?

A
  • depends_on : Specifies that a resource or module depends on another resource or module.
  • count: Lets you create multiple instances of a resource or module based on a number.
  • for_each : Allows you to create multiple instances of a resource or module based on a map or set, with each item being unique.
  • provider : Specifies which provider configuration to use for a resource or module.
  • lifecycle: Manages the lifecycle behavior of a resource (e.g., prevent deletion, ignore changes, etc.).

create_before_destroy: Ensures a new resource is created before destroying the old one.
prevent_destroy: Protects a resource from being destroyed accidentally.
ignore_changes: Tells Terraform to ignore changes to certain attributes.
- timeouts: Configures how long Terraform should wait for a resource operation to complete.

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