ExamGecko
Home Home / HashiCorp / Terraform Associate 003

HashiCorp Terraform Associate 003 Practice Test - Questions Answers, Page 7

Question list
Search
Search

Which of the following are advantages of using infrastructure as code (laC) instead of provisioning with a graphical user interface (GUI)? Choose two correct answers.

A.
Prevents manual modifications to your resources
A.
Prevents manual modifications to your resources
Answers
B.
Lets you version, reuse, and share infrastructure configuration
B.
Lets you version, reuse, and share infrastructure configuration
Answers
C.
Secures your credentials
C.
Secures your credentials
Answers
D.
Provisions the same resources at a lower cost
D.
Provisions the same resources at a lower cost
Answers
E.
Reduces risk of operator error
E.
Reduces risk of operator error
Answers
Suggested answer: B, E

Explanation:

Infrastructure as code (IaC) is a way of managing and provisioning cloud infrastructure using programming techniques instead of manual processes1. IaC has many advantages over using a graphical user interface (GUI) for provisioning infrastructure, such as:

* Versioning: IaC allows you to store your infrastructure configuration in a version control system, such as Git, and track changes over time. This enables you to roll back to previous versions, compare differences, and collaborate with other developers2.

* Reusability: IaC allows you to create reusable modules and templates that can be applied to different environments, such as development, testing, and production. This reduces duplication, improves consistency, and speeds up deployment3.

* Sharing: IaC allows you to share your infrastructure configuration with other developers, teams, or organizations, and leverage existing code from open source repositories or registries. This fosters best practices, innovation, and standardization4.

* Risk reduction: IaC reduces the risk of human error, configuration drift, and security breaches that can occur when provisioning infrastructure manually or using a GUI. IaC also enables you to perform automated testing, validation, and compliance checks on your infrastructure before deploying it5.

Reference =

* 1: What is Infrastructure as Code? Explained for Beginners - freeCodeCamp.org

* 2: The benefits of Infrastructure as Code - Microsoft Community Hub

* 3: Infrastructure as Code : Best Practices, Benefits & Examples - Spacelift

* 4: 5 Benefits of Infrastructure as Code (IaC) for Modern Businesses in the Cloud

* 5: The 7 Biggest Benefits of Infrastructure as Code - DuploCloud

What are some benefits of using Sentinel with Terraform Cloud/Terraform Cloud? Choose three correct answers.

A.
You can restrict specific resource configurations, such as disallowing the use of CIDR=0.0.0.0/0.
A.
You can restrict specific resource configurations, such as disallowing the use of CIDR=0.0.0.0/0.
Answers
B.
You can check out and check in cloud access keys
B.
You can check out and check in cloud access keys
Answers
C.
Sentinel Policies can be written in HashiCorp Configuration Language (HCL)
C.
Sentinel Policies can be written in HashiCorp Configuration Language (HCL)
Answers
D.
Policy-as-code can enforce security best practices
D.
Policy-as-code can enforce security best practices
Answers
E.
You can enforce a list of approved AWS AMIs
E.
You can enforce a list of approved AWS AMIs
Answers
Suggested answer: A, D, E

Explanation:

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


Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument.

A.
True
A.
True
Answers
B.
False
B.
False
Answers
Suggested answer: B

Explanation:

Terraform can manage resource dependencies implicitly or explicitly. Implicit dependencies are created when a resource references another resource or data source in its arguments. Terraform can infer the dependency from the reference and create or destroy the resources in the correct order. Explicit dependencies are created when you use thedepends_onargument to specify that a resource depends on another resource or module. This is useful when Terraform cannot infer the dependency from the configuration or when you need to create a dependency for some reason outside of Terraform's scope.Reference= :Create resource dependencies:Terraform Resource Dependencies Explained

Which provider authentication method prevents credentials from being stored in the state file?

A.
Using environment variables
A.
Using environment variables
Answers
B.
Specifying the login credentials in the provider block
B.
Specifying the login credentials in the provider block
Answers
C.
Setting credentials as Terraform variables
C.
Setting credentials as Terraform variables
Answers
D.
None of the above
D.
None of the above
Answers
Suggested answer: D

Explanation:

None of the above methods prevent credentials from being stored in the state file. Terraform stores the provider configuration in the state file, which may include sensitive information such as credentials. This is a potential security risk and should be avoided if possible. To prevent credentials from being stored in the state file, you can use one of the following methods:

