Terraform Configuration and Usage, Exams of Advanced Education

An overview of terraform, a popular infrastructure as code (iac) tool. Terraform allows users to define and provision cloud infrastructure using a declarative configuration language. Key concepts such as terraform providers, modules, variables, and state management. It also addresses common terraform commands, best practices, and security considerations. The information presented could be useful for university students studying cloud computing, devops, or software engineering, as well as professionals working with terraform in their organizations.

Typology: Exams

2024/2025

Available from 09/17/2024

BEST-TUTOR.
BEST-TUTOR. 🇺🇸

3.5

(17)

12K documents

1 / 45

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Terraform Associate Exam Questions and Answers 2024
The terraform.tfstate file alwaysmatchesyour currently built infrastructure.
A.True
B.False
B
Oneremotebackendconfigurationalwaysmaps to a single remoteworkspace.
C.True
D.False
B
How isthe Terraformremotebackenddifferent thanother statebackendssuch as S3,
Consul, etc.?
E.It canexecute Terraformruns on dedicatedinfrastructure on premises or in
TerraformCloud
F. It doesn't showthe output of a terraformapply locally
G.It is only available to paying customers
H.All of theabove
A
What is theworkflow for deploying newinfrastructurewith Terraform?
I.terraformplan to import thecurrent infrastructure tothe statefile, make codechanges,
and terraform apply to updatethe infrastructure.
J.Writea Terraformconfiguration, runterraformshowto viewproposedchanges,
andterraformapplyto create newinfrastructure.
K.terraformimport toimport thecurrent infrastructure to the state file, make code changes,
and terraform apply to updatetheinfrastructure.
L. Writea Terraformconfiguration, runterraforminit, runterraformplan toviewplanned
infrastructure
changes, and terraformapply to create newinfrastructure.
D
Aprovider configuration block is required in every Terraformconfiguration. Example:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d

Partial preview of the text

Download Terraform Configuration and Usage and more Exams Advanced Education in PDF only on Docsity!

Terraform Associate Exam Questions and Answers 2024

The terraform.tfstate file alwaysmatchesyour currently built infrastructure. A.True B.False B Oneremotebackendconfigurationalwaysmaps to a single remoteworkspace. C.True D.False B How isthe Terraformremotebackenddifferent thanother statebackendssuch as S3, Consul, etc.? E. It canexecute Terraformruns on dedicatedinfrastructure on premises or in TerraformCloud F. It doesn't showthe output of a terraformapply locally G.It is only available to paying customers H.All of the above A What is the workflowfor deploying newinfrastructurewith Terraform? I.terraformplan to import thecurrent infrastructure tothe statefile, make codechanges, and terraform apply to updatethe infrastructure. J.Writea Terraformconfiguration, runterraformshowto viewproposedchanges, andterraformapplyto create newinfrastructure. K.terraformimport toimport thecurrent infrastructure to the state file, make code changes, and terraform apply to updatetheinfrastructure. L. Writea Terraformconfiguration, runterraforminit, runterraformplan toviewplanned infrastructure changes, and terraformapply to create newinfrastructure. D Aprovider configuration block is required in every Terraformconfiguration. Example:

pvorider "provider_name" D ... } A.Tru e B.Fals e B( 58 %) - A( 42 %) You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerunthescript. Which of the followingcommandswould you use first? A.terraformtaint null_resource.run_script B.terraformapply -target=null_resource.run_script C.terraformvalidatenull_resource.run_script D.terraformplan -target=null_resource.run_script A Which provisioner invokes a process on the resource created by Terraform? E. remote-exec F. null-exec G.local-exec H.file A Whichof the following is not true of Terraformproviders? I. Providerscan be written by individuals J. Providerscan be maintained by a community of users K. Someprovidersaremaintained by HashiCorp L.Majorcloudvendors and non-cloudvendorscanwrite, maintain, or collaborate on TerraformprovidersE. None of the above E What command does Terraformrequire the first time yourun it within a configuration directory? M.terraformimport N.terraforminit O.terraformplan

