wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Terraform Day 2 Accenture

Total questions: 27

Worksheet time: 9mins

Name
Class
Date
1.

Which command initializes the terraform configuration?

a)

terraform start

b)

terraform init

c)

terraform fmt

d)

terraform apply

2.

What does the terraform plan command do?

a)

Applies the changes required to reach the desired state of the configuration

b)

Shows the execution plan for the changes required to reach the desired state

c)

Initializes the configuration

d)

Deletes the resources defined in the configuration

3.

When checking the syntax of Terraform configuration files, which command ought to be executed?

a)

terraform check

b)

terraform validate

c)

terraform plan

d)

terraform fmt

4.

What happens when you apply Terraform configuration? Choose TWO correct answers.

a)

Terraform makes any infrastructure changes that are defined in your configuration.

b)

Terraform gets the plugins that the configuration requires.

c)

Terraform updates the state file with the configuration changes it made.

d)

Terraform will destroy and recreate all your infrastructure from scratch.

5.

What is the workflow for deploying new infrastructure when using Terraform?

a)

Use the Terraform plan command to import the current infrastructure to the state file, make code changes, and run the Terraform apply command to update the infrastructure.

b)

Write the Terraform configuration, run the terraform show command to view proposed changes, and run terraform apply to create the new infrastructure.

c)

Terraform import is used to import the current infrastructure to the state file, make code changes, and apply terraform 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.

6.

How do you specify a provider in a Terraform configuration file?

a)

provider "name" { }

b)

module "name" { }

c)

resource "name" { }

d)

data "name" { }

7.

What is the default file name where Terraform stores its state locally?

a)

state.tf

b)

terraform.state

c)

terraform.tfstate

d)

terraform.tf.state

8.

Does running 'terraform init' automatically initialize a file named 'main.tf'

a)

Yes

b)

No

9.

In the context of Terraform, what does "Desired State Management" refer to?

a)

The current configuration of the infrastructure

b)

The configuration that should be applied to the infrastructure

c)

The historical state of the infrastructure

d)

The default settings of the infrastructure

10.

If we need to destroy the Terraform-managed infrastructure using terraform destroy command without confirmation which option should we use?

a)

-auto-noapprove

b)

-auto-proceed

c)

-auto-destroy

d)

-auto-approve

11.

We have copied a sample terraform code from a GitHub repository to his local terraform configuration file.

There are certain formatting issues in the code.

resource "aws_instance" "cloudthat-ec2" {

ami = "ami-090fa75af13c156b4"

instance_type = "m5.large"

count = 5

}

Which command can we run to ensure that code is automatically formatted?

a)

terraform code format

b)

terraform format

c)

terraform fmt

d)

none of the given

12.

Code in the Terraform language is stored in files with the ........... file extension

a)

.tf


b)

.yml

c)

.sh

d)

.terra

13.

Terraform commands order ………….


a)

terraform init,terraform plan,terraform apply,terraform destroy

b)

terraform init,terraform apply,terraform plan,terraform destroy


c)

terraform plan,terraform init,terraform apply,terraform destroy

d)

terraform apply,terraform plan,terraform init,terraform destroy

14.

There is a requirement to save a terraform plan to a specific file.

Which of the following command can be used to achieve this use-case?

a)

terraform plan out <filename>

b)

terraform output plan <filename>

c)

terraform plan -out=<filename>

d)

terraform plan <filename>

15.

You are provisioning a set of virtual machines using Terraform, each with its own set of tags(key-value pairs) for classification and organization. Which collection type in Terraform would be most suitable for representing the set of tags for each virtual machine?

a)

list

b)

set

c)

object

d)

map

16.

Terraform apply creates an EC2 instance (name: example)
We want Terraform to display the private_ip of the EC2 after creation automatically. How can we do this?

a)

output "privateip"
{
value = aws_instance.example.private_ip
}

b)

input "privateip"
{
value = aws_instance.example.private_ip
}

c)

data "privateip"
{
value = aws_instance.example.private_ip
}

d)

output "privateip"
{
value = example.private_ip
}

17.

What is the purpose of the "terraform.tfvars" file?

a)

To define variables that are specific to a particular environment

b)

To define variables that are automatically loaded by Terraform

c)

To manage state

d)

To define providers

18.

Your Terraform configuration deployed a web application, including an AWS EC2 instance. Now, you require the public IP address of the instance.

a)

Execute terraform show and search for the public IP address in the output.

b)

Use the AWS Management Console to locate the public IP address.

c)

Check the terraform.tfstate file for the public IP address.

d)

Run terraform output and specify the name of the output variable containing the public IP address.

19.

What is the main purpose of using locals in Terraform?

a)

To define resources that are only available within the local network and not accessible from the internet.

b)

To define reusable values or expressions that can be referenced within the Terraform configuration.

c)

To create remote connections to other Terraform configurations or infrastructure deployments.

d)

To manage the state of Terraform resources and track changes over time.

20.

Which block is used to define local values in Terraform?



(a)  

21.

You are managing a Terraform configuration for deploying a network infrastructure. You need to retrieve a value from a map based on a specific key. Which function should you use?

a)

get()

b)

lookup()

c)

find()

d)

search()

22.

Which Terraform function is used to retrieve a specific element from a list?

a)

lookup()

b)

fetch()

c)

search()

d)

element()

23.

Can we create a function and use it in our terraform configuration?

a)

No

b)

Yes

24.

Which data structure in Terraform is used to store unique values without any specific order?

a)

list

b)

set

c)

map

d)

tuple

25.

Which of the following best describes a Terraform data source?

a)

A plugin to extend Terraform's functionality.

b)

A mechanism to retrieve information from external systems for use in your configuration.

c)

A module to provision infrastructure resources.

d)

A backend storage for Terraform state files.

26.

Your organization has been managing AWS resources manually or with another tool, and now you are transitioning to using Terraform for infrastructure as code. You need to reference existing VPCs, subnets, and security groups that were created outside of Terraform to avoid duplicating infrastructure and ensure consistency. Which option is most suitable?

a)

By storing state files remotely.

b)

By defining output variables.

c)

By using version control for configuration files.

d)

By using data sources

27.

Usernames and passwords referenced in the Terraform code, even as variables, will end up in plain text in the state file.

a)

True

b)

False