Eleventh Flashcards Preview

P211A000N02F > Eleventh > Flashcards

Flashcards in Eleventh Deck (5)
Loading flashcards...
1

You are a DevOps Engineer and you want to automate the provision of your IaC using Jenkins Pipelines and Terraform.
After checkout, the repository with your Terraform code, what would be the next step to be executed on your Pipeline to work with Terraform and initialize the terraform work directory?

A. terraform validate
B. terraform init
C. terraform plan
D. terraform apply

B. terraform init

Every time that we check out the infrastructure from a version control we must initialize the terraform code using terraform init

A is incorrect because terraform validate the configuration but don’t initialize the Terraform backend

C and D are incorrect because we need to install the plugins, providers and clone the module that we will use before doing a plan or apply our infrastructure

https://learn.hashicorp.com/tutorials/terraform/aws-build#initialize-the-directory

2

terraform validate checks and validate the access to the terraform state and remote states

A. True
B. False

B. False

terraform validate just checks if the terraform code is syntactically valid without access to remote states

A is incorrect because validate just check the terraform code syntactically

https://www.terraform.io/docs/cli/commands/validate.html

3

You are a DevOps Engineer and you want to automate the provision of your IaC using Jenkins Pipelines,GitHub, and Terraform.

You have a variable that is assigned to all the AWS resources of your infrastructure as a tag called commit_hash.

How can you specify this variable during the plan stage?

A. You have to edit your variables files before executing a plan
B. You can’t assign single values during your execution plan
C. terraform plan -var ‘commit_hash=my_commit_hash_value’
D. terraform plan -var commit_hash=my_commit_hash_value

C. terraform plan -var ‘commit_hash=my_commit_hash_value’

Terraform is using the argument -var ‘variable=value’ when you want to set a value into a variable during the plan or the apply

A is incorrect because it is not necessary to edit the variables file configuration to modify your variables’ value. You can do it using the ‘-var’ argument

B is incorrect because you can assign variables during the plan and apply executions

D is incorrect due to a syntax error (Missing quotes)

https://www.terraform.io/docs/cli/commands/plan.html#var-39-foo-bar-39-

4

Terraform will ask you in an interactive approval of your infrastructure when executing terraform apply. How can you skip this approval?

A. terraform apply -force=yes
B. terraform apply -yes
C. terraform apply -approve=yes
D. terraform apply -auto-approve

D. terraform apply -auto-approve

You can use the flag -auto-approve to skip the interactive approval of your terraform apply execution

A, B and C are incorrect as these flags don’t exist as a terraform apply arguments

https://www.terraform.io/docs/cli/commands/apply.html#auto-approve
https://www.terraform.io/docs/cli/commands/apply.html#usage

5

How can you destroy a particular resource of your state during the terraform destroy execution?

A. terraform destroy -target=RESOURCE_TYPE.NAME
B. terraform destroy -resource=RESOURCE_TYPE.NAME
C. terraform destroy RESOURCE_TYPE.NAME
D. terraform destroy will destroy all the infrastructure based on our terraform state. You can’t specifya single resource

A. terraform destroy -target=RESOURCE_TYPE.NAME

A is the correct answer as you can specify a target of a single resource (or resources) where you can execute your terraform destroy

B is incorrect because this argument doesn’t exist

C is incorrect because you have to specify a flag where you pass your arguments

D is incorrect as this assumption can be modified using the argument “-target”

https://www.terraform.io/docs/cli/commands/destroy.html
https://www.terraform.io/docs/cli/commands/plan.html#resource-targeting