How would you reference the "name'' value of the second instance of this resource?
Correct Answer: D
In Terraform, when you use the count meta-argument, you can reference individual instances using an index. The indexing starts at 0, so to reference the "name" value of the second instance, you would use aws_instance.web[1].name. This syntax allows you to access the properties of specific instances in a list generated by the count argument. Reference: Terraform documentation on count and accessing resource instances: Terraform Count
Terraform-Associate-003 Exam Question 67
Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Cloud automatically and proactively enforce this security control?
Correct Answer: D
The best way to automatically and proactively enforce the security control that new AWS S3 buckets must be private and encrypted at rest is with a Sentinel policy, which runs before every apply. Sentinel is a policy as code framework that allows you to define and enforce logic-based policies for your infrastructure. Terraform Cloud supports Sentinel policies for all paid tiers, and can run them before any terraform plan or terraform apply operation. You can write a Sentinel policy that checks the configuration of the S3 buckets and ensures that they have the proper settings for privacy and encryption, and then assign the policy to your Terraform Cloud organization or workspace. This way, Terraform Cloud will prevent any changes that violate the policy from being applied. Reference = [Sentinel Policy Framework], [Manage Policies in Terraform Cloud], [Write and Test Sentinel Policies for Terraform]
Terraform-Associate-003 Exam Question 68
Which of the following methods, used to provision resources into a public cloud, demonstrates the concept of infrastructure as code?
Correct Answer: C
The concept of infrastructure as code (IaC) is to define and manage infrastructure using code, rather than manual processes or GUI tools. A script that contains a series of public cloud CLI commands is an example of IaC, because it uses code to provision resources into a public cloud. The other options are not examples of IaC, because they involve manual or interactive actions, such as running curl commands, sending REST requests, or entering commands into a console. Reference = [Introduction to Infrastructure as Code with Terraform] and [Infrastructure as Code]
Terraform-Associate-003 Exam Question 69
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout.
Correct Answer: A
Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into stdout, along with other log levels such as TRACE, INFO, WARN, and ERROR. This can be useful for troubleshooting or debugging purposes.
Terraform-Associate-003 Exam Question 70
What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.
Correct Answer: A,D,E
Sentinel is a policy-as-code framework that allows you to define and enforce rules on your Terraform configurations, states, and plans1. Some of the benefits of using Sentinel with Terraform Cloud/Terraform Enterprise are: * You can restrict specific resource configurations, such as disallowing the use of CIDR=0.0.0.0/0, which would open up your network to the entire internet. This can help you prevent misconfigurations or security vulnerabilities in your infrastructure2. * Policy-as-code can enforce security best practices, such as requiring encryption, authentication, or compliance standards. This can help you protect your data and meet regulatory requirements3. * You can enforce a list of approved AWS AMIs, which are pre-configured images that contain the operating system and software you need to run your applications. This can help you ensure consistency, reliability, and performance across your infrastructure4. Reference = * 1: Terraform and Sentinel | Sentinel | HashiCorp Developer * 2: Terraform Learning Resources: Getting Started with Sentinel in Terraform Cloud * 3: Exploring the Power of HashiCorp Terraform, Sentinel, Terraform Cloud ... * 4: Using New Sentinel Features in Terraform Cloud - Medium