If you manually destroy infrastructure, what is thebest practicereflectingthischange in Terraform? A. Run terraformrefresh B.It will happenautomatically C.Manually update thestate fire D.Runterraformimport A What is not processed when running a terraformrefresh? E.State file F. Configuration file G.Credentials H.Cloudprovider B What information doesthe public TerraformModule Registry automatically expose about published modules? I. Required input variables J. Optional inputs variables and default values K.Outputs L.All of the above M.Noneof the above D If a module usesa local values, you can expose that value witha terraformoutput. N.True O.False A You should store secret data in the same version control repository as your Terraformconfiguration. P. True Q.False B Which of thefollowing is not a valid string function in Terraform? R.split S.join

C. slice D. chomp C You have provisioned somevirtual machines(VMs) on Google Cloud Platform(GCP) using the gcloud commandlinetool. However, you arestandardizingwithTerraformandwant tomanage these VMs using Terraforminstead. What arethetwothings you must do to achievethis? (Choosetwo.) A. ProvisionnewVMsusing Terraformwiththesame VMnames B. Usetheterraformimport commandfor the existing VMs C. Write Terraformconfigurationfor theexisting VMs D. Run the terraformimport-gcp command B C You have recently started anewjob at a retailer as an engineer. As part of thisnewrole, you have been tasked withevaluating multipleoutagesthat occurredduringpeak shoppingtime during theholiday season. Your investigationfoundthat theteamis manually deploying newcomputeinstances and configuring each compute instance manually. This has led to inconsistent configuration between each compute instance. How would you solve this using infrastructure as code? A.Implement aticketingworkflowthat makesengineerssubmit aticket beforemanually provisioning and configuring a resource B.Implement a checklist that engineerscanfollowwhen configuring compute instances C.Replace the computeinstance typewitha larger version to reduce thenumber of requireddeployments D.Implement aprovisioningpipelinethat deploysinfrastructureconfigurationscommitted to yourversion control systemfollowing code reviews D terraforminit initializes a sample main.tf file in the current directory. E.True F. False B Whichtwostepsare required to provision newinfrastructure in the Terraformworkflow? (Choosetwo.) G.Destroy H.Apply I. Import J. Init K.Validate

terraformvalidate validates the syntax of Terraformfiles. A.True B.False A You have used Terraformto create an ephemeral development environment in the cloud and are nowready to destroy all theinfrastructuredescribed by your Terraformconfiguration. To be safe, you wouldlike to first see all the infrastructurethat will be deleted by Terraform. Whichcommandshould you use to showall of the resourcesthat will be deleted? (Choosetwo.) C.Run terraformplan - destroy. D.This is not possible. Youcanonly showresourcesthat will be created. C. Runterraformstate rm*. D. Runterraformdestroy and it will first output all theresourcesthat will be deletedbeforepromptingfor approval. A D Which of thefollowing is thecorrect way to pass thevalue in thevariablenum_serversintoamodulewith the input servers? E. servers=num_servers F. servers=variable.num_servers G.servers=var(num_servers) H.servers=var.num_servers D ATerraformprovisioner must be nested inside a resource configuration block. I. True J. False A (B - 35 %) Terraformcanrun on Windows or Linux, but it requiresa Server version of the Windowsoperating system. K.True L. False B What does the default "local" Terraformbackend store? A. tfplan files

B.Terraformbinary C.Providerplugins D.Statefile D Youhavemultipleteammemberscollaborating on infrastructure as code(IaC) using Terraform, and want to apply formatting standards for readability. How can you format Terraform HCL(HashiCorp Configuration Language) code according to standard Terraformstyle convention? E. Run theterraformfmt command during the code linting phase of your CI/CDprocess F. Designate oneperson in each teamtoreview and format everyone'scode G.Manually apply two spacesindentation and alignequal sign "=" characters in every Terraformfile(.tf) H.Writeashell script totransformTerraformfiles using toolssuch as AWK, Python, and sed A What valuedoesthe TerraformCloud/TerraformEnterpriseprivatemoduleregistryprovideoverthepublic Terraform Module Registry? I.The ability to share moduleswithpublic Terraformusers and members of TerraformEnterprise Organizations J. The ability totag modules by version or release K. The ability to restrict modules to membersof TerraformCloud or Enterprise organizations L. Theability toshare modulespubliclywith any user of Terraform C Whichtask doesterraforminit not perform? M.Sourcesall providerspresent in theconfiguration and ensuresthey are downloaded and availablelocally N.Connects to the backend O.Sources any modules and copiestheconfigurationlocally P. Validates all required variables are present D Youhave declaredavariable calledvar.list which is alist of objectsthat all have an attribute id. Which optionswill produce a list of the IDs? (Choose two.) Q.D for o in var.list : o => o.id } R.var.list[].id S.[ var.list[*].id ] T. [ for o in var.list : o.id ]

