Page 1 of 1

Terraform Associate Questions + Answers

Posted: Fri Feb 25, 2022 3:45 am
by answerhappygod
Exam A QUESTION 1
The terraform.tfstate file always matches your currently built infrastructure.
A. True B. False
Correct Answer: B Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/language/state/index.html QUESTION 2
Which of the following is not true of Terraform providers?
A. Providers can be written by individuals
B. Providers can be maintained by a community of users
C. Some providers are maintained by HashiCorp
D. Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers E. None of the above
Correct Answer: D Section: (none) Explanation
Explanation/Reference:
Reference: https://jayendrapatil.com/terraform-che ... figuration QUESTION 3
You should store secret data in the same version control repository as your Terraform configuration.



A. True B. False
Correct Answer: B Section: (none) Explanation
Explanation/Reference:
Reference: https://blog.gruntwork.io/a-comprehensi ... 586955ace1
QUESTION 4
You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead.
What are the two things you must do to achieve this? (Choose two.)
A. Provision new VMs using Terraform with the same VM names B. Use the terraform import command for the existing VMs
C. Write Terraform configuration for the existing VMs
D. Run the terraform import-gcp command
Correct Answer: BD Section: (none) Explanation
Explanation/Reference:
Explanation:
The terraform import command is used to import existing infrastructure. Import existing Google Cloud resources into Terraform with Terraformer.
Reference: https://www.terraform.io/docs/cli/import/usage.html https://cloud.google.com/docs/terraform
QUESTION 5
terraform init initializes a sample main.tf file in the current directory.
A. True B. False



Correct Answer: B Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/cli/commands/init.html QUESTION 6
Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.)
A. Destroy B. Apply C. Import D. Init
E. Validate
Correct Answer: BD Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/guides/core-workflow.html QUESTION 7
Terraform requires the Go runtime as a prerequisite for installation.
A. True B. False
Correct Answer: B Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/extend/gu ... guide.html QUESTION 8
When should you use the force-unlock command?
A. You see a status message that you cannot acquire the lock



B. You have a high priority change
C. Automatic unlocking failed
D. Your apply failed due to a state lock
Correct Answer: C Section: (none) Explanation
Explanation/Reference:
Explanation:
Manually unlock the state for the defined configuration.
Reference: https://www.terraform.io/docs/cli/comma ... nlock.html
QUESTION 9
You have used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your Terraform configuration. To be safe, you would like to first see all the infrastructure that will be deleted by Terraform.
Which command should you use to show all of the resources that will be deleted? (Choose two.)
A. Run terraform plan -destroy.
B. This is not possible. You can only show resources that will be created.
C. Run terraform state rm *.
D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.
Correct Answer: CD Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/cli/comma ... te/rm.html QUESTION 10
What does the default "local" Terraform backend store?
A. tfplan files
B. Terraform binary C. Provider plugins D. State file



Correct Answer: D Section: (none) Explanation
Explanation/Reference:
Explanation:
The local backend stores state on the local filesystem, locks that state using system APIs, and performs operations locally.
Reference: https://www.terraform.io/docs/language/ ... local.html QUESTION 11
What value does the Terraform Cloud/Terraform Enterprise private module registry provide over the public Terraform Module Registry?
A. The ability to share modules with public Terraform users and members of Terraform Enterprise Organizations B. The ability to tag modules by version or release
C. The ability to restrict modules to members of Terraform Cloud or Enterprise organizations
D. The ability to share modules publicly with any user of Terraform
Correct Answer: D Section: (none) Explanation
Explanation/Reference:
Explanation:
Terraform Registry is an index of modules shared publicly using this protocol. This public registry is the easiest way to get started with Terraform and find modules created by others in the community.
Reference: https://www.terraform.io/docs/language/ ... urces.html QUESTION 12
You have declared a variable called var.list which is a list of objects that all have an attribute id. Which options will produce a list of the IDs? (Choose two.)
A. { for o in var.list : o => o.id } B. var.list[*].id
C. [ var.list[*].id ]
D. [ for o in var.list : o.id ]



Correct Answer: AB Section: (none) Explanation
Explanation/Reference:
QUESTION 13
When using a module block to reference a module stored on the public Terraform Module Registry such as:
How do you specify version 1.0.0?
A. Modules stored on the public Terraform Module Registry do not support versioning
B. Append ?ref=v1.0.0 argument to the source path
C. Add version = "1.0.0" attribute to module block
D. Nothing – modules stored on the public Terraform Module Registry always default to version 1.0.0
Correct Answer: A Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/language/ ... urces.html QUESTION 14
Which option can not be used to keep secrets out of Terraform configuration files?
A. A Terraform provider B. Environment variables C. A -var flag
D. secure string
Correct Answer: C Section: (none) Explanation



Explanation/Reference:
Reference: https://secrethub.io/blog/secret-manage ... terraform/ QUESTION 15
What is one disadvantage of using dynamic blocks in Terraform?
A. They cannot be used to loop through a list of values
B. Dynamic blocks can construct repeatable nested blocks C. They make configuration harder to read and understand D. Terraform will run more slowly
Correct Answer: A Section: (none) Explanation
Explanation/Reference:
Reference: https://github.com/hashicorp/terraform/issues/19291 QUESTION 16
Only the user that generated a plan may apply it.
A. True B. False
Correct Answer: A Section: (none) Explanation
Explanation/Reference:
Explanation:
The optional -out argument can be used to save the generated plan to a file for later execution with terraform apply, which can be useful when running Terraform in automation.
Reference: https://learn.hashicorp.com/tutorials/t ... -terraform
QUESTION 17
Examine the following Terraform configuration, which uses the data source for an AWS AMI. What value should you enter for the ami argument in the AWS instance resource?



A. aws_ami.ubuntu
B. data.aws_ami.ubuntu C. data.aws_ami.ubuntu.id D. aws_ami.ubuntu.id
Correct Answer: C Section: (none) Explanation
Explanation/Reference:
Explanation:
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
Reference: https://registry.terraform.io/providers ... s/instance
QUESTION 18
What is the name assigned by Terraform to reference this resource?



A. dev
B. azurerm_resource_group C. azurerm
D. test
Correct Answer: D Section: (none) Explanation
Explanation/Reference:
QUESTION 19
Where in your Terraform configuration do you specify a state backend?
A. The terraform block B. The resource block C. The provider block
D. The datasource block
Correct Answer: A Section: (none) Explanation
Explanation/Reference:
Explanation:
Backends are configured with a nested backend block within the top-level terraform block.
Reference: https://www.terraform.io/docs/language/ ... ation.html QUESTION 20
How would you reference the "name" value of the second instance of this fictitious resource?



A. element(aws_instance.web, 2) B. aws_instance.web[1].name
C. aws_instance.web[1]
D. aws_instance.web[2].name
E. aws_instance.web.*.name
Correct Answer: A Section: (none) Explanation
Explanation/Reference:
Reference: https://www.terraform.io/docs/configura ... ation.html