Terraform Flashcards
You have configured a variable and didn’t set any value and when you do ‘terraform plan’ does it ask for input value?
True
False
True
Whenever there is a variable set and no value configured upon terraform plan it will give you an option to enter the value
On terraform plan command execution log, you see tilde (~) sign. What does this sign represent? Whether the resource it is pointing to will get deleted on terraform apply?
True
False
False
Tilde symbol means resources will be updated in place.
is state-unlock the command to unlock the locked state file
True
False
False
Force-unlock is the command to remove lock from a state file
Hashicorp suggests using local-exec to run scripts on local machines with null_resources.
True
False
True
Not all of the “backend types” support locking? Please choose from below which support locking?
- artifactory
- consul
- DynamoDB
- azurerm
- consul
- DynamoDB
- azurerm
You have configured 10 instances from a single configuration by using which configuration you can keep switching back ?
- workspaces
- local values
- backend
- remote_exec
- workspaces
Which of the following is not a native Infrastructure as code tool?
- Cloudformation
- Azure Resource Manager
- Terraform
- Puppet
Puppet
Terraform allows you to define multiple providers resources in a single terraform configuration file?
True
https://www.terraform.io/intro/use-cases.html%23multi-cloud-deployment
What happens if a provisioner fails to execute?
when = destroy
1) . Terraform will error
2) . Rerun the provisioners again on the next terraform apply
Due to this behavior, care should be taken for destroy provisioners to be safe to run multiple times.
A newbie is allocated to a terraform project, he/she has been given the task of configuring applications on servers using terraform. All the servers are created using terraform. While doing configuration he/she succeeds in all servers, but one server is messed due to application configuration. So he wants to destroy this server and launch a new one.
A terraform destroy -target=resource_name.variable_name
B terraform plan -target=resource_name.variable_name then terraform apply
C terraform taint resource_name.variable_name then terraform apply
D terraform state rm resource_name.variable_name then terraform apply
C. terraform taint resource_name.variable_name then terraform apply
What happens when a “terraform taint” is applied to a resource?
A terraform will destroy the resource
B. terraform will modify the state file with resource status marked as tainted
C. terraform will destroy and recreate a new resource with the same configuration
D. terraform destroys and recreates all resources in the state file
B. terraform will modify the state file with resource status “marked as tainted”.
Terraform represents this by marking the object as “tainted” in the Terraform state, in which case Terraform will propose to replace it in the next plan you create.
Bob works for a company Fusion Corp. The internal IT team has downloaded and kept the plugins in common path so that all team members use the same version of plugins. How can
configure terraform to use these pre-downloaded plugins, instead of downloading new plugins.
A terraform init plugin-dir-PATH
B.terraform init ~plugin-path=PATH
C. terraform init -get-plugins=PATH
D.terraform init plugin-file=PATH
terraform init plugin-dir-PATH
Explanation:
Answer: A
+ Option A is CORRECT plugin-dir option Skips plugin installation and loads plugins only from the specified directory.
+ Option Bi s INCORRECT because plugin-path option is not present in nit command
+ Option C is INCORRECT because get-plugins accepts value a Boolean value. Skips plugin installation, Terraform will use plugins installed in the user plugins directory. and any
plugins already installed for the current working directory. Ifthe installed plugins aren’t sufficient for the configuration, init fal
+ Option Dis INCORRECT plugin-fil is not a valid option for init command,
~plugin-dir=PATH Skips plugin installation and loads plugins only from the specified directory. This ignores the user plugins directory and any plugins already installed in the current
Which of the following is true about third-party plugins? (Select two)
A. Third-party plugins also get downloaded automatically from Terraform version 0.12
B. Third-party plugins (both providers and provisioners) can be manually installed into the user plugins directory based on the OS
C. Third-party plugins should be installed only into the user plugins directory, no other directories are supported for third party plugins
D. Third-party plugins that are approved by HashiCorp are supported
E. Plugins can be written only in Go Language
B. Third-party plugins (both providers and provisioners) can be manually installed into the user plugins directory based on the OS
D. Plugins can be written only in Go Language
How to save a destroy plan to a file before destroying it?
- terraform plan -destroy
- terraform plan
- terraform plan -out=PATH
- terraform plan -destroy -out=PATH
terraform plan -destroy -out=PATH
How can we skip the interactive approval for terraform apply command? (Select two)
A. terraform apply –auto-approve
B. terraform apply-yes
C. terraform plan -out=”test.tfplan” and terraform apply test.tfplan
D. terraform apply -auto-approve=true
A. terraform apply –auto-approve
C. terraform plan -out=”test.tfplan” and terraform apply test.tfplan
Which of the following is true about local backend? (select two)?
A. local backend stores state on the local file system
B. locks that state using system APIs
C. performs operations locally and remotely
D. Data at rest is encrypted by terraform
E. locks that state using terraform prebuilt APIs
A. local backend stores state on the local file system
B. locks that state using system APIs
When multiple team members are working on the same state file, the state file gets locked. How would you remove the lock?
- terraform force-unlock LOCK_ID
- terraform force-unlock STATE_FILE
- terraform unlock LOCK_ID
- terraform force-unlock=true
- terraform force-unlock LOCK_ID
Usage: terraform force-unlock [options] LOCK_ID [DIR]
https://www.terraform.io/docs/cli/commands/force-unlock.html
Which of the following backends supports “state storage” with default locking? (Select two)
- s3
- azurerm
- gcs
- http
- artifactory
- azurerm
- gcs
Bob wants to see all the terraform output values stored in terraform.tfstate file. Which of the below commands will do the task? (Select Three)
A. terraform output B. terraform show C. terraform output -state=terraform.state D. terraform state list E. terraform show terraform.tfstate
A. terraform output
B. terraform show
C. terraform output -state=terraform.tfstate
https://www.terraform.io/docs/cli/commands/output.html
What are the benefits of using consul? (Select Two)
A. Consul is a tool not for orchestration
B. Consul is used for service discovery and configuration
C. Consul helps to expose resources to be used to interact with consul cluster
D. Consul is not a provider for consul remote state backend
B. Consul is used for service discovery and configuration
C. Consul helps to expose resources to be used to interact with consul cluster
https://registry.terraform.io/providers/hashicorp/consul/latest/docs
Please identify which of the below features best apply
resource “aws_ec2_instance
{
name ‘test-terraforn”
application = “S{aws_ec2_instance. test-terraforn }”
dynamic “setting”
{
for_each = var.test
content
{
}
}
A. Resource
B. Providers
C. Local-exec
D.Dynamic-block
Explanation:
Answer:D Dynamic Block
https://wwterraformio|does/configuration/expressionshtmt
‘dynamic blocks are to be defined and can define multiple nested blocks inside the dynamic block
What are the benefits of policy as code feature sentinel?
A. Sandboxing
B. Encryption
C. Automation
D. Codification
A. Sandboxing
C. Automation
D. Codification
You been asked to manually taint a resource using cli which commands from below you use?
A. terraform taint -resource-name
B. terraform taint resource.id
C. terraform taint = resource.id
D. terraform taint resource.id -name
B. terraform taint resource.id
https://www.terraform.io/docs/commands/taint.html
You are using a vault provider, and during what phase does it get the data?
- terraform refresh
- terraform apply
- terraform plan
- terraform init
- terraform init