Whichoption cannot be used to keep secretsout of Terraformconfiguration files? A.ATerraformprovider B.Environment variables C.A -var flag D.securestring D What is one disadvantage of using dynamic blocks in Terraform? E.They cannot be used to loop through a list of values F. Dynamic blocks can construct repeatable nested blocks G.They make configuration harder to read and understand H.Terraformwill run more slowly C Only theuserthat generatedaplan may applyit. I. True J. False B Examine the following Terraformconfiguration, whichusesthedata source for an AWSAMI. What value should you enter for the ami argument in the AWSinstance resource? data "aws_ami" "ubuntu" D ... } resource "aws_instance" "web" D ami = instance_type = "t 2 .micro" tags = D Name="HelloWorld" } } K.aws_ami.ubuntu L.data.aws_ami.ubuntu

C. data.aws_ami.ubuntu.id D. aws_ami.ubuntu.id C FILLBLANK- Youneed to specify a dependency manually. What resource meta- parameter can you use to make sure Terraformrespectsthedependency? Typeyour answer in thefieldprovided. Thetext field is not case-sensitive and all variations of the correct answer are accepted. depends_on You have never used Terraformbefore and would like totest it out using a sharedteamaccount for a cloud provider. The sharedteamaccount already contains 15 virtual machines(VM). You develop a Terraform configuration containing one VM, performterraformapply, and see that your VMwas created successfully. What should you do to delete the newly-created VMwith Terraform? A.The Terraformstatefilecontainsall 16 VMsin theteamaccount. Executeterraformdestroy and select the newly-created VM. B.The Terraformstate file only containsthe onenew VM. Execute terraformdestroy. C.Delete the Terraformstate file and execute Terraformapply. D.Deletethe VMusing the cloud provider console and terraformapply to apply the changes to the Terraform state file. B What is thenameassigned by Terraformto referencethisresource? resource "azurerm_resource_ group" "dev" D name = "test" location ="wes tus" } E.dev F. azurerm_reso urce_group G.azurerm H.test A Settingthe TF_LOGenviron ment variable to DEBUGcausesd ebugmessages to be

B. Howeverlong it takestheresourceprovider to fulfill therequest C. Afterupdatingthestatefile D. Based on thevalueprovided tothe - refreshcommandlineargument E. None of the above B Howwould you referencethe"name" value of thesecondinstance of thisfictitiousresource? resource"aws_instance" "web" D count = 2 name = "terraform- $Dcount.index}" } A. element(aws_instance.we b, 2 ) B. aws_instance.web[ 1 ].nam e C. aws_instance.web[ 1 ] D. aws_instance.web[2].name E. aws_instance.web.*.name B A Terraformprovider is not responsible for: A. Understanding API interactions with some service B.Provisioning infrastructu re in multiple clouds C.Exposing resources and data sources based on an API D.Managing actions to takebased on resource differences B Terraformprovisioners can be added to any resource block. E.True F. False A( 53 %) - B( 47 %)

FILLBLANK-

Which flag would you add to terraformplan to save the execution plan to a file? Typeyour answer in the field provided. Thetext field is not case-sensitive and all variations of thecorrect answerareaccepted.

out=FILENA ME FILL BLANK - What is thename of thedefault filewhere Terraformsto resthestate? Typeyour answer in thefield provided. Thetext field is not case- sensitive and all variations of thecorrect answer areaccepted Terraform.tfs tate ATerraforml ocal value can ref erence othe r Terraformlo cal values. A.True B.False A Which of the following is not a valid Terraformc ollection type?

