Deck 1 Flashcards

Learn 1st 20 (16 cards)

1
Q

The terraform.tfstate file always matches your currently built infrastructure.

A. True
B. False

A

Correct Answer: B
Reference:

https://www.terraform.io/docs/language/state/index.html
This state is stored by default in a local file named ··terraform.tfstate … but it can also be stored remotely, which works better in a team environment.

Terraform uses th is local state to create plans and make changes to your infrastructure. Prior to any operation. Terraform does a refresh to update the state with the real infrastructure.

The primary purpose of Terraform state is to store bindings between objects in a remote system and resource instances declared in your configuration. When Terraform creates a remote object in response to a change of configuration, it will record the identity of that remote object against a particular resource instance, and then potentially update or delete that object in response to future configuration changes.

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

One remote backend configuration always maps to a single remote workspace.

A. True
B. False

A

Correct Answer: A
Reference:
https://www.terraform.io/docs/language/settings/backends/remote.html
Workspaces
The remote backend can work with either a single remote Terraform Cloud workspace, or with multiple similarly-named remote workspaces (like networking-dev and networking-prod ). The workspaces block of the backend configuration determines which mode it uses:
To use a single remote Terraform Cloud workspace, set workspaces. name to the remote workspace’s full name (like networking ).

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

How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?

A. It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud
B. It doesn’t show the output of a terraform apply locally
C. It is only available to paying customers
D. All of the above

A

Correct Answer: A

If you and your team are using Terraform to manage meaningful infrastructure, we recommend using the remote backend with Terraform Cloud
or Terraform
Enterprise.
Reference:
https://www.terraform.io/docs/language/settings/backends/index.html

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

What is the workflow for deploying new infrastructure with Terraform?

A. terraform plan to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure.
B. Write a Terraform configuration, run terraform show to view proposed changes, and terraform apply to create new infrastructure.
C. terraform import to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure.
D. Write a Terraform configuration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create
new infrastructure.

A

Correct Answer: D

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

A provider configuration block is required in every Terraform configuration.
Example:
provider “provider name”{

}

A. True
B. False

A

False

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

You run a local-exec provisioner in a null resource called nulLresource.run_script and realize that you need to rerun the script.
Which of the following commands would you use first?

A. terraform taint null_resource.run_script
B. terraform apply -target=null_resource.run_script
C. terraform validate nulLresource.run_script
D. terraform plan -target=null_resource.run_script

A

Correct Answer: A

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

Which provisioner invokes a process on the resource created by Terraform?

A. remote-exec
B. null-exec
C. local-exec
D. file

A

Correct Answer: A

The remote-exec provisioner invokes a script on a remote resource after it is created.

Reference:
https://www.terraform.io/docs/language/resources/provisioners/remote·exec.html

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

Which of the following is not true of Terraform providers?

A. Providers can be written by individuals
B. Providers can be maintained by a community of users
C. Some providers are maintained by HashiCorp
D. Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers
E. None of the above

A

Correct Answer: D

Reference:
https://jayendrapatil.com/terraform-cheat-sheet/#Terraform_Read_and_write_conf1guration

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

What command does Terraform require the first time you run it within a configuration directory?

A. terraform import
B. terraform init
C. terraform plan
D. terraform workspace

A

Correct Answer: B

terraform init command is used to initialize a working directory containing Terraform configuration files.
Reference:
https://www.terraform.io/docs/cli/commands/init.html

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

You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code.
What is the best method to quickly find the IP address of the resource you deployed?

A. Run terraform output ip_address to view the result
B. In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the
state file
C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address
D. Run terraform destroy then terraform apply and look for the IP address in stdout

A

Correct Answer: A
Reference:
https://www.terraform.io/docs/cli/commands/output.html

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

Which of the following is not a key principle of infrastructure as code?
Choose all that apply

A. Versioned infrastructure
B. Golden images
C. ldempotence
D. Self-describing infrastructure

A

ABD

https://docs.microsoft.com/en-us/azure/devops/learn/what-is-infrastructure-ascode#:~:
text=ldempotence%20is%20a%20principle%20of,of%20the%
20environment’s%20starting%20state

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

Terraform variables and outputs that set the “description” argument will store that description in the state file.

A. True
B. False

A

A. True

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

What is the provider for this fictitious resource?
resource “aws_vpc” “main” {
name= “test”

A. vpc
B. main
C. aws
D. test

A

C. AWS

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

If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform?

A. Run terraform refresh
B. It will happen automatically
C. Manually update the state fire
D. Run terraform import

A

A. Run terraform refresh

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

What is not processed when running a terraform refresh?

A. State file
B. Configuration file
C. Credentials
D. Cloud provider

A

B. Configuration file

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