- (Exam Topic 4)
Given the below resource configuration - resource "aws_instance" "web" { # ... count = 4 }
What does the terraform resource address aws_instance.web refer to?
Correct Answer:
A
A Resource Address is a string that references a specific resource in a larger infrastructure. An address is made up of two parts:
[module path][resource spec] Module path:
A module path addresses a module within the tree of modules. It takes the form: module.A.module.B.module.C...
Multiple modules in a path indicate nesting. If a module path is specified without a resource spec, the address applies to every resource within the module. If the module path is omitted, this addresses the root module.
Given a Terraform config that includes: resource "aws_instance" "web" {
# ...
count = 4
}
An address like this: aws_instance.web[3]
Refers to only the last instance in the config, and an address like this: aws_instance.web
Refers to all four "web" instances. https://www.terraform.io/docs/internals/resource-addressing.html
- (Exam Topic 2)
lookup retrieves the value of a single element from which of the below data type?
Correct Answer:
A
https://www.terraform.io/docs/configuration/functions/lookup.html
- (Exam Topic 4)
Which parameters does terraform import require? Choose two correct answers.
Correct Answer:
CD
https://www.terraform.io/cli/commands/import#usage
- (Exam Topic 4)
To check if all code in a Terraform configuration with multiple modules is properly formatted without making changes, what command should be run?
Correct Answer:
D
-check Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.
-recursive Also process files in subdirectories. By default, only the given directory (or current directory) is processed.