B.Store the state in an encrypted backend C.Edit your statefile toscrub out thesensitivedata D.Alwaysstore your secrets in a secrets.tfvarsfile. B In contrast to TerraformOpen Source, whenworkingwith TerraformEnterprise and Cloud Workspaces, conceptually you couldthinkabout themas completely separateworkingdirectories. E.True F. False A You want to know fromwhich paths Terraform is loading providers referenced in your Terraform configuration (*.tf files). Youneed to enable debug messages to find thisout. Which of the following would achieve this? G.Set theenvironment variable TF_LOG=TRACE H.Set verbose loggingfor each provider in your Terraformconfiguration I. Set theenvironment variable TF_VAR_log=TRACE J. Set theenvironment variable TF_LOG_PATH A How is terraformimport run? K. As a part of terraforminit L. As a part of terraformplan M.As a part of terraformrefresh D. By an explicit call E. All of theabove D Youhaveasimple Terraformconfigurationcontainingonevirtual machine(VM) in acloudprovider. Yourun terraformapply and the VMis created successfully. What will happen if you deletethe VMusing the cloud provider console, and run terraformapply againwithout changing any Terraformcode? N.Terraformwill remove the VMfromstate file O.Terraformwill report an error C. Terraformwill not make any changes D. Terraformwill recreate the VM D Which of these options is the most secure place to storesecrets foeconnecting to a Terraformremote backend?

A.Defined in Environment variables B.Inside the backendblock within the Terraformconfiguration C.Defined in aconnectionconfigurationoutside of Terraform D.Noneof above A Your DevOpsteamis currently using thelocal backend for your Terraformconfiguration. Youwould like to move to aremotebackend to beginstoringthestatefile in acentral location. Which of thefollowing backends would not work? E. Amazon S F. Artifactory G.Git H.TerraformCloud C Whichbackenddoesthe TerraformCLI use by default? I. TerraformCloud J. Consul K.Remote L. Local D Whenyou initialize Terraform, wheredoes it cache modulesfromthepublic TerraformModule Registry? A. On disk in the /tmp directory B. In memory C. On disk in the.terraformsub-directory D. They arenot cached C Youwritea newTerraformconfiguration and immediately runterraformapply in the CLI using thelocal backend. Why will the apply fail? M.Terraformneeds you to format your code according to best practices first N.Terraformneeds to install the necessary plugins first O.The TerraformCLI needsyou to log into Terraformcloud first D. Terraformrequires you to manually run terraform plan first B

D

You just scaled your VM infrastructure and realized you set the count variable to the wrong value. You correct the value and save your change. What do you do next to make your infrastructure match your configuration? A.Run an apply and confirmthe planned changes B.Inspect your Terraformstatebecause you want tochange it C. Reinitializebecauseyour configuration has changed D. Inspect all Terraformoutputs to make sure they are correct A Terraformprovisioners that require authentication can use the block. C.connection D.credentials E.secrets F. ssh A Terraformvalidate reportssyntax check errorsfromwhich of the following scenarios? G.Code contains tabsindentation instead of spaces H.There is missing value for a variable I. Thestatefilesdoesnot matchthecurrent infrastructure J. None of the above B Which of thefollowing is allowed as a Terraformvariablename? K.count L.name M.source N.version B What type of block is used to construct a collection of nested configuration blocks? O.for_each P. repeated

C. nesting D. dynamic D Module variable assignments are inherited fromthe parent module and do not need to be explicitly set. A.True B.False B If writing Terraformcodethat adherestothe Terraformstyleconventions, howwould you properly indent each nesting level compared to the one above it? C.Withfourspaces D.Withatab E.Withthreespaces F. Withtwospaces D Which of the following is not an action performed by terraforminit? G.Create a sample main.tf file H.Initialize a configured backend I. Retrieve the source code for all referenced modules J. Loadrequiredproviderplugins A HashiCorp Configuration Language (HCL) supportsuser-definedfunctions. K.True L. False B Howcan you trigger arun in a TerraformCloudworkspacethat is connected toa Version Control System (VCS) repository? M.Only TerraformCloud organization ownerscan set workspacevariables on VCS connectedworkspaces N.Commit a change to the VCSworkingdirectory and branch that the TerraformCloud workspace is connected to O.Only members of a VCSorganization canopenapull request against repositoriesthat areconnected to