Exam 1 Review Flashcards

1
Q

Using terraform apply -replace is how you

A

tag a resource for replacement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False? A provider block is required in every configuration file so Terraform can download the proper plugin.

A

You don’t have to specify a provider block since Terraform is smart enough to download the right provider based on the specified resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Can the child modules refer to any of the variables declared in the parent module?

A

Child modules can only access variables that are passed in the calling module block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If an engineer makes a change outside of Terraform, what command can you run to detect drift and update the state file?

A

terraform apply -refresh-only

Note that terraform refresh used to be the correct command here, but that command is deprecated. It might show up on the exam though.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which of the features below is not available in the free version of Terraform Cloud?

Private Module Registry
State Management
Remote Operations
Single Sign-On

A

Single Sign-On is a feature of Terraform Enterprise and Terraform Cloud for Business. It is NOT available in Terraform Cloud (free tier)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A child module created a new subnet for some new workloads. What Terraform block type would allow you to pass the subnet ID back to the parent module?

A

You need to use an output block to be able to export any data back to the parent/calling module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A user manually logged into the AWS console and updated a resource managed by Terraform, but you also updated that same resource using the code. What will happen when you run Terraform apply since the change was already made?

A

A terraform apply will run its own state refresh and TF will see the configuration matches the deployed infrastructure. Nothing will happen as a result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Private Module Registry and what are its features? (2)

A
  • You can store and distribute Terraform modules within an organization, making it easier to share code and ensure consistency across multiple projects.
  • Some of its features include versioning, access controls, and integration with existing CI/CD pipelines.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When you run a terraform init, where does Terraform OSS download and store the modules locally?

A

When plugins and modules are downloaded, they are stored under their respective directory in the .terraform/modules folder within the current working directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax to refer to a resource?

A

To refer to a resource, you’d use
<block type>.<resource type>.<name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the syntax to set the value of an input variable using environment variables?

A

You need to use TF_VAR_ to set an environment variable for use with Terraform
export TF_VAR_<variable name>=<desired_input>
export TF_VAR_user=dbadmin101

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Workspaces in OSS are often used within the ____ _______ _________ while workspaces in Enterprise/Cloud are often (but not required) mapped to _____ ______

A

Workspaces in OSS are often used within the same working directory while workspaces in Enterprise/Cloud are often (but not required) mapped to specific repos.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or False? When you are referencing a module, you must specify the version of the module in the calling module block.`

A

While it’s not required, it is highly recommended to specify the version for each module to avoid issues with newer versions of the module that could break your configuration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain how the local-exec provisioner works.

A

The local-exec provisioner executes a local command after creating a resource. It runs on the machine where Terraform is running, not on the resource itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain parallelism in Terraform.

A

Parallelism is the way Terraform can deploy many resources at the same time to speed up the deployment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

You have a configuration file that you’ve deployed to one AWS region already but you want to deploy the same configuration file to a second AWS region without making changes to the configuration file. What feature of Terraform can you use to accomplish this?

A

Use Terraform’s workspaces feature.

Workspaces allow you to manage multiple instances of the same infrastructure with different variables or states. By creating a new workspace for the second AWS region, you can deploy the same configuration file without making any changes.

17
Q

To use Terraform’s workspaces feature to deploy the same configuration file to a second AWS region without making changes to the configuration file, follow these three steps:

A
  1. Create a new workspace for the second AWS region using the terraform workspace new <workspace_name> command.
  2. Switch to the new workspace using the terraform workspace select <workspace_name> command.
  3. Apply the configuration file using the terraform apply command.
18
Q

When enabled at what point in the terraform workflow does Sentinel run?

A

Sentinel runs after a terraform plan, but before a terraform apply.

19
Q

What should the code look like to ensure you’re using a specific version of the AWS provider?

A

To specify the version of Terraform provider that is required, you need to use the required_providers block parameter under the terraform block

terraform {
  required_version = ">= 1.0"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
   }
}
20
Q

You are managing multiple resources using Terraform running in AWS. You want to destroy all the resources except for a single web server. How can you accomplish this?

A

To accomplish this, you need to delete a resource from state, you can use the terraform state rm <address> command, which will effectively make Terraform “forget” the object while it continues to exist in the remote system.

Then you can run a terraform destroy to destroy the remaining resources.

To