Showing posts with label Terraform. Show all posts
Showing posts with label Terraform. Show all posts

Saturday, March 29, 2025

Terraform Commands

Workspace commands

terraform workspace new myworkspace



terraform workspace select default




terraform workspace delete default



terraform workspace delete myworkspace



Terraform Quiz : Question and Answers

 1) Format to define address in terraform is ________.

        a. Both “[10.0.0.0/16]” and [“10.0.0.0/16”] are valid

        b. “[10.0.0.0/16]”

        c. [“10.0.0.0/16”]

        

2)  A set of files which describe the infrastructure in terraform is called as __________.

        a. Terraform files

        b. Terraform description files

        c. Terraform details

        d. Terraform configuration


3)  Which of the following is the correct format to define type and name of resource of virtual network

        a. resource “azurerm_virtual_network”“vnet”

        b. resource "azurerm_virtual_network""vnet" & resource "azurerm_virtual_network" "vnet" are correct

        c. resource “azurerm_virtual_network” ”vnet”


4)  HCL Stands for?

        a. Hashicorp Connection Language

        b. Hashicorp Configuration Language

        c. Harshicorp Common Language


5)  Which is the command to initialize the plugins in terraform?

        a. terraform init

        b. terraform run

        c. terraform begin

        d. Terraform configuration


6) Terraform is an infrastructure provisioning tool.

        a. True

        b. False


7)  IaC is frequently referred as ____________.

        a. Normal code

        b. Programmable code 

        c. Programmable Infrastructure

        d. Normal Infrastructure


8)  What is the command to create a storage account of the name mystorageacct in Terraform?

        a. resource “azurerm_storage_account” “mystorageacct”

        b. resource “azure_Storage_account” “mystorageacct” 

        c. resource “azurerm_storage_acct””mystorageacct” and resource “azurerm_storage_acct” “mystorageacct” are correct

        d. resource “azurerm_storage_account””mystorageacct”


9)  Which of the following command helps in aligning the format of Terraform?

        a. terraform format

        b. terraform fmt

        c. terraform allign


10)  Which of the following parameter can be used to make the label sensitive?

        a. sensitive

        b. hide

        c. confidential

        d. optional


11)  Which of the following parameter can be used to make the label sensitive?

        a. CLI Flags DRY

        b. Remote state configurations DRY

        c. Keep terraform code DRY

        d. All the options


12)  Local values are defined in __________ blocks.

        a. local

        b. function

        c. main


13) Which of the following parameters are needed to create a backend for AWS using S3?

        a. bucket and key

        b. bucket, key and region

        c. bucket and region


14) Terraform Module registry makes the work easy to deal with ___________.

        a. modules

        b. Modues

        c.Modular Variables

        d. All the options


15) Which of the following option is used to combine two or more lists?

        a. concat

        b. combine

        c. merge


16) Terraform supports which of the cloud providers?

        a. Azure and AWS

        b. Azure 

        c.AWS

        d. Alicloud

        e. All the options


17) Which of the following feature is true about Terragrunt?

        a. It provides locking mechanism

        b. It redirects to the Terraform original commands

        c. It allows you to use remote state

        d. All the options


18) Which of the following syntax is used to assign a variable?

        a. terraform apply -var='name=test'

        b. terraform apply -var =name =test

        c. terraform apply -var="name =test"

        d. Both terraform apply -var="name =test" and terraform apply -var='name=test' are correct


19) Once the terraform apply is completed, the state file will go to ___________ state .

        a. Cannot be predicted

        b. locked

        c. unlocked

       

20) Which of the following function returns lexically sorted list of map keys?

        a. string(map)

        b. list(map)

        c. keys(map)


21) Current workspace is denoted by using ______________.

        a. $

        b. _

        c.-

        d. *


22) Which of the following option is used to configure the lock in AWS using terragrunt?

        a. DynamoDB

        b. VPC

        c. DB


23) Which of the following command is used to move the workspace with name stage?

        a. terraform workspace select stage

        b. terraform workspace choose stage

        c. terraform workspace switch stage

     

24) Which command should be run after deleting the backend?

        a. terraform taint

        b. terraform untaint

        c. terraform fmt

        d.  terraform init


25) Which type of resource is used to create storage account in Azure?

        a. azure_storage_account

        b. azurerm_storage_account

        c. azure_storage_accounts


26) Which of the following option is not a built-in function supported by Terraform?

        a. abs(float)

        b. compact(list)

        c. chomp(string)

        d. contains(map,element)


27) Interpolation syntax can be used to configure backends.

        a. False

        b. True

  

28) Which of the following command is used to list the workspaces?

        a. terraform workspace show

        b. terrform workspace details

        c. terrform workspace list

        d. terrform workspace view


29) Terraform manages the multiple clouds by using _____________.

        a. Specified Databases

        b. API Calls

        c. Storage accounts

        

30) Terragrunt helps in configuring the remote backend.

        a. True

        b. False


31) For AWS, the backend is ______________.

        a. VPC

        b. S3

        c. All the above


32) Backend supports which of the following features?

        a. State locking and consistency checking

        b. State locking 

        c. consistency checking


33) You can get the secondary access key from storage account by using which of the following command?

  a. azurerm_storage.storageaccount.secondary_access_key                          b. azurerm_storage_account.storageaccount.secondary_access_key

  c. azurerm_storage_account.storageaccount.secondary_key

  d. azurerm_storage.storageccount.secondary_key


34) Which of the following option is the configuration syntax for creating s3 bucket?

        a. aws_s3_bucket

        b. aws_bucket_s3

        c. aws_bucket

       

35) Terragrunt files are saved by using ______________.

        a. .terragrunt

        b. .terragruntfiles

        c. .terragrunt.tf

 

36) Which of the following syntax is used to define lookup?

        a. lookup(map,[default])

        b. lookup(map,key, [default])

        c. lookup(key,map,[default])

        d. None of the options


37) In Terraform, you can mask the value by using _______________ parameter.

        a. hide

        b. sensitive

        c. mask


38) Azure uses which of the following option to store its state file?

        a. Virtual machine

        b. Storage Account

        c. All the above


39) Terraform cannot perform which of the following actions?

        a. Plan

        b. Apply

        c. auto-intialise

        d. none of the options


40) What is the command to create a workspace in Terraform?

        a. terraform workspace prod

        b. terraform workspace new prod

        c. terraform prod workspace

        d. terraform workspace prod new


41) What is the resource type in Azure to create a storage container?

        a. azure_container

        b. azurerm_storage_container

        c. azure_storage_container

        d. azurerm_container


42) Which of the following workspaces cannot be removed?

        a. Prod

        b. Dev

        c. Test

        d. *default


43) Terraform supports which of the cloud providers?

        a. Azure and AWS

        b. Azure 

        c. AWS

        d. Alicloud