What feature stops multiple users from operating on the Terraform state at the same time?
A
Explanation:
State locking prevents other users from modifying the state file while a Terraform operation is in
progress. This prevents conflicts and data loss1.
Which of the following is not a valid string function in Terraform?
C
Explanation:
Referencing Terraform Built-in Functions:
✅
chomp: removes trailing newlines
✅
join: combines list into string
✅
split: splits string into list
❌
slice:is nota valid Terraform string function (it's used in other languages like Python)
What does the default "local" Terraform backend store?
B
Explanation:
The default “local” Terraform backend stores the state file in a local file named terraform.tfstate,
which can be used to track and manage the state of your infrastructure3.
How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control
System (VCS) repository?
B
Explanation:
This will trigger a run in the Terraform Cloud workspace, which will perform a plan and apply
operation on the infrastructure defined by the Terraform configuration files in the VCS repository.
You're building a CI/CD (continuous integration/continuous delivery) pipeline and need to inject
sensitive variables into your Terraform run. How can you do this safely?
D
Explanation:
This is a secure way to inject sensitive variables into your Terraform run, as they will not be stored in
any file or source code repository. You can also use environment variables or variable files with
encryption to pass sensitive variables to Terraform.
When should you write Terraform configuration files for existing infrastructure that you want to start
managing with Terraform?
C
Explanation:
You need to write Terraform configuration files for the existing infrastructure that you want to import
into Terraform, otherwise Terraform will not know how to manage it. The configuration files should
match the type and name of the resources that you want to import.
Variables declared within a module are accessible outside of the module.
B
Explanation:
Variables declared within a module are only accessible within that module, unless they are explicitly
exposed as output values1.
Your security team scanned some Terraform workspaces and found secrets stored in plaintext in state
files. How can you protect that data?
D
Explanation:
This is a secure way to protect sensitive data in the state file, as it will be encrypted at rest and in
transit2. The other options are not recommended, as they could lead to data loss, errors, or security
breaches.
If you update the version constraint in your Terraform configuration, Terraform will update your lock
file the next time you run terraform Init.
A
Explanation:
If you update the version constraint in your Terraform configuration, Terraform will update your lock
file the next time you run terraform init3. This will ensure that you use the same provider versions
across different machines and runs.
Once you configure a new Terraform backend with a terraform code block, which command(s) should
you use to migrate the state file?
A
Explanation:
This command will initialize the new backend and prompt you to migrate the existing state file to the
new location4. The other commands are not relevant for this task.