Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Terraform associate questions with correct answers
Typology: Exams
1 / 19
Which Terraform files should be ignored by Git when committing code to a repo? CORRECT ANSWER terraform.tfstate - tf state of a specific env terraform.tfvars - password, ip addresses, sensitive data What are the features of Terraform state? CORRECT ANSWER Mapping to real world - Metadata - Including dependency order Performance - cache of the attribute values for all resources in the state, performance improvement Syncing - remote state to prevent stepping on each others toes What structure do you use to iterate through a list of things like ip addresses, ports, etc. CORRECT ANSWER A dynamic block in TFE a workspace is mapped to how many VCS repos? CORRECT ANSWER 1 What is a VCS repo? CORRECT ANSWER Version Control System How many workspaces can be mapped to 1 VCS repo? CORRECT ANSWER Many Before you can run terraform import to start managing new resources, what should you do? CORRECT ANSWER update configuration files to include the new resource
What are ways that you can avoid putting sensitive fields in remote repos? CORRECT ANSWER 1. Use command line key value pairs
In the output of a terraform apply, what signifies a destroy? CORRECT ANSWER
In the output of a terraform apply, what signifies a create in place? CORRECT ANSWER + What connection types are supported by remote-exec? CORRECT ANSWER winrm ssh What are the 3 types of resource blocks in Terraform? CORRECT ANSWER resource, data and modules If you are sourcing your module, what is the correct syntax from a hashicorp module named consul, with an AWS provider CORRECT ANSWER source = "hashicorp/consul/aws" What does a terraform init do? CORRECT ANSWER Copy Source Modules Backend initialization Child Module Installation Plugin Installation (providers) what is the command on tf open source to creating a workspace named personal CORRECT ANSWER terraform workspace new personal What is included in a standard backend? CORRECT ANSWER Standard: State management, functionality covered in State Storage & Locking
What is included in an enhanced backend? CORRECT ANSWER Enhanced: Everything in standard plus remote operations. State management, state storage and locking. What are the two types of standard back ends? CORRECT ANSWER local and remote What are three three common examples of standard backends? CORRECT ANSWER TFE, artafactory, s When setting provider versions what does the "~>" operator mean? CORRECT ANSWER Use the (~>) pessimistic constraint operator. For better understanding use this example Minor and patch updates only ~> 0.9 is equivalent to >= 0.9, < 1.0 Patch updates only ~> 0.8.4, is equivalent to >= 0.8.4, < 0. What is the default logging level in Terraform? CORRECT ANSWER debug=TRACE Does terraform refresh modify the statefile? CORRECT ANSWER Yes If you use Terraform andVault together where are the secrets no longer kept? CORRECT ANSWER plan files If you use Terraform and Vault together where are secrets still kept? CORRECT ANSWER state files
What does terraform do when it expects a string but gets a number (like 42)? CORRECT ANSWER It will cast it according to what is expects. What do you add to terraform fmt to make sure you get sub directories? CORRECT ANSWER terraform fmt -recursive Break this down: module.sound.scientific_name CORRECT ANSWER module is what it says sound is the module name scientific_name is an object What does terraform refresh need to do it's job? CORRECT ANSWER state file config file providers You now that instance "i-abc1234" exists, and want to add it to your state-file. What is the command for that? CORRECT ANSWER terraform import aws_instance.foo i-abcd When you run terraform taint what happens? CORRECT ANSWER he command will modify the state file in order to mark a resource. Once a resource is marked, the next plan will show that the resource will be destroyed and recreated and the next apply will implement this change. how is lookup used? CORRECT ANSWER lookup(map, key, default)
Is there a way to not refresh the state with terraform plan? CORRECT ANSWER - refresh=false What is the command to switch to a workspace called "personal". CORRECT ANSWER terraform workspace select personal What is the installation called when it needs to not be connected to the internet. CORRECT ANSWER air-gapped What does terraform state list do? CORRECT ANSWER lists the resources in terraform statefile. What the the resource in resource "aws_instance" "my_insta" CORRECT ANSWER
For a workspace where is the "local state" stored? CORRECT ANSWER terraform.tfstate.d What type of function is "tostring"? CORRECT ANSWER type conversion function What language is terraform config generally written in? CORRECT ANSWER json hcl what directory are plugins downloaded to? CORRECT ANSWER .terraform/plugins What does Hashicorp recommended for spaces? CORRECT ANSWER 2 What type of backend database does TFE require for a clustered deplyment? CORRECT ANSWER PostgreSQL If you use terraform and Vault do you gain any extra ability to masks secrets in the terraform plan? CORRECT ANSWER No What is the environment variable needed to change the log level? CORRECT ANSWER TF_LOG Can a terraform init automatically download community plugins? CORRECT ANSWER Yes
Be default how many resources can terraform provision concurrentlly? CORRECT ANSWER 10 Your state has an output of "dino", what command can display the value? CORRECT ANSWER terraform output dino What will occur when a resource is successfully created but failed during provisioning? CORRECT ANSWER Terraform will have an error message mark the resource as tainted by modifying the state If has failure behavior will continue, otherwise exits. What is the bare minimum needed for a project to be a module? CORRECT ANSWER A .tf file. what is the core workflow for terraform? CORRECT ANSWER Write -> Plan -> Apply What is the missing part? resource "some_aws_resource" "test" { name = "tf-test-name" ... dynamic "setting" { for_each = var.settings content {
name = ____.value["name"] value = ____.value["value"] } } } CORRECT ANSWER each How do you use the current workspace name in a config file? locals { machine_name = "${______}_machine" } CORRECT ANSWER ${terraform.workspace}.machine Given that the foo object was ONLY defined with an "id" attribute, what happens to the "name" attribute? Will this value be correct? // terraform.tfvars foo = { id = "Ladmo" name = "not Wallace" } CORRECT ANSWER It is discarded during type conversion and will not cause an error. Fill in the missing command: resource "azurerm_resource_group" "rg" {
for_each = { first_key = "kara-tur" second_key = "oearth" } name = _____.key location = _____.value } CORRECT ANSWER each Terraform cloud uses what protocol to authenticate VCS providers? CORRECT ANSWER Oauth What would be the result of the function below? zipmap(["labrador", "poodle", "labrador"], [1, 2, 3]) CORRECT ANSWER {"labrador"=3,"poodle"=2} What is the output of this? variable "mylist" { type = list(any) default = ["x", "", null] } concat(my_list, ["y", "z"]) CORRECT ANSWER ["x", "", null,"y","z"] What happens if you set TF_LOG=BOB? CORRECT ANSWER It will enable logging as an unknown logging level will default to TRACE https://www.terraform.io/docs/internals/debugging.html
What file does the command "terraform workspace show" reference? CORRECT ANSWER .terraform/enviornment When using a local backend, where will Terraform create a directory and store workspaces? CORRECT ANSWER terraform.tfstate.d/workspacename What is the format for Terraform env variables? CORRECT ANSWER TF_VAR_name What are the requirements needed for publishing a public module? CORRECT ANSWER Public Github repo Name formatted: terraform-
how do you create a plan for a single resource? CORRECT ANSWER terraform plan -target="resourceName" uses the same provider. Given that provider plugins are really large, they are having a hard time downloading it when running terraform init in different places. What can you add to your environment variable or your .terraformrc file for caching behavior to be enabled when downloading plugins? CORRECT ANSWER plugin_cache_dir = "$HOME/.terraform.d/plugin-cache" export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache" What are the advantages that Terraform offers? CORRECT ANSWER Terraform just uses the cloud provider's own API under the hood. Terraform's advantages are:
locals What order are terraform variables initialized in? CORRECT ANSWER ETJ-AT- AJ-CL Environment variables The terraform.tfvars file, if present. The terraform.tfvars.json file, if present. Any *.auto.tfvars or *.auto.tfvars.json files, processed in lexical order of their filenames. Any -var and -var-file options on the command line, in the order they are provided. What is the precedence when variables are initialized in multiple places? CORRECT ANSWER CL-AJ-AT-JTE What are the two interactive ways of install terraform enterprise? CORRECT ANSWER air-gapped online What command can you use to inspect the Terraform State? CORRECT ANSWER Terraform show If resources are currently being managed what can you migrate to change a backend? CORRECT ANSWER terraform state file What are the benefits of IaS? CORRECT ANSWER Automation of infra Reusability of the code - can use in diff envs
Versioning - VC, uses VC tools and processes (ARVer) Name a feature not available on Terraform Cloud. CORRECT ANSWER Roles and Team management if you want to run terraform plan without refreshing the state what flag should you send it? What other advantage does it offer? CORRECT ANSWER --refesh=false Redices API clls What does terraform refresh need to execute successfully? CORRECT ANSWER Providers Statefile Configuration Can third party plugins be installed through terraform init? CORRECT ANSWER They cannot be installed with terraform init. Where can you install third party plugins? CORRECT ANSWER ~/.terraform.d/plugins on other systems. Why would this result in an error?
variable "example" { type = list(string) default = {} } CORRECT ANSWER lists should be defined with [] NOT {} Which of these are supported backend types: consul s gcs pg github tfe CORRECT ANSWER s gcs pg tfe Which of these are supported backend types: consul artifactory http bitbucket manta tfe CORRECT ANSWER consul artifactory http
manta tfe What does it mean if terraform is declarative? CORRECT ANSWER It is describing an intended goal rather than the steps to reach that goal. What is the difference between terraform and a configuration management tool (CMT)? CORRECT ANSWER CMT installs and manages software on a machine that already exists. Terraform provisions and creates infrastructure. Does the existence of a provider plugin found locally in the working directory create a provider dependency? CORRECT ANSWER Just being installed locally does not create a dependency. If you use a resource belonging to a particular provider in a resource or data block create a dependency? CORRECT ANSWER No, just using as data or resource does not create a dependency. What command launches an interactive commandline? CORRECT ANSWER Terraform console what syntax des Terraform support for comments? CORRECT ANSWER //
/* and */ What is kept in ~/.terraform.d/? CORRECT ANSWER credentials
plugin cache third party plugins What env variable will let you persist the logs? CORRECT ANSWER TF_LOG_PATH You want to upgrade the provider version to the latest acceptable one. What is the approach to do it? CORRECT ANSWER terraform init -upgrade Should a public module always be public and open-source to be able to be used? CORRECT ANSWER No, does not have to be open source. If resources are deleted manually but were created through terraform, what will happen if terraform apply? CORRECT ANSWER They will be created again. Can a child module can access all the variables of the parent module? CORRECT ANSWER No, a parent can access child module variables. Can a parent module can access all the variables of the child module? CORRECT ANSWER Yes, a parent can access the child module variables. Can a parent module override values in child module? CORRECT ANSWER A parent cannot override values in child module. Is it mandatory to provide a module version while pulling code from Terraform Registry? CORRECT ANSWER No, it is mandatory for a plugin.
Is it necessary to have a state file for the terraform functions to work? CORRECT ANSWER Yes, a state is necessary What is a TF config with some or few arguments called? CORRECT ANSWER A partial config Which backend providers do not support state locking? CORRECT ANSWER artifactory etcd tfe (atlas) What does TF run on? CORRECT ANSWER MacOS FreeBSD OpenBSD Solaris Linux Windows What 4 commands refersh terraform state CORRECT ANSWER plan apply init refresh What does terraform plan --destroy do? CORRECT ANSWER previews terraform destroy
what does terraform state pull do? CORRECT ANSWER manually download state to local What is the arguement sent to terraform apply to specify a variable file? CORRECT ANSWER --var-file="name.tfvars" What is the name format for private registry modules? CORRECT ANSWER hostname/namespace/name/provider besides the name, what else is required for private registry modules? CORRECT ANSWER a version What is the keyword top use to control what happens during failure? CORRECT ANSWER on_failure For on_failure what are the two values? CORRECT ANSWER continue fail