When should you write Terraform configuration files for existing infrastructure that you want to start managing with Terraform?
Answer(s): C
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.
Answer(s): B
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?
Answer(s): D
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.
Answer(s): A
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?
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.
Post your Comments and Discuss HashiCorp Terraform Associate 004 exam prep with other Community members: