wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TFTJS

Total questions: 68

Worksheet time: 34mins

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

28.

You write a new Terraform configuration and immediately run terraform apply in the CLI using the local backend. Why will the apply fail?

a)

Terraform needs you to format your code according to best practices first

b)

Terraform needs to install the necessary plugins first

c)

The Terraform CLI needs you to log into Terraform cloud first

d)

Terraform requires you to manually run terraform plan first

29.

Your team is collaborating on a Terraform project, and you're concerned about potential conflicts when multiple team members try to apply changes simultaneously. Which feature of Terraform helps prevent such conflicts?

a)

State management

b)

Locking

c)

State commands

d)

Terraform Cloud

30.

You want to inspect the details of resources managed by Terraform within your project. Which Terraform command should you use?

a)

terraform plan

b)

terraform apply

c)

terraform show

d)

terraform state list

31.

You want to list all resources tracked by Terraform within your project. Which Terraform command would provide you with this information?

a)

terraform state list

b)

terraform state show

c)

terraform state pull

d)

terraform state refresh

32.

In your Terraform project, you have accidentally deleted an EC2 resource outside of Terraform, and now you need to remove it from Terraform's state file to avoid conflicts. Which Terraform command should you use to remove the resource from the state file?

a)

terraform state remove aws_instance.example

b)

terraform state rm aws_instance.example

c)

terraform state delete aws_instance.example

d)

terraform state clean aws_instance.example

33.

Where in your Terraform configuration do you specify a state backend?

a)

The terraform block

b)

The resource block

c)

The provider block

d)

The datasource block

34.

You suspect there might be issues with your current state file and want to manually inspect its contents. Which command would you use to download and view the state file in JSON format?

a)

terraform state show

b)

terraform state pull

c)

terraform plan

d)

terraform state list

35.

You need to inspect the details of a specific resource within your state file to verify its attributes. Which command should you use?

a)

terraform state list

b)

terraform state show

c)

terraform plan

d)

terraform state mv

36.

You want to clean up your state file by removing resources that are no longer needed, but you want to confirm the exact resource names first. Which sequence of commands should you use?

a)

terraform plan followed by terraform destroy

b)

terraform state list followed by terraform state rm

c)

terraform state show followed by terraform state rm

d)

terraform apply followed by terraform state rm

37.

What is the default backends used by terraform CLI?

a)

Terraform Cloud

b)

Consul

c)

Remote

d)

Local

38.

What does the default "local" Terraform backend store?

a)
  • tfplan files

b)
  • Terraform binary

c)
  • Provider plugins

d)
  • State file

39.

what contains a terraform state?

a)

The mapping of the resource's configuration

b)

Information of the real infrastructure

c)

Metadata of the resources created

40.

Why is it useful to use remote backends?

a)

To work in a team

b)

for remote operations

c)

for state locking

41.

By default, where does Terraform store its state file?​

a)

remotely using Terraform Cloud​

b)

current working directory​

c)

shared directory​

d)

Amazon S3 bucket​

42.

Which of these provisioners can execute a command on the machine where Terraform is run?

a)

remote-exec

b)

local-exec

c)

script-exec

d)

manual-exec

43.

Which provisioner would you use to transfer files to a remote machine in Terraform?

a)

file

b)

upload-exec

c)

remote-exec

d)

local-exec

44.

What is the key difference between local-exec and remote-exec provisioners in Terraform?

a)

local-exec runs on the target resource, and remote-exec runs on the local machine

b)

local-exec runs on the local machine, and remote-exec runs on the target resource

c)

local-exec runs before resource creation, while remote-exec runs after

d)

There is no difference; both run the same commands

45.

When using the file provisioner in Terraform, which parameter specifies the file to be uploaded?

a)

source

b)

destination

c)

content

d)

remote_path

46.

Which command is used to initialize a backend configuration in Terraform?

a)

terraform init

b)

terraform backend

c)

terraform state

d)

terraform configure

47.

Which connection type is supported by Terraform for connecting to a remote machine for provisioning?

a)

ssh

b)

ftp

c)

http

d)

rdp

48.

Which GCP service is typically used for storing remote state files in Terraform?

a)

Google Cloud Datastore

b)

Google Cloud Storage (GCS)

c)

Google Cloud Bigtable

d)

Google Cloud Functions

49.

Where is the backend block typically located within a Terraform configuration file?

a)

Inside the provider block

b)

At the beginning of the file, outside of any block.

c)

Inside the terraform block.

d)

After the resource definitions

50.

Which of the following actions will NOT trigger a reinitialization of the backend in Terraform?

a)

Changing the backend configuration values

b)

Running terraform plan

c)

Running terraform init -reconfigure

d)

Switching from a local backend to a remote backend

51.

Rahul is working on a project that requires him to create a Virtual Private Cloud (VPC) for his application. He has a module locally located at ./modules/vpc which creates a VPC. How would he correctly use this module in his Terraform configuration?

a)

module "vpc" {

source = "./modules/vpc"

cidr_block = "10.0.0.0/16"

}

b)

module "vpc" {

source = "github.com/modules/vpc"

cidr_block = "10.0.0.0/16"

}

c)

module "vpc" {

path = "./modules/vpc"

cidr_block = "10.0.0.0/16"

}

d)

module "vpc" {

directory = "./modules/vpc"

cidr_block = "10.0.0.0/16"

}

52.

Aarush is trying to find where published modules can be located for his project.

a)

  • In the root module locally

b)

  • Only on local filesystems

c)

  • Inside the Terraform state file

d)

On Public, Private Repositories

53.

What is a child module in Terraform?

a)
  • The top-level module that Terraform starts with

b)
  • A module that is only used for testing purposes

c)
  • A module that contains the Terraform state file

d)

A module that is called from within a root module

54.

Aarav is learning about Terraform for his cloud infrastructure project. What is a Terraform Module?

a)

A Terraform module is a set of Terraform configuration files in a single directory.

b)

A set of configuration files that define the infrastructure

c)

A method to organize Terraform configurations for reusability

d)

All of the above

55.

Aarav is working on a Terraform module for his project. Which of the following parameters is essential to include in a Terraform module's when publishing it?

a)

input variables

b)

output variables

c)

Module Description

d)

Access Keys

56.

What is the primary reason for publishing a module to the Terraform Registry?

a)

  • To hide the module's source code

b)

To make the module available for other Terraform users, like Sneha and Asher, to use and collaborate on

c)

  • To prevent any modifications to the module

d)

To increase the complexity of the module

57.

Aarav is working on a project that requires him to reference resources defined within a local module. How does he do this?

a)

  • By using the module block and specifying the module's path

b)

  • By importing the resources into the root module using the import command

c)

  • By defining global variables that reference the local module's resources

d)

  • By directly accessing the resources within the module's configuration files

58.

Sanya is trying to understand the different source types for calling modules in her project.

a)

Local Paths

b)

Github

c)

Terraform Registry

d)

All of the above

59.

Ishika is trying to understand what the required argument for the module is in her programming assignment.

(a)  

60.

Akhil is working on a Terraform project and needs to manage his workspaces. What command should he run to display all workspaces for the current configuration?

a)

terraform workspace

b)

terraform workspace show

c)

terraform workspace list

d)

terraform show workspace

61.

Aarush is working on a project using Terraform. What is a Terraform workspace used for?

a)

To execute Terraform functions

b)

To manage separate state files for different environments.

c)

To define variable values.

d)

To execute Terraform commands

62.

Aanya is managing infrastructure for a software development company with separate environments for development, staging, and production. Each environment requires its own set of infrastructure resources. She decides to use Terraform workspaces to manage these environments efficiently.
Given the scenario described above, which Terraform workspace command should Aanya use to create a new workspace named "staging" to manage infrastructure resources specific to the staging environment?

a)

terraform workspace new staging

b)

terraform workspace create staging

c)

terraform workspace switch staging

d)

terraform workspace add staging

63.

Which Terraform workspace command should Saisha use to switch to the workspace named "project-a" to manage infrastructure resources for the "Project A" team?

a)

terraform workspace switch project-a

b)

terraform workspace select project-a

c)

terraform workspace change project-a

d)

terraform workspace use project-a

64.

What is the correct sequence of actions for Divya to safely delete her workspace in Terraform?

a)

Run terraform workspace delete <workspace-name> directly without any additional steps.

b)

Use terraform destroy to destroy all resources in the workspace, switch to another workspace, and then run terraform workspace delete <workspace-name>.

c)

Switch to another workspace (not the one you want to delete), then run terraform workspace delete <workspace-name>.

d)

Ensure you are in the workspace you want to delete, then run terraform workspace delete <workspace-name>.

65.

Avni is managing her infrastructure using Terraform. She knows that each Terraform CLI Workspace uses its own state file to manage the infrastructure associated with that particular workspace.

a)

False

b)

True

66.

Sneha is learning about Terraform. Where are Terraform Workspace local state files stored?

a)

a directory called terraform.tfstate.d

b)

a temp directory called .tfstate*

c)

a directory called terraform.workspaces.tfstate

d)

a file called terraform.tfstate

67.

Aditi would like to reuse the same Terraform configuration for her development and production environments with a different state file for each. Which command would she use?

a)

terraform import

b)

terraform init

c)

terraform state

d)

terraform workspace

68.

Aanya is using Terraform Cloud for her project. What is the purpose of workspaces in her setup?

a)

  • To manage different versions of the Terraform CLI

b)

  • To segregate infrastructure deployments

c)

  • To store Docker images

d)

  • To monitor network traffic