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
What is the use of local-exec in terraform? Choose all that apply
- A. to invoke commands locally on the remote host
- B. usually to run commands on the machine where terraform is running
- C. use to invoke scripts locally
- D. locally create variables and run in terraform
B. usually to run commands on the machine where terraform is running
C. use to invoke scripts locally
You are making some changes to terraform configuration and do you need to apply to terraform init every time?
What are the cases where terraform init needs to be called?
Choose 3
A. on any new environment that configures a backend
B. on removing backend configuration completely
C. on any change of backend configuration
D. Every time you add some configs run init so that it makes sure everything is up to date
A. on any new environment that configures a backend
B. on removing backend configuration completely
C. on any change of backend configuration
Please choose the operation systems which support terraform enterprise. Choose all that are applicable?
A. Fedora B. Ubuntu 16.04.3 C. Centos - 7.7 D. Windows 7 E. All of the above
B. Ubuntu 16.0.4.3
C. Centos - 7.7
What are the benefits of a private registry? Please choose 3 from below:
A. Terraform cloud private registry is a paid feature B. Using a private registry all the modules can be shared across within or across organizations. C. It supports module versioning, filterable list of available modules, and configuration designer to build new workspaces D. It is very similar to public terraform registry
B. Using a private registry all the modules can be shared across within or across organizations. C. It supports module versioning, filterable list of available modules, and configuration designer to build new workspaces D. It is very similar to the public terraform registry
What features are exclusive to Terraform Enterprise from below. (select three)
A. Saml/sso B. Audit logging C. Remote state D. ServiceNow integration E. Private module registry
A. Saml/sso
B. Audit Logging
D. ServiceNow integration
What does the .terraform.lock.hcl file responsible for?
This is the dependency lock file that tracks only provider dependencies.
The lock file is always named .terraform.lock.hcl, and this name is intended to signify that it is a lock file for various items that Terraform caches in the .terraform subdirectory of your working directory.
Terraform automatically creates or updates the dependency lock file each time you run the terraform init command.
Terraform 0.14 added support for a lock file which gets created or updated every time you run terraform init. The file is typically generated into your working directory (i.e., the folder in which you ran terraform init) and is called .terraform.lock.hcl. “It captures the versions of all the Terraform providers you’re using”. Normally, you want to check this file into version control so that when your team members run Terraform, they get the exact same provider versions.
When terraform init is working on installing all of the providers needed for a configuration, “Terraform considers both the version constraints in the configuration and the version selections recorded in the lock file.”
If a particular provider has no existing recorded selection, Terraform will select the newest available version that matches the given version constraint, and then update the lock file to include that selection.
If a particular provider already has a selection recorded in the lock file, Terraform will always re-select that version for installation, even if a newer version has become available. You can override that behavior by adding the -upgrade option when you run terraform init, in which case Terraform will disregard the existing selections and once again select the newest available version matching the version constraint.
Because the dependency lock file is primarily maintained automatically by Terraform itself, rather than being updated manually by you or your team, your version control system may show you that the file has changed.
Terraform refresh is automatically run in which of the following commands?
- terraform state
- terraform output
- terraform validate
- terraform plan
- terraform apply
- terraform plan
- terraform apply