Use environment variables to pass credentials to the provider. This way, the credentials are not part of the provider configuration and are not stored in the state file. However, this method may not work for some providers that require credentials to be set in the provider block.

Use dynamic credentials to authenticate with your cloud provider. This way, Terraform Cloud or Enterprise will request temporary credentials from your cloud provider for each run and use them to provision your resources. The credentials are not stored in the state file and are revoked after the run is completed. This method is supported for AWS, Google Cloud Platform, Azure, and Vault.Reference= : [Sensitive Values in State] :Authenticate providers with dynamic credentials

In Terraform HCL, an object type of object({name=string, age-number}) would match this value.

A)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: B

Which Terraform collection type should you use to store key/value pairs?

A.
Set
A.
Set
Answers
B.
Map
B.
Map
Answers
C.
Tuple
C.
Tuple
Answers
D.
list
D.
list
Answers
Suggested answer: B

Explanation:

The Terraform collection type that should be used to store key/value pairs ismap. A map is a collection of values that are accessed by arbitrary labels, called keys. The keys and values can be of any type, but the keys must be unique within a map. For example,var = { key1 = 'value1', key2 = 'value2' }is a map with two key/value pairs. Maps are useful for grouping related values together, such as configuration options or metadata.Reference= [Collection Types], [Map Type Constraints]

You add a new provider to your configuration and immediately run terraform apply in the CD using the local backend. Why does the apply fail?

A.
The Terraform CD needs you to log into Terraform Cloud first
A.
The Terraform CD needs you to log into Terraform Cloud first
Answers
B.
Terraform requires you to manually run terraform plan first
B.
Terraform requires you to manually run terraform plan first
Answers
C.
Terraform needs to install the necessary plugins first
C.
Terraform needs to install the necessary plugins first
Answers
D.
Terraform needs you to format your code according to best practices first
D.
Terraform needs you to format your code according to best practices first
Answers
Suggested answer: C

Explanation:

The reason why the apply fails after adding a new provider to the configuration and immediately runningterraform applyin the CD using the local backend is because Terraform needs to install the necessary plugins first. Terraform providers are plugins that Terraform uses to interact with various cloud services and other APIs. Each provider has a source address that determines where to download it from. When Terraform encounters a new provider in the configuration, it needs to runterraform initfirst to install the provider plugins in a local directory. Without the plugins, Terraform cannot communicate with the provider and perform the desired actions.Reference= [Provider Requirements], [Provider Installation]

Which two steps are required to provision new infrastructure in the Terraform workflow? Choose two correct answers.

A.
Plan
A.
Plan
Answers
B.
Import
B.
Import
Answers
C.
Alidate
C.
Alidate
Answers
D.
Init
D.
Init
Answers
E.
apply
E.
apply
Answers
Suggested answer: D, E

Explanation:

The two steps that are required to provision new infrastructure in the Terraform workflow areinitandapply. Theterraform initcommand initializes a working directory containing Terraform configuration files. It downloads and installs the provider plugins that are needed for the configuration, and prepares the backend for storing the state. Theterraform applycommand applies the changes required to reach the desired state of the configuration, as described by the resource definitions in the configuration files. It shows a plan of the proposed changes and asks for confirmation before making any changes to the infrastructure.Reference= [The Core Terraform Workflow], [Initialize a Terraform working directory with init], [Apply Terraform Configuration with apply]

What is the name of the default file where Terraform stores the state?

Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

A.
Terraformtfstate
A.
Terraformtfstate
Answers
Suggested answer: A

Explanation:

The name of the default file where Terraform stores the state isterraform.tfstate. This file contains a JSON representation of the current state of the infrastructure managed by Terraform. Terraform uses this file to track the metadata and attributes of the resources, and to plan and apply changes. By default, Terraform stores the state file locally in the same directory as the configuration files, but it can also be configured to store the state remotely in a backend.Reference= [Terraform State], [State File Format]

Which command add existing resources into Terraform state?

A.
Terraform init
A.
Terraform init
Answers
B.
Terraform plan
B.
Terraform plan
Answers
C.
Terraform refresh
C.
Terraform refresh
Answers
D.
Terraform import
D.
Terraform import
Answers
E.
All of these
E.
All of these
Answers
Suggested answer: D

Explanation:

This is the command that can add existing resources into Terraform state, by matching them with the corresponding configuration blocks in your files.

Total 195 questions
Go to page: of 20