Font size
WorksheetsTerraform Day 2 Accenture
Total questions: 27
Worksheet time: 9mins
Which command initializes the terraform configuration?
terraform start
terraform init
terraform fmt
terraform apply
What does the terraform plan command do?
Applies the changes required to reach the desired state of the configuration
Shows the execution plan for the changes required to reach the desired state
Initializes the configuration
Deletes the resources defined in the configuration
When checking the syntax of Terraform configuration files, which command ought to be executed?
terraform check
terraform validate
terraform plan
terraform fmt
What happens when you apply Terraform configuration? Choose TWO correct answers.
Terraform makes any infrastructure changes that are defined in your configuration.
Terraform gets the plugins that the configuration requires.
Terraform updates the state file with the configuration changes it made.
Terraform will destroy and recreate all your infrastructure from scratch.
What is the workflow for deploying new infrastructure when using Terraform?
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.
Write the Terraform configuration, run the terraform show command to view proposed changes, and run terraform apply to create the new infrastructure.
Terraform import is used to import the current infrastructure to the state file, make code changes, and apply terraform to update the infrastructure.
Write a Terraform configuration, run Terraform init, run Terraform plan to view planned infrastructure changes, and terraform apply to create new infrastructure.
How do you specify a provider in a Terraform configuration file?
provider "name" { }
module "name" { }
resource "name" { }
data "name" { }
What is the default file name where Terraform stores its state locally?
state.tf
terraform.state
terraform.tfstate
terraform.tf.state
Does running 'terraform init' automatically initialize a file named 'main.tf'
Yes
No
In the context of Terraform, what does "Desired State Management" refer to?
The current configuration of the infrastructure
The configuration that should be applied to the infrastructure
The historical state of the infrastructure
The default settings of the infrastructure
If we need to destroy the Terraform-managed infrastructure using terraform destroy command without confirmation which option should we use?
-auto-noapprove
-auto-proceed
-auto-destroy
-auto-approve
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?
terraform code format
terraform format
terraform fmt
none of the given
Code in the Terraform language is stored in files with the ........... file extension
.tf
.yml
.sh
.terra
Terraform commands order ………….
terraform init,terraform plan,terraform apply,terraform destroy
terraform init,terraform apply,terraform plan,terraform destroy
terraform plan,terraform init,terraform apply,terraform destroy
terraform apply,terraform plan,terraform init,terraform destroy
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?
terraform plan out <filename>
terraform output plan <filename>
terraform plan -out=<filename>
terraform plan <filename>
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?
list
set
object
map
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?
output "privateip"
{
value = aws_instance.example.private_ip
}
input "privateip"
{
value = aws_instance.example.private_ip
}
data "privateip"
{
value = aws_instance.example.private_ip
}
output "privateip"
{
value = example.private_ip
}
What is the purpose of the "terraform.tfvars" file?
To define variables that are specific to a particular environment
To define variables that are automatically loaded by Terraform
To manage state
To define providers
Your Terraform configuration deployed a web application, including an AWS EC2 instance. Now, you require the public IP address of the instance.
Execute terraform show and search for the public IP address in the output.
Use the AWS Management Console to locate the public IP address.
Check the terraform.tfstate file for the public IP address.
Run terraform output and specify the name of the output variable containing the public IP address.
What is the main purpose of using locals in Terraform?
To define resources that are only available within the local network and not accessible from the internet.
To define reusable values or expressions that can be referenced within the Terraform configuration.
To create remote connections to other Terraform configurations or infrastructure deployments.
To manage the state of Terraform resources and track changes over time.
Which block is used to define local values in Terraform?
(a)
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?
get()
lookup()
find()
search()
Which Terraform function is used to retrieve a specific element from a list?
lookup()
fetch()
search()
element()
Can we create a function and use it in our terraform configuration?
No
Yes
Which data structure in Terraform is used to store unique values without any specific order?
list
set
map
tuple
Which of the following best describes a Terraform data source?
A plugin to extend Terraform's functionality.
A mechanism to retrieve information from external systems for use in your configuration.
A module to provision infrastructure resources.
A backend storage for Terraform state files.
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?
By storing state files remotely.
By defining output variables.
By using version control for configuration files.
By using data sources
Usernames and passwords referenced in the Terraform code, even as variables, will end up in plain text in the state file.
True
False
