wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

T5 # 221- 275

Total questions: 55

Worksheet time: 55mins

Name
Class
Date
1.

Which of the following state management command allow you to retrieve a list of resources that are part of the state file?

a)

terraform state list

b)

terraform state view

c)

terraform view

d)

terraform list

2.

If you delete a remote backend from the configuration, will you need to rebuild your state files locally?

a)

True

b)

False

3.

During a terraform apply, a resource is successfully created but eventually fails during provisioning. What happens to the resource?

a)

The resource will be planned for destruction and recreation upon the next terraform apply

b)

Terraform will retry to provision again.

c)

The failure of provisioner will be ignored and it will not cause a failure to terraform apply

d)

The resource will be automatically destroyed.

4.

Which of the following Terraform commands will automatically refresh the state unless supplied with additional flags or arguments? Choose TWO correct answers.

a)

terraform state

b)

terraform apply

c)

terraform plan

d)

terraform validate

e)

terraform output

5.

A user has created three workspaces using the command line - prod, dev, and test. The user wants to create a fourth workspace named stage. Which command will the user execute to accomplish this?

a)

terraform workspace new stage

b)

terraform workspace -new stage

c)

terraform workspace -create stage

d)

terraform workspace create stage

6.

You cannot publish your own modules on the Terraform Registry.

a)

True

b)

False

7.

Which of the following allows Terraform users to apply policy as code to enforce standardized configurations for resources being deployed via infrastructure as code?

a)

Sentinel

b)

Module registry

c)

Functions

d)

Workspaces

8.

In Terraform Enterprise, a workspace can be mapped to how many VCS repos?

a)

5

b)

2

c)

3

d)

1

9.

Terraform Enterprise currently supports running under which the following operating systems?

a)

A. Ubuntu B. Amazon Linux C. Debian D. CentOS E. Red Hat Enterprise Linux F. Oracle Linux

b)

Any

c)

None abobe

10.

Complete the following sentence: For local state, the workspaces are stored directly in a ___________.

a)

a file called terraform.tfstate.backup

b)

directory called terraform.workspaces.tfstate

c)

a file called terraform.tfstate

d)

directory called terraform.tfstate.d

11.

You can migrate the Terraform backend but only if there are no resources currently being managed.

a)

True

b)

False

12.

After running into issues with Terraform, you need to enable verbose logging to assist with troubleshooting the error. Which of the following values provides the MOST verbose logging?

a)

ERROR

b)

INFO

c)

WARN

d)

TRACE

e)

DEBUG

13.

From the answers below, select the advantages of using Infrastructure as Code.

Select four

a)

Provide a codified workflow to develop customer-facing applications.

b)

Safely test modifications using a "dry run" before applying any actual changes.

c)

Easily integrate with application workflows (GitLab Actions, Azure DevOps, CI/CD tools).

d)

Easily change and update existing infrastructure.

e)

Provide reusable modules for easy sharing and collaboration.

14.

What resource dependency information is stored in Terraform's state?

a)

Only implicit dependencies are stored in state.

b)

Both implicit and explicit dependencies are stored in state.

c)

Only explicit dependencies are stored in state.

d)

No dependency information is stored in state.

15.

Consider the following Terraform 0.12 configuration snippet:

1. variable "vpc_cidrs" {

2. type = map

3. default = {

4. us-east-1 = "10.0.0.0/16"

5. us-east-2 = "10.1.0.0/16"

6. us-west-1 = "10.2.0.0/16"

7. us-west-2 = "10.3.0.0/16"

8. }

9. }

10.

resource "aws_vpc" "shared" {

cidr_block = _____________

}

How would you define the cidr_block for us-east-1 in the aws_vpc resource using a variable?

a)

var.vpc_cidrs.0

b)

vpc_cidrs[“us-east-1”]

c)

var.vpc_cidrs[“us-east-1”]

d)

var.vpc_cidrs[0]

16.

Your organization has moved to AWS and has manually deployed infrastructure using the console. Recently, a decision has been made to standardize on Terraform for all deployments moving forward. What can you do to ensure that all existing is managed by Terraform moving forward without interruption to existing services?

a)

Submit a ticket to AWS and ask them to export the state of all existing resources and use terraform import to import them into the state file.

b)

Delete the existing resources and recreate them using new a Terraform configuration so Terraform can manage them moving forward.

c)

Resources that are manually deployed in the AWS console cannot be imported by Terraform.

d)

Using terraform import, import the existing infrastructure into your Terraform state.

17.

Which of the following actions are performed during a terraform init?

a)

Initializes downloaded and/or installed providers

b)

Initializes the backend configuration

c)

Provisions the declared resources in your configuration

d)

Download the declared providers which are supported by HashiCorp

18.

What is a downside to using the Vault provider to read secrets from Vault?

a)

Secrets are persisted to the state file and plans.

b)

Terraform and Vault must be running on the same version.

c)

Terraform and Vault must be running on the same physical host.

d)

Terraform requires a unique auth method to work with Vault.

19.

Given the below resource configuration -

resource "aws_instance" "web" {

# ...

count = 4

}

What does the terraform resource address aws_instance.web refer to?

a)

It refers to all 4 web instances , together , for further individual segregation , indexing is required , with a 0 based index.

b)

It refers to the last web EC2 instance , as by default , if no index is provided , the last / N-1 index is used.

c)

It refers to the first web EC2 instance out of the 4 ,as by default , if no index is provided , the first / 0th index is used.

d)

The above will result in a syntax error , as it is not syntactically correct . Resources defined using count , can only be referenced using indexes.

20.

State is a requirement for Terraform to function

a)

True

b)

False

21.

You wanted to destroy some of the dependent resources from real infrastructure. You choose to delete those resources from your configuration file and run terraform plan and then apply. Which of the following way your resources would be destroyed?

a)

Terraform can still determine the correct order for destruction from the state even when you delete one or more items from the configuration.

b)

Those would be destroyed in the order in which they were written in the configuration file previously before you have deleted them from configuration file.

c)

The resource will be destructed in random order as you have already deleted them from configuration.

d)

You can not destroy resources by deleting them from configuration file and running plan and apply

22.

Your developers are facing a lot of problem while writing complex expressions involving difficult interpolations . They have to run the terraform plan every time and check whether there are errors , and also check terraform apply to print the value as a temporary output for debugging purposes.

What should be done to avoid this?

a)

Use terraform console command to have an interactive UI with full access to the underlying terraform state to run your interpolations , and debug at real-time.

b)

Add a breakpoint in your code, using the watch keyword , and output the value to console for temporary debugging.

c)

Use terraform zipmap function , it will be able to easily do the interpolations without complex code.

d)

Use terraform console command to have an interactive UI , but you can only use it with local state , and it does not work with remote state.

23.

When writing Terraform code, HashiCorp recommends that you use how many spaces between each nesting level?

a)

0

b)

1

c)

2

d)

4

24.

When using parent/child modules to deploy infrastructure, how would you export a value from one module to import into another module. For example, a module dynamically deploys an application instance or virtual machine, and you need the IP address in another module to configure a related DNS record in order to reach the newly deployed application.

a)

Export the value using terraform export and input the value using terraform input.

b)

Configure the pertinent provider's configuration with a list of possible IP addresses to use.

c)

Configure an output value in the application module in order to use that value for the DNS module.

d)

Preconfigure the IP address as a parameter in the DNS module.

25.

You have configured an Auto Scaling group in AWS to automatically scale the number of instances behind a load balancer based on the instances CPU utilization. The instances are configured using a Launch Configuration. You have observed that the Auto Scaling group doesn't successfully scale when you apply changes that require replacing the Launch Configuration. Why is this happening?

a)

You need to configure an explicit dependency for the Auto Scaling group using the depends_on meta-parameter.

b)

You need to configure an explicit dependency for the Launch Configuration using the depends_on meta-parameter.

c)

You need to configure the Auto Scaling group's create_before_destroy meta-parameter.

d)

You need to configure the Launch Configuration's create_before_destroy meta-parameter.

26.

You have written a terraform IaC script which was working till yesterday , but is giving some vague error from today , which you are unable to understand . You want more detailed logs that could potentially help you troubleshoot the issue , and understand the root cause. What can you do to enable this setting? Please note , you are using terraform OSS.

a)

Terraform OSS can push all its logs to a syslog endpoint. As such, you have to set up the syslog sink, and enable TF_LOG_PATH env variable to the syslog endpoint and all logs will automatically start streaming.

b)

Detailed logs are not available in terraform OSS, except the crash message. You need to upgrade to terraform enterprise for this point.

c)

Enable the TF_LOG_PATH to the log sink file location, and logging output will automatically be stored there.

d)

Enable TF_LOG to the log level DEBUG, and then set TF_LOG_PATH to the log sink file location. Terraform debug logs will be dumped to the sink path, even in terraform OSS.

27.

Given the Terraform configuration below, in which order will the resources be created?

resource "aws_instance" "web_server"{

ami = "ami-b374d5a5"

instance_type = "t2.micro"

}

resource "aws_eip" "web_server_ip"{

vpc = true

instance = aws_instance.web_server.id

}

a)

aws_eip will be created first aws_instance will be created second

b)

aws_eip will be created first aws_instance will be created second

c)

Resources will be created simultaneously

d)

aws_instance will be created first aws_eip will be created second

28.

After executing a terraform apply, you notice that a resource has a tilde (~) next to it. What does this infer?

a)

The resource will be updated in place.

b)

The resource will be created.

c)

Terraform can't determine how to proceed due to a problem with the state file.

d)

The resource will be destroyed and recreated.

29.

A single terraform resource file that defines an aws_instance resource can simple be renamed to azurerm_virtual_machine in order to switch cloud providers

a)

True

b)

False

30.

A "backend" in Terraform determines how state is loaded and how an operation such as apply is executed. Which of the following is not a supported backend type?

a)

Terraform enterprise

b)

Consul

c)

Github

d)

S3

e)

Artifactory

31.

John is writing a module and within the module, there are multiple places where he has to use the same conditional expression but he wants to avoid repeating the same values or expressions multiple times in a configuration,. What is a better approach to dealing with this?

a)

Local Values

b)

Expressions

c)

Functions

d)

Variables

32.

You have created a custom variable definition file my_vars.tfvars. How will you use it for provisioning infrastructure?

a)

terraform apply -var-state-file ="my_vars.tfvars"

b)

terraform apply var-file="my_vars.tfvars"

c)

terraform plan -var-file="my_vars.tfvar"

d)

terraform apply -var-file="my_vars.tfvars"

33.

Which one is the right way to import a local module names consul?

a)

module "consul" {

source = "consul"

}

b)

module "consul" {

source = "consul"

}

c)

module "consul" {

source = "../consul"

}

d)

module "consul" {

source = "module/consul"

}

34.

Your team uses terraform OSS . You have created a number of resuable modules for important , independent network components that you want to share with your team to enhance consistency .

What is the correct option/way to do that?

a)

Terraform modules cannot be shared in OSS version . Each developer needs to maintain their own modules and leverage them in the main tf file.

b)

Upload your modules with proper versioning in the terraform public module registry . Terraform OSS is directly integrated with the public module registry , and can reference the modules from the code in the main tf file.

c)

Terraform module sharing is only available in Enterprise version via terraform private module registry , so no way to enable it in OSS version.

d)

Store your modules in a NAS/ shared file server , and ask your team members to directly reference the code from there. This is the only viable option in terraform OSS ,which is better than individually maintaining module versions for every developer.

35.

Using multi-cloud and provider-agnostic tools provides which of the following benefits?

a)

Operations teams only need to learn and manage a single tool to manage infrastructure, regardless of where the infrastructure is deployed.

b)

Increased risk due to all infrastructure relying on a single tool for management.

c)

Can be used across major cloud providers and VM hypervisors.

d)

Slower provisioning speed allows the operations team to catch mistakes before they are applied.

36.

A variable az has the following default value. What will be the datatype of the variable?

az=["us-west-1a","us-east-1a"]

a)

object

b)

list

c)

map

d)

string

37.

Your team lead does not trust the junior terraform engineers who now have access to the git repo . So , he wants you to have some sort of a checking layer , whereby , you can ensure that the juniors will not create any non-compliant resources that might lead to a security audit failure in future. What can you do to efficiently enforce this?

a)

Create a design /security document (in PDF) and share to the team , and ask them to always follow that document , and never deviate from it.

b)

Since your team is using Hashicorp Terraform Enterprise Edition , enable Sentinel , and write Policy-As-Code rules that will check for non-compliant resource provisioning , and prevent/report them.

c)

Use Terraform OSS Sentinel Lite version , which will save cost , since there is no charge for OSS , but it can still check for most non-compliant rules using Policy-As-Code.

d)

Create a git master branch , and implement PR . Every change needs to be reviewed by you , before being merged to the master branch.

38.

Which of the following connection types are supported by the remote-exec provisioner? (select two)

a)

WinRM

b)

UDP

c)

SMB

d)

RDP

e)

ssh

39.

Select all features which are exclusive to Terraform Enterprise. (Select Three)

a)

Sentinel

b)

Cost Estimation

c)

Audit Logs

d)

Clustering

e)

SAML/SSO

40.

Valarie has created a database instance in AWS and for ease of use is outputting the value of the database password with the following code. Valarie wants to hide the output value in the CLI after terraform apply that's why she has used sensitive parameter.

1. output "db_password" {

2. value = local.db_password

3. sensitive = true

4. }

Since sensitive is set to true, will the value associated with db password be available in plain-text in the state file for everyone to read?

a)

Yes

b)

No

41.

Select the feature below that best completes the sentence:

The following list represents the different types of __________ available in Terraform.

1. max

2. min

3. join

4. replace

5. list

6. length

7. range

a)

Backends

b)

Data sources

c)

Named values

d)

Functions

42.

Named workspaces are not a suitable isolation mechanism for strong separation between staging and production?

a)

True

b)

False

43.

Talal is a DevOps engineer and he has deployed the production infrastructure using Terraform. He is using a very large configuration file to maintain and update the actual infrastructure. As the infrastructure have grown to a very complex and large, he has started experiencing slowness when he run runs terraform plan. What are the options for him to resolve this slowness?

a)

Use -refresh=true flag as well as the -target flag with terraform plan in order to work around this.

b)

Run terraform refresh every time before running terraform plan.

c)

Break large configurations into several smaller configurations that can each be independently applied.

d)

Use -refresh=false flag as well as the -target flag with terraform plan in order to work around this.

44.

Your team has started using terraform OSS in a big way , and now wants to deploy multi region deployments (DR) in aws using the same terraform files . You want to deploy the same infra (VPC,EC2 ...) in both us-east-1 ,and us-west-2 using the same script , and then peer the VPCs across both the regions to enable DR traffic. But , when you run your script , all resources are getting created in only the default provider region.

What should you do? Your provider setting is as below -

# The default provider configuration

provider "aws" {

region = "us-east-1"

}

a)

No way to enable this via a single script . Write 2 different scripts with different default providers in the 2 scripts , one for us-east , another for us-west

b)

Create a list of regions , and then use a for-each to iterate over the regions , and create the same resources ,one after the one , over the loop.

c)

Use provider alias functionality , and add another provider for us-west region . While creating the resources using the tf script , reference the appropriate provider (using the alias).

d)

Manually create the DR region , once the Primary has been created , since you are using terraform OSS , and multi region deployment is only available in Terraform Enterprise.

45.

Which of the following is considered a Terraform plugin?

a)

Terraform language

b)

Terraform tooling

c)

Terraform logic

d)

Terraform provider

46.

Multiple provider instances blocks for AWS can be part of a single configuration file?

a)

False

b)

True

47.

In the example below, where is the value of the DNS record's IP address originating from?

1. resource "aws_route53_record" "www"

2. {

3. zone_id = aws_route53_zone.primary.zone_id

4. name = "www.example.com"

5. type = "A"

6. ttl = "300"

7. records = [module.web_server.instance_ip_address]

8. }

a)

The regular expression named module.web_server

b)

The output of a module named web_server

c)

By querying the AWS EC2 API to retrieve the IP address

d)

Value of the web_server parameter from the variables.tf file

48.

What does the command terraform fmt do?

a)

Rewrite Terraform configuration files to a canonical format and style.

b)

Deletes the existing configuration file.

c)

Updates the font of the configuration file to the official font supported by HashiCorp.

d)

Formats the state file in order to ensure the latest state of resources can be obtained.

49.

Which feature of Terraform allows multiple state files for a single configuration file depending upon the environment?

a)

Terraform Modules

b)

Terraform Enterprise

c)

Terraform Workspaces

d)

Terraform Remote Backends

50.

Terraform will sync all resources in state by default for every plan and apply, hence for larger infrastructures this can slow down terraform plan and terraform apply commands?

a)

True

b)

False

51.

Your company has a lot of workloads in AWS , and Azure that were respectively created using CloudFormation , and AzureRM Templates. However , now your CIO has decided to use Terraform for all new projects , and has asked you to check how to integrate the existing environment with terraform code. What should be your next plan of action?

a)

Tell the CIO that this is not possible . Resources created in CloudFormation , and AzureRM templates cannot be tracked using terraform.

b)

Use terraform import command to import each resource one by one

c)

This is only possible in Terraform Enterprise , which has the TerraformConverter exe that can take any other template language like AzureRM and convert to Terraform code

d)

Just write the terraform config file for the new resources , and run terraform apply , the state file will automatically be updated with the details of the new resources to be imported

52.

In order to make a Terraform configuration file dynamic and/or reusable, static values should be converted to use what?

a)

Input Parameters

b)

Module

c)

Regular Expressions

d)

Output Value

53.

Which Terraform command will check and report errors within modules, attribute names, and value types to make sure they are syntactically valid and internally consistent?

a)

terraform validate

b)

terraform format

c)

terraform fmt

d)

terraform show

54.

When using constraint expressions to signify a version of a provider, which of the following are valid provider versions that satisfy the expression found in the following code snippet: (select two)

1. terraform

2. {

3. required_providers

4. {

5. aws = "~> 1.2.0"

6. }

7. }

a)

1.3.1

b)

1.2.3

c)

1.2.9

d)

1.3.0

55.

resource "aws_s3_bucket" "example" {

bucket = "my-test-s3-terraform-bucket"

...

}

resource "aws_iam_role" "test_role" {

name = "test_role"

...

}

Due to the way that the application code is written ,

the s3 bucket must be created before the test role is created , otherwise there will be a problem.

How can you ensure that?

a)

This will already be taken care of by terraform native implicit dependency. Nothing else needs to be done from your end.

b)

Add explicit dependency using depends_on . This will ensure the correct order of resource creation.

c)

Create 2 separate terraform config scripts , and run them one by one , 1 for s3 bucket , and another for IAM role , run the S3 bucket script first.

d)

This is not possible to control in terraform . Terraform will take care of it in a native way , and create a dependency graph that is best suited for the parallel resource creation.