Terraform all

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What does terraform destroy do? • A. Destroy all infrastructure in the Terraform state file • B. Destroy all Terraform code files in the current directory while leaving the state file intact • C. Destroy all infrastructure in the configured Terraform provider • D. Destroy the Terraform state file while leaving infrastructure intact

A. Destroy all infrastructure in the Terraform state file

When using a module from the public Terraform Module Registry, the following parameters are required attributes in the module block. (Choose two.) • A. Each of the module's required inputs • B. The module's source address • C. Terraform Module Registry account token • D. Each of the module's dependencies (example: submodules) • E. The version of the module

A. Each of the module's required inputs AND B. The module's source address

Terraform variables and outputs that set the "description" argument will store that description in the state file. • A. True • B. False

B. False

Variables declared within a module are accessible outside of the module. • A. True • B. False

B. False

You can reference a resource created with for_each using a Splat (*) expression. • A. True • B. False

B. False

You cannot install third party plugins using terraform init. • A. True • B. False

B. False

You have modified your local Terraform configuration and ran terraform plan to review the changes. Simultaneously, your teammate manually modified the infrastructure component you are working on. Since you already ran terraform plan locally, the execution plan for terraform apply will be the same. • A. True • B. False

B. False

You have to initialize a Terraform backend before it can be configured. • A. True • B. False

B. False

terraform validate validates that your infrastructure matches the Terraform state file. • A. True • B. False

B. False

Which of the following is not an advantage of using infrastructure as code operations? • A. Self-service infrastructure deployment • B. Troubleshoot via a Linux diff command • C. Public cloud console configuration workflows • D. Modify a count parameter to scale resources • E. API driven workflows

C. Public cloud console configuration workflows

Terraform configuration (including any module references) can contain only one Terraform provider type. • A. True • B. False

B. False

Terraform plan updates your state file. • A. True • B. False

B. False

Terraform can only manage resource dependencies if you set them explicitly with the depends_on argument. • A. True • B. False

B. False

Terraform requires the Go runtime as a prerequisite for installation. • A. True • B. False

B. False

Terraform provisioners can be added to any resource block. • A. True • B. False

A. True

You can access state stored with the local backend by using the terraform_remote_state data source. • A. True • B. False

A. True

Terraform variable names are saved in the state file. • A. True • B. False

B. False

Which of the following does terraform apply change after you approve the execution plan? (Choose two.) • A. Cloud infrastructure • B. The .terraform directory • C. The execution plan • D. State file • E. Terraform code

A. Cloud infrastructure

Why should secrets not be hard coded into Terraform code? (Choose two.) • A. It makes the code less reusable. • B. Terraform code is typically stored in version control, as well as copied to the systems from which it's run. Any of those may not have robust security mechanisms. • C. The Terraform code is copied to the target resources to be applied locally and could expose secrets if a target resource is compromised. • D. All passwords should be rotated on a quarterly basis.

A. It makes the code less reusable. AND B. Terraform code is typically stored in version control, as well as copied to the systems from which it's run. Any of those may not have robust security mechanisms.

Which of the following is true about terraform apply? (Choose two.) • A. It only operates on infrastructure defined in the current working directory or workspace • B. You must pass the output of a terraform plan command to it • C. Depending on provider specification, Terraform may need to destroy and recreate your infrastructure resources • D. By default, it does not refresh your state file to reflect current infrastructure configuration • E. You cannot target specific resources for the operation

A. It only operates on infrastructure defined in the current working directory or workspace AND C. Depending on provider specification, Terraform may need to destroy and recreate your infrastructure resources

Which of the following can you do with terraform plan? (Choose two.) • A. Save a generated execution plan to apply later • B. Execute a plan in a different workspace • C. View the execution plan and check if the changes match your expectations • D. Schedule Terraform to run at a planned time in the future

A. Save a generated execution plan to apply later AND C. View the execution plan and check if the changes match your expectations

Where can Terraform not load a provider from? • A. Source code • B. Plugins directory • C. Official HashiCorp distribution on releases.hashicorp.com • D. Provider plugin cache

A. Source code

What does Terraform use .terraform.lock.hcl file for? • A. Tracking provider dependencies • B. There is no such file • C. Preventing Terraform runs from occurring • D. Storing references to workspaces which are locked

A. Tracking provider dependencies

A module can always refer to all variables declared in its parent module. • A. True • B. False

A. True

When you use a remote backend that needs authentication, HashiCorp recommends that you: • A. Use partial configuration to load the authentication credentials outside of the Terraform code • B. Push your Terraform configuration to an encrypted git repository • C. Write the authentication credentials in the Terraform configuration files • D. Keep the Terraform configuration files in a secret store

A. Use partial configuration to load the authentication credentials outside of the Terraform code

Which provider authentication method prevents credentials from being stored in the state file? • A. Using environment variables • B. Specifying the login credentials in the provider block • C. Setting credentials as Terraform variables • D. None of the above

A. Using environment variables

You want to share Terraform state with your team, store it securely, and provide state locking. How would you do this? (Choose three.) • A. Using the remote Terraform backend with Terraform Cloud Terraform Enterprise. • B. Using the local backend. • C. Using the s3 terraform backend. The dynamodb_field option is not needed. • D. Using an s3 terraform backend with an appropriate IAM policy and dynamodb_field option configured. • E. Using the consul Terraform backend.

A. Using the remote Terraform backend with Terraform Cloud / Terraform Enterprise. AND D. Using an s3 terraform backend with an appropriate IAM policy and dynamodb_field option configured. AND Using the consul Terraform backend.

What is the purpose of a Terraform workspace in either open source or enterprise? • A. Workspaces allow you to manage collections of infrastructure in state files • B. A logical separation of business units • C. A method of grouping multiple infrastructure security policies • D. Provides limited access to a cloud environment

A. Workspaces allow you to manage collections of infrastructure in state files

Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers in HCL2? • A. servers - var.num_servers • B. servers - num_servers • C. servers - var(num_servers) • D. $(var.num_servers)

A. servers - var.num_servers

Which are forbidden actions when the Terraform state file is locked? (Choose three.) • A. terraform destroy • B. terraform fmt • C. terraform state list • D. terraform apply • E. terraform plan • F. terraform validate

A. terraform destroy AND D. terraform apply AND E. terraform plan

You have modified your Terraform configuration to fix a typo in the Terraform ID of a resource from aws_security_group.http to aws_security_group.http Which of the following commands would you run to update the ID in state without destroying the resource? • A. terraform mv aws_security_group.htp aws_security_group.http • B. terraform apply • C. terraform refresh

A. terraform mv aws_security_group.htp aws_security_group.http

You are making changes to existing Terraform code to add some new infrastructure. When is the best time to run terraform validate? • A. After you run terraform plan so you can validate that your state file is consistent with your infrastructure • B. Before you run terraform plan so you can validate your code syntax • C. Before you run terraform apply so you can validate your infrastructure changes • D. After you run terraform apply so you can validate that your infrastructure is reflected in your code

B. Before you run terraform plan so you can validate your code syntax

What does running a terraform plan do? • A. Imports all of your existing cloud provider resources to the state file • B. Compares the state file to your Terraform code and determines if any changes need to be made • C. Imports all of your existing cloud provider resources to your Terraform configuration file • D. Compares your Terraform code and local state file to the remote state file in a cloud provider and determines if any changes need to be made

B. Compares the state file to your Terraform code and determines if any changes need to be made

A Terraform output that sets the "sensitive" argument to true will not store that value in the state file. • A. True • B. False

B. False

All Terraform Cloud tiers support team management and governance. • A. True • B. False

B. False

All modules published on the official Terraform Module Registry have been verified by HashiCorp. • A. True • B. False

B. False

Module version is required to reference a module on the Terraform Module Registry. • A. True • B. False

B. False

Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files without changing their contents. • A. True • B. False

B. False

Terraform Cloud is available only as a paid offering from HashiCorp. • A. True • B. False

B. False

Which of these statements about Terraform Enterprise workspaces is false? • A. They can securely store cloud credentials • B. You must use the CLI to switch between workspaces • C. Plans and applies can be triggered via version control system integrations • D. They have role-based access controls

B. You must use the CLI to switch between workspaces

What does terraform refresh modify? • A. Your cloud infrastructure • B. Your state file • C. Your Terraform plan • D. Your Terraform configuration

B. Your state file

Which of the fallowing commands would you use to access all of the attributes and details of a resource managed by Terraform? • A. terraform state list • B. terraform state show • C. terraform get • D. terraform state list

B. terraform state show

When should you run terraform init? • A. After you run terraform apply for the first time in a new Terraform project and before you run terraform plan • B. After you run terraform plan for the first time in a new Terraform project and before you run terraform apply • C. After you start coding a new Terraform project and before you run terraform plan for the first time • D. Before you start coding a new Terraform project

C. After you start coding a new Terraform project and before you run terraform plan for the first time

When does Sentinel enforce policy logic during a Terraform Enterprise run? • A. Before the plan phase • B. During the plan phase • C. Before the apply phase • D. After the apply phase

C. Before the apply phase

What does state locking accomplish? • A. Copies the state file from memory to disk • B. Encrypts any credentials stored within the state file • C. Blocks Terraform commands from modifying the state file • D. Prevents accidental deletion of the state file

C. Blocks Terraform commands from modifying the state file

What does terraform import allow you to do? • A. Import a new Terraform module • B. Use a state file to import infrastructure to the cloud • C. Import provisioned infrastructure to your state file • D. Import an existing state file to a new Terraform workspace

C. Import provisioned infrastructure to your state file

Which of the following statements about local modules is incorrect? • A. Local modules are not cached by terraform init command • B. Local modules are sourced from a directory on disk • C. Local modules support versions • D. All of the above (all statements above are incorrect) • E. None of the above (all statements above are correct)

C. Local modules support versions

Which Terraform collection type should you use to store key;value pairs? • A. tuple • B. set • C. maps • D. list

C. Maps

A junior admin accidentally deleted some of your cloud instances. What does Terraform do when you run terraform apply? • A. Build a completely brand new set of infrastructure • B. Tear down the entire workspace infrastructure and rebuild it • C. Rebuild only the instances that were deleted • D. Stop and generate an error message about the missing instances

C. Rebuild only the instances that were deleted

The ________ determines how Terraform creates, updates, or deletes resources. • A. Terraform configuration • B. Terraform core • C. Terraform provider • D. Terraform provisioner

C. Terraform provider

What advantage does an operations team that uses infrastructure as code have? • A. The ability to delete infrastructure • B. The ability to update existing infrastructure • C. The ability to reuse best practice configurations and settings • D. The ability to autoscale a group of servers

C. The ability to reuse best practice configurations and settings

If a DevOps team adopts AWS CloudFormation as their standardized method for provisioning public cloud resources, which of the following scenarios poses a challenge for this team? • A. The team is asked to build a reusable code base that can deploy resources into any AWS region • B. The team is asked to manage a new application stack built on AWS-native services • C. The organization decides to expand into Azure and wishes to deploy new infrastructure using their existing codebase • D. The DevOps team is tasked with automating a manual provisioning process

C. The organization decides to expand into Azure and wishes to deploy new infrastructure using their existing codebase

Which are examples of infrastructure as code? (Choose two.) • A. Cloned virtual machine images • B. Change management database records • C. Versioned configuration files • D. Docker files

C. Versioned configuration files AND D. Docker files

Which of the following is true about Terraform's implementation of infrastructure as code? (Choose two.) • A. It is only compatible with AWS infrastructure management • B. You cannot reuse infrastructure configuration • C. You can version your infrastructure configuration • D. It requires manual configuration of infrastructure resources • E. It allows you to automate infrastructure provisioning

C. You can version your infrastructure configuration AND E. It allows you to automate infrastructure provisioning

You are writing a child Terraform module which provisions an AWS instance. You want to make use of the IP address returned in the root configuration. You name the instance resource "main". Which of these is the correct way to define the output value using HCL2? A. output "instance_ip_addr" { value = aws_instance.main.private_ip } B. output "aws_instance.instance_ip_addr" { value = "${main.private_ip}"} C. output "instance_ip_addr" { value = "${aws_instance.main.private_ip}"} D. output "instance_ip_addr" { return aws_instance.main.private_ip}

C. output "instance_ip_addr" { value = "${aws_instance.main.private_ip}"}

What is a key benefit of the Terraform state file? • A. A state file can be used to schedule recurring infrastructure tasks • B. A state file represents a source of truth for resources provisioned with a public cloud console • C. A state file represents the desired state expressed by the Terraform code files • D. A state file represents a source of truth for resources provisioned with Terraform

D. A state file represents a source of truth for resources provisioned with Terraform

Which of the following is not a way to trigger terraform destroy? • A. Using the destroy command with auto-approve • B. Running terraform destroy from the correct directory and then typing "yes" when prompted in the CLI • C. Passing --destroy at the end of a plan request • D. Delete the state file and run terraform apply

D. Delete the state file and run terraform apply

You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you terraform apply again immediately afterwards without changing any Terraform code? • A. Terraform will terminate and recreate the VM • B. Terraform will create another duplicate VM • C. Terraform will apply the VM to the state file • D. Nothing

D. Nothing

When should Terraform configuration files be written when running terraform import on existing infrastructure? • A. Infrastructure can be imported without corresponding Terraform code • B. Terraform will generate the corresponding configuration files for you • C. You should write Terraform configuration files after the next terraform import is executed • D. Terraform configuration should be written before terraform import is executed

D. Terraform configuration should be written before terraform import is executed

Which type of block fetches or computes information for use elsewhere in a Terraform configuration? • A. provider • B. resource • C. local • D. data

D. data

You're writing a Terraform configuration that needs to read input from a local file called id_rsa.pub. Which built-in Terraform function can you use to import the file's contents as a string? • A. fileset("id_rsa.pub") • B. filebase64("id_rsa.pub") • C. templatefile("id_rsa.pub") • D. file("id_rsa.pub")

D. file("id_rsa.pub")

Once a new Terraform backend is configured with a Terraform code block, which command(s) is (are) used to migrate the state file? • A. terraform apply • B. terraform push • C. terraform destroy, then terraform apply • D. terraform init

D. terraform init

You have just developed a new Terraform configuration for two virtual machines with a cloud provider. You would like to create the infrastructure for the first time. Which Terraform command should you run first? • A. terraform apply • B. terraform plan • C. terraform show • D. terraform init

D. terraform init

As a member of an operations team that uses infrastructure as code (IaC) practices, you are tasked with making a change to an infrastructure stack running in a public cloud. Which pattern would follow IaC best practices for making a change? • A. Clone the repository containing your infrastructure code and then run the code • B. Use the public cloud console to make the change after a database record has been approved • C. Make the change programmatically via the public cloud CLI • D. Make the change via the public cloud API endpoint • E. Submit a pull request and wait for an approved merge of the proposed changes

E. Submit a pull request and wait for an approved merge of the proposed changes

You have decided to create a new Terraform workspace to deploy a development environment. What is different about this workspace? • A. It has its own state file • B. It pulls in a different terraform.tfvars file • C. It uses a different branch of code • D. It uses a different backend

• A. It has its own state file

You want to tag multiple resources with a string that is a combination of a generated random_id and a variable. How should you use the same value in all these resources without repeating the random_id and variable in each resource? • A. Local values • B. Data source • C. Modules • D. Outputs

• A. Local values

What are some benefits of using Sentinel with Terraform Cloud Terraform Enterprise? (Choose three.) • A. Policy-as-code can enforce security best practices • B. You can restrict specific configurations on resources like "CIDR=0.0.0.0/0" not allowed • C. You can enforce a list of approved AWS AMIs • D. Sentinel Policies can be written in HashiCorp Configuration Language (HCL) • E. You can check out and check in cloud access keys

• A. Policy-as-code can enforce security best practices • B. You can restrict specific configurations on resources like "CIDR=0.0.0.0/0" not allowed • C. You can enforce a list of approved AWS AMIs

What does Terraform use providers for? (Choose three.) • A. Provision resources for on-premises infrastructure services • B. Simplify API interactions • C. Provision resources for public cloud infrastructure services • D. Enforce security and compliance policies • E. Group a collection of Terraform configuration files that map to a single state file

• A. Provision resources for on-premises infrastructure services • B. Simplify API interactions • C. Provision resources for public cloud infrastructure services

While deploying a virtual machine, the first launch user_data script fails due to race condition with another resource deployed during the same Terraform run. What is the least disruptive method to correct the issue? • A. Run terraform taint against the virtual machine's resource name, then terraform apply • B. Restart the virtual machine from the cloud portal • C. Run terraform apply again • D. Run terraform destroy then terraform apply

• A. Run terraform taint against the virtual machine's resource name, then terraform apply

Define the purpose of state in Terraform. • A. State is used to map real world resources to your configuration and keep track of metadata • B. State is a method of codifying the dependencies of related resources • C. State is used to enforce resource configurations that relate to compliance policies • D. State is used to store variables and quickly reuse existing code

• A. State is used to map real world resources to your configuration and keep track of metadata

Any user can publish modules to the public Terraform Module Registry. • A. True • B. False

• A. True

How would you output returned values from a child module? • A. Declare the output in the root configuration • B. Declare the output in the child module • C. Declare the output in both the root and child module • D. None of the above

• B. Declare the output in the child module

Using the terraform state rm command against a resource will destroy it. • A. True • B. False

• B. False

You just upgraded the version of a provider in an existing Terraform project. What do you need to do to install the new provider? • A. Run terraform apply -upgrade • B. Run terraform init -upgrade • C. Run terraform refresh • D. Upgrade your version of Terraform

• B. Run terraform init -upgrade

Which of the following is the safest way to inject sensitive values into a Terraform Cloud workspace? • A. Write the value to a file and specify the file with the -var-file flag • B. Set a value for the variable in the UI and check the "Sensitive" check box • C. Edit the state file directly just before running terraform apply • D. Set the variable value on the command line with the -var flag

• B. Set a value for the variable in the UI and check the "Sensitive" check box

Which method for sharing Terraform configurations keeps them confidential within your organization, supports Terraform's semantic version constraints, and provides a browsable directory? • A. Generic git repository • B. Terraform Cloud Terraform Enterprise private module registry • C. Public Terraform Module Registry • D. Subfolder within a workspace

• B. Terraform Cloud/Terraform Enterprise private module registry

You have some Terraform code and a variable definitions file named dev.auto.tfvars that you tested successfully in the dev environment. You want to deploy the same code in the staging environment with a separate variable definition file and a separate state file. Which two actions should you perform? (Choose two.) • A. Copy the existing terraform.tfstate file and save it as staging.terraform.tfstate • B. Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file="staging.auto.tfvars" flag • C. Create a new Terraform workspace for staging • D. Create a new Terraform provider for staging • E. Add new Terraform code (*.tf files) for staging in the same directory

• B. Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file="staging.auto.tfvars" flag • C. Create a new Terraform workspace for staging

Which feature is not included in Terraform Cloud's free tier? • A. Workspace • B. Remote state management • C. Audit logging • D. Private module registry

• C. Audit logging

You want to define multiple data disks as nested blocks inside the resource block for a virtual machine. What Terraform feature would help you define the blocks using the values in a variable? • A. Local values • B. Collection functions • C. Dynamic blocks • D. Count arguments

• C. Dynamic blocks

You have been working in a Cloud provider account that is shared with other team members. You previously used Terraform to create a load balancer that is listening on port 80. After some application changes, you updated the Terraform code to change the port to 443. You run terraform plan and see that the execution plan shows the port changing from 80 to 443 like you intended, and step away to grab some coffee. In the meantime, another team member manually changes the load balancer port to 443 through the Cloud provider console before you get back to your desk. What will happen when you terraform apply upon returning to your desk? • A. Terraform will fail with an error because the state file is no longer accurate. • B. Terraform will change the load balancer port to 80, and then change it back to 443. • C. Terraform will not make any changes to the Load Balancer and will update the state file to reflect any changes made. • D. Terraform will change the port back to 80 in your code.

• C. Terraform will not make any changes to the Load Balancer and will update the state file to reflect any changes made.

From which of these sources can Terraform import modules? • A. Local path • B. GitHub Repository • C. Terraform Module Registry • D. All of the above

• D. All of the above

Which configuration consistency errors does terraform validate report? • A. A mix of spaces and tabs in configuration files • B. Differences between local and remote state • C. Terraform module isn't the latest version • D. Declaring a resource identifier more than once

• D. Declaring a resource identifier more than once

Which backend does the Terraform CLI use by default? • A. API • B. Remote • C. Terraform Cloud • D. Local • E. HTTP

• D. Local

How does Terraform manage most dependencies between resources? • A. By defining dependencies as modules and including them in a particular order • B. The order that resources appear in Terraform configuration indicates dependencies • C. Using the depends_on parameter • D. Terraform will automatically manage most resource dependencies

• D. Terraform will automatically manage most resource dependencies

In contrast to Terraform Open Source, when working with Terraform Enterprise and Cloud Workspaces, conceptually you could think about them as completely separate working directories. • A. True • B. False

A. True

terraform validate validates the syntax of Terraform files. • A. True • B. False

A. True

FILL BLANK - Which flag would you add to terraform plan to save the execution plan to a file? Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

-out=FILENAME

Which of the following is not an action performed by terraform init? • A. Create a sample main.tf file • B. Initialize a configured backend • C. Retrieve the source code for all referenced modules • D. Load required provider plugins

A. Create a sample main.tf file

Which of these options is the most secure place to store secrets foe connecting to a Terraform remote backend? • A. Defined in Environment variables • B. Inside the backend block within the Terraform configuration • C. Defined in a connection configuration outside of Terraform • D. None of above

A. Defined in Environment variables

Terraform can import modules from a number of sources `" which of the following is not a valid source? • A. FTP server • B. GitHub repository • C. Local path • D. Terraform Module Registry

A. FTP server

How is the Terraform remote backend different than other state backends such as S3, Consul, etc.? • A. It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud • B. It doesn't show the output of a terraform apply locally • C. It is only available to paying customers • D. All of the above

A. It can execute Terraform runs on dedicated infrastructure on premises or in Terraform Cloud

You're building a CI:CD (continuous integration/ continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely? • A. Pass variables to Terraform with a ג€"var flag • B. Copy the sensitive variables into your Terraform code • C. Store the sensitive variables in a secure_vars.tf file • D. Store the sensitive variables as plain text in a source code repository

A. Pass variables to Terraform with a ג€"var flag

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 confirm the planned changes • B. Inspect your Terraform state because you want to change it • C. Reinitialize because your configuration has changed • D. Inspect all Terraform outputs to make sure they are correct

A. Run an apply and confirm the planned changes

You have used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your Terraform configuration. To be safe, you would like to first see all the infrastructure that will be deleted by Terraform. Which command should you use to show all of the resources that will be deleted? (Choose two.) • A. Run terraform plan -destroy. • B. This is not possible. You can only show resources that will be created. • C. Run terraform state rm *. • D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.

A. Run terraform plan -destroy. AND D. Run terraform destroy and it will first output all the resources that will be deleted before prompting for approval.

If you manually destroy infrastructure, what is the best practice reflecting this change in Terraform? • A. Run terraform refresh • B. It will happen automatically • C. Manually update the state fire • D. Run terraform import

A. Run terraform refresh

You have multiple team members collaborating 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 Terraform style convention? • A. Run the terraform fmt command during the code linting phase of your CI:CD process • B. Designate one person in each team to review and format everyone's code • C. Manually apply two spaces indentation and align equal sign "=" characters in every Terraform file (*.tf) • D. Write a shell script to transform Terraform files using tools such as AWK, Python, and sed

A. Run the terraform fmt command during the code linting phase of your CI:CD process

Which of the following is available only in Terraform Enterprise or Cloud workspaces and not in Terraform CLI? • A. Secure variable storage • B. Support for multiple cloud providers • C. Dry runs with terraform plan • D. Using the workspace as a data source

A. Secure variable storage

You want to know from which paths Terraform is loading providers referenced in your Terraform configuration (*.tf files). You need to enable debug messages to find this out. Which of the following would achieve this? • A. Set the environment variable TF_LOG=TRACE • B. Set verbose logging for each provider in your Terraform configuration • C. Set the environment variable TF_VAR_log=TRACE • D. Set the environment variable TF_LOG_PATH

A. Set the environment variable TF_LOG=TRACE

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

A. The terraform block

A Terraform provisioner must be nested inside a resource configuration block. • A. True • B. False

A. True

If a module uses a local values, you can expose that value with a terraform output. • A. True • B. False

A. True

In Terraform 0.13 and above, outside of the required_providers block, Terraform configurations always refer to providers by their local names. • A. True • B. False

A. True

How can terraform plan aid in the development process? • A. Validates your expectations against the execution plan without permanently modifying state • B. Initializes your working directory containing your Terraform configuration files • C. Formats your Terraform configuration files • D. Reconciles Terraform's state against deployed resources and permanently modifies state using the current status of deployed resources

A. Validates your expectations against the execution plan without permanently modifying state

Your risk management organization requires that new AWS S3 buckets must be private and encrypted at rest. How can Terraform Enterprise automatically and proactively enforce this security control? • A. With a Sentinel policy, which runs before every apply • B. By adding variables to each TFE workspace to ensure these settings are always enabled • C. With an S3 module with proper settings for buckets • D. Auditing cloud storage buckets with a vulnerability scanning tool

A. With a Sentinel policy, which runs before every apply

Terraform provisioners that require authentication can use the ______ block. • A. connection • B. credentials • C. secrets • D. ssh

A. connection

Which provisioner invokes a process on the resource created by Terraform? • A. remote-exec • B. null-exec • C. local-exec • D. file

A. remote-exec

You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script. Which of the following commands would you use first? • A. terraform taint null_resource.run_script • B. terraform apply -target=null_resource.run_script • C. terraform validate null_resource.run_script • D. terraform plan -target=null_resource.run_script

A. terraform taint null_resource.run_script

Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.) • A. Destroy • B. Apply • C. Import • D. Init • E. Validate

B. Apply AND D. Init

You have declared an input variable called environment in your parent module. What must you do to pass the value to a child module in the configuration? • A. Add node_count = var.node_count • B. Declare the variable in a terraform.tfvars file • C. Declare a node_count input variable for child module • D. Nothing, child modules inherit variables of parent module

C. Declare a node_count input variable for child module

How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository? • A. Only Terraform Cloud organization owners can set workspace variables on VCS connected workspaces • B. Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to • C. Only members of a VCS organization can open a pull request against repositories that are connected to Terraform Cloud workspaces • D. Only Terraform Cloud organization owners can approve plans in VCS connected workspaces

B. Commit a change to the VCS working directory and branch that the Terraform Cloud workspace is connected to

What is not processed when running a terraform refresh? • A. State file • B. Configuration file • C. Credentials • D. Cloud provider

B. Configuration file

A provider configuration block is required in every Terraform configuration. • A. True • B. False

B. False

All standard backend types support state storage, locking, and remote operations like plan, apply and destroy. • A. True • B. False

B. False

If a module declares a variable with a default, that variable must also be defined within the module. • A. True • B. False

B. False

Module variable assignments are inherited from the parent module and do not need to be explicitly set. • A. True • B. False

B. False

One remote backend configuration always maps to a single remote workspace. • A. True • B. False

B. False

Only the user that generated a plan may apply it. • A. True • B. False

B. False

Setting the TF_LOG environment variable to DEBUG causes debug messages to be logged into syslog. • A. True • B. False

B. False

Terraform and Terraform providers must use the same major version number in a single configuration. • A. True • B. False

B. False

Terraform can run on Windows or Linux, but it requires a Server version of the Windows operating system. • A. True • B. False

B. False

Terraform providers are always installed from the Internet. • A. True • B. False

B. False

When running the command terraform taint against a managed resource you want to force recreation upon, Terraform will immediately destroy and recreate the resource. • A. True • B. False

B. False

You should store secret data in the same version control repository as your Terraform configuration. • A. True • B. False

B. False

terraform init initializes a sample main.tf file in the current directory. • A. True • B. False

B. False

When does terraform apply reflect changes in the cloud environment? • A. Immediately • B. However long it takes the resource provider to fulfill the request • C. After updating the state file • D. Based on the value provided to the -refresh command line argument • E. None of the above

B. However long it takes the resource provider to fulfill the request

A Terraform provider is not responsible for: • A. Understanding API interactions with some service • B. Provisioning infrastructure in multiple clouds • C. Exposing resources and data sources based on an API • D. Managing actions to take based on resource differences

B. Provisioning infrastructure in multiple clouds

Your security team scanned some Terraform workspaces and found secrets stored in a plaintext in state files. How can you protect sensitive data stored in Terraform state files? • A. Delete the state file every time you run Terraform • B. Store the state in an encrypted backend • C. Edit your state file to scrub out the sensitive data • D. Always store your secrets in a secrets.tfvars file.

B. Store the state in an encrypted backend

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

B. Terraform needs to install the necessary plugins first

You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains 15 virtual machines (VM). You develop a Terraform configuration containing one VM, perform terraform apply, and see that your VM was created successfully. What should you do to delete the newly-created VM with Terraform? • A. The Terraform state file contains all 16 VMs in the team account. Execute terraform destroy and select the newly-created VM. • B. The Terraform state file only contains the one new VM. Execute terraform destroy. • C. Delete the Terraform state file and execute Terraform apply. • D. Delete the VM using the cloud provider console and terraform apply to apply the changes to the Terraform state file.

B. The Terraform state file only contains the one new VM. Execute terraform destroy.

You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead. What are the two things you must do to achieve this? (Choose two.) • A. Provision new VMs using Terraform with the same VM names • B. Use the terraform import command for the existing VMs • C. Write Terraform configuration for the existing VMs • D. Run the terraform import-gcp command

B. Use the terraform import command for the existing VMs AND C. Write Terraform configuration for the existing VMs

Which of these is the best practice to protect sensitive values in state files? • A. Blockchain • B. Secure Sockets Layer (SSL) • C. Enhanced remote backends • D. Signed Terraform providers

C. Enhanced remote backends

Your DevOps team is currently using the local backend for your Terraform configuration. You would like to move to a remote backend to begin storing the state file in a central location. Which of the following backends would not work? • A. Amazon S3 • B. Artifactory • C. Git • D. Terraform Cloud

C. Git

When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.) • A. When a change is made to the resources via the Azure Cloud Console, the changes are recorded in a new state file • B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state file to reflect them during the next plan or apply • C. When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated • D. When a change is made to the resources via the Azure Cloud Console, the changes are recorded in the current state file

B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state file to reflect them during the next plan or apply AND C. When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated

Which of the following is allowed as a Terraform variable name? • A. count • B. name • C. source • D. version

B. name

What command does Terraform require the first time you run it within a configuration directory? • A. terraform import • B. terraform init • C. terraform plan • D. terraform workspace

B. terraform init

A fellow developer on your team is asking for some help in refactoring their Terraform code. As part of their application's architecture, they are going to tear down an existing deployment managed by Terraform and deploy new. However, there is a server resource named aws_instance.ubuntu[1] they would like to keep to perform some additional analysis. What command should be used to tell Terraform to no longer manage the resource? • A. terraform apply rm aws_instance.ubuntu[1] • B. terraform state rm aws_instance.ubuntu[1] • C. terraform plan rm aws_instance.ubuntu[1] • D. terraform delete aws_instance.ubuntu[1]

B. terraform state rm aws_instance.ubuntu[1]

You would like to reuse the same Terraform configuration for your development and production environments with a different state file for each. Which command would you use? • A. terraform import • B. terraform workspace • C. terraform state • D. terraform init

B. terraform workspace

You have declared a variable called var.list which is a list of objects that all have an attribute id. Which options will produce a list of the IDs? (Choose two.) • A. { for o in var.list : o => o.id } • B. var.list[*].id • C. [ var.list[*].id ] • D. [ for o in var.list : o.id ]

B. var.list[*].id AND D. [ for o in var.list : o.id ]

Which option cannot be used to keep secrets out of Terraform configuration files? • A. Environment Variables • B. Mark the variable as sensitive • C. A Terraform provider • D. A -var flag

C. A Terraform provider

When using a module block to reference a module stored on the public Terraform Module Registry How do you specify version 1.0.0? • A. Modules stored on the public Terraform Module Registry do not support versioning • B. Append ?ref=v1.0.0 argument to the source path • C. Add version = "1.0.0" attribute to module block • D. Nothing ג€" modules stored on the public Terraform Module Registry always default to version 1.0.0

C. Add version = "1.0.0" attribute to module block

When should you use the force-unlock command? • A. You see a status message that you cannot acquire the lock • B. You have a high priority change • C. Automatic unlocking failed • D. You apply failed due to a state lock

C. Automatic unlocking failed

When you initialize Terraform, where does it cache modules from the public Terraform Module Registry? • A. On disk in the tmp directory • B. In memory • C. On disk in the .terraform sub-directory • D. They are not cached

C. On disk in the .terraform sub-directory

What features does the hosted service Terraform Cloud provide? (Choose two.) • A. Automated infrastructure deployment visualization • B. Automatic backups • C. Remote state storage • D. A web-based user interface (UI)

C. Remote state storage AND D. A web-based user interface (UI)

You have deployed a new webapp with a public IP address on a cloud provider. However, you did not create any outputs for your code. What is the best method to quickly find the IP address of the resource you deployed? • A. Run terraform output ip_address to view the result • B. In a new folder, use the terraform_remote_state data source to load in the state file, then write an output for each resource that you find the state file • C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address • D. Run terraform destroy then terraform apply and look for the IP address in stdout

C. Run terraform state list to find the name of the resource, then terraform state show to find the attributes including public IP address

What is terraform refresh intended to detect? • A. Terraform configuration code changes • B. Empty state files • C. State file drift • D. Corrupt state files

C. State file drift

What is one disadvantage of using dynamic blocks in Terraform? • A. They cannot be used to loop through a list of values • B. Dynamic blocks can construct repeatable nested blocks • C. They make configuration harder to read and understand • D. Terraform will run more slowly

C. They make configuration harder to read and understand

Examine the following Terraform configuration, which uses the data source for an AWS AMI. What value should you enter for the ami argument in the AWS instance resource • A. aws_ami.ubuntu • B. data.aws_ami.ubuntu • C. data.aws_ami.ubuntu.id • D. aws_ami.ubuntu.id

C. data.aws_ami.ubuntu.id

You need to deploy resources into two different cloud regions in the same Terraform configuration. To do that, you declare multiple provider configurations as follows: What meta-argument do you need to configure in a resource block to deploy the resource to the `us-west-2` AWS region? • A. alias = west • B. provider = west • C. provider = aws.west • D. alias = aws.west

C. provider = aws.west

Which of the following is not a valid string function in Terraform? • A. split • B. join • C. slice • D. chomp

C. slice

What command should you run to display all workspaces for the current configuration? • A. terraform workspace • B. terraform workspace show • C. terraform workspace list • D. terraform show workspace

C. terraform workspace list

What information does the public Terraform Module Registry automatically expose about published modules? • A. Required input variables • B. Optional inputs variables and default values • C. Outputs • D. All of the above • E. None of the above

D. All of the above

How is terraform import run? • A. As a part of terraform init • B. As a part of terraform plan • C. As a part of terraform refresh • D. By an explicit call • E. All of the above

D. By an explicit call

You have recently started a new job at a retailer as an engineer. As part of this new role, you have been tasked with evaluating multiple outages that occurred during peak shopping time during the holiday season. Your investigation found that the team is manually deploying new compute instances 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 a ticketing workflow that makes engineers submit a ticket before manually provisioning and configuring a resource • B. Implement a checklist that engineers can follow when configuring compute instances • C. Replace the compute instance type with a larger version to reduce the number of required deployments • D. Implement a provisioning pipeline that deploys infrastructure configurations committed to your version control system following code reviews

D. Implement a provisioning pipeline that deploys infrastructure configurations committed to your version control system following code reviews

Terraform validate reports syntax check errors from which of the following scenarios? • A. Code contains tabs indentation instead of spaces • B. There is missing value for a variable • C. The state files does not match the current infrastructure • D. None of the above

D. None of the above

What does the default "local" Terraform backend store? • A. tfplan files • B. Terraform binary • C. Provider plugins • D. State file

D. State file

What features stops multiple admins from changing the Terraform state at the same time? • A. Version control • B. Backend types • C. Provider constraints • D. State locking

D. State locking

You have a simple Terraform configuration containing one virtual machine (VM) in a cloud provider. You run terraform apply and the VM is created successfully. What will happen if you delete the VM using the cloud provider console, and run terraform apply again without changing any Terraform code? • A. Terraform will remove the VM from state file • B. Terraform will report an error • C. Terraform will not make any changes • D. Terraform will recreate the VM

D. Terraform will recreate the VM

Which statement describes a goal of infrastructure as code? • A. An abstraction from vendor specific APIs • B. Write once, run anywhere • C. A pipeline process to test and deliver software • D. The programmatic configuration of resources

D. The programmatic configuration of resources

Which task does terraform init not perform? • A. Sources all providers present in the configuration and ensures they are downloaded and available locally • B. Connects to the backend • C. Sources any modules and copies the configuration locally • D. Validates all required variables are present

D. Validates all required variables are present

If writing Terraform code that adheres to the Terraform style conventions, how would you properly indent each nesting level compared to the one above it? • A. With four spaces • B. With a tab • C. With three spaces • D. With two spaces

D. With two spaces

What is the workflow for deploying new infrastructure with Terraform? • A. terraform plan to import the current infrastructure to the state file, make code changes, and terraform apply to update the infrastructure. • B. Write a Terraform configuration, run terraform show to view proposed changes, and terraform apply to create new infrastructure. • C. terraform import to import the current infrastructure to the state file, make code changes, and terraform apply 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.

D. Write a Terraform configuration, run terraform init, run terraform plan to view planned infrastructure changes, and terraform apply to create new infrastructure.

What type of block is used to construct a collection of nested configuration blocks? • A. for_each • B. repeated • C. nesting • D. dynamic

D. dynamic

Which option can not be used to keep secrets out of Terraform configuration files? • A. A Terraform provider • B. Environment variables • C. A -var flag • D. secure string

D. secure string

Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers? • A. servers = num_servers • B. servers = variable.num_servers • C. servers = var(num_servers) • D. servers = var.num_servers

D. servers = var.num_servers

Which of the following arguments are required when declaring a Terraform output? • A. sensitive • B. description • C. default • D. value

D. value

You need to constrain the GitHub provider to version 2.1 or greater. Which of the following should you put into the Terraform 0.12 configuration's provider block? A. version >= 2.1 B. version ~> 2.1 C. version = "<= 2.1" D. version = ">= 2.1"

D. version = ">= 2.1"

Which argument(s) is (are) required when declaring a Terraform variable? • A. type • B. default • C. description • D. All of the above • E. None of the above

E. None of the above

Which of the following is not true of Terraform providers? • A. Providers can be written by individuals • B. Providers can be maintained by a community of users • C. Some providers are maintained by HashiCorp • D. Major cloud vendors and non-cloud vendors can write, maintain, or collaborate on Terraform providers • E. None of the above

E. None of the above

FILL BLANK - What is the name of the default file where Terraform stores the state? Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

Terraform.tfstate

FILL BLANK - You need to specify a dependency manually. What resource meta-parameter can you use to make sure Terraform respects the dependency? Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

depends_on

Most Terraform providers interact with ____________. • A. API • B. VCS Systems • C. Shell scripts • D. None of the above

• A. API

A Terraform local value can reference other Terraform local values. • A. True • B. False

• A. True

HashiCorp Configuration Language (HCL) supports user-defined functions. • A. True • B. False

• B. False

Which of the following is not a key principle of infrastructure as code? • A. Versioned infrastructure • B. Golden images • C. Idempotence • D. Self-describing infrastructure

• B. Golden images

Why would you use the terraform taint command? • A. When you want to force Terraform to destroy a resource on the next apply • B. When you want to force Terraform to destroy and recreate a resource on the next apply • C. When you want Terraform to ignore a resource on the next apply • D. When you want Terraform to destroy all the infrastructure in your workspace

• B. When you want to force Terraform to destroy and recreate a resource on the next apply

Where does the Terraform local backend store its state? • A. In the tmp directory • B. In the terraform file • C. In the terraform.tfstate file • D. In the user's terraform.state file

• C. In the terraform.tfstate file

What value does the Terraform Cloud Terraform Enterprise private module registry provide over the public Terraform Module Registry? • A. The ability to share modules with public Terraform users and members of Terraform Enterprise Organizations • B. The ability to tag modules by version or release • C. The ability to restrict modules to members of Terraform Cloud or Enterprise organizations • D. The ability to share modules publicly with any user of Terraform

• C. The ability to restrict modules to members of Terraform Cloud or Enterprise organizations

Which of the following is not a valid Terraform collection type? • A. list • B. map • C. tree • D. set

• C. tree

Which backend does the Terraform CLI use by default? • A. Terraform Cloud • B. Consul • C. Remote • D. Local

• D. Local

A terraform apply can not _________ infrastructure. • A. change • B. destroy • C. provision • D. import

• D. import


Ensembles d'études connexes

Presidents of the Philippines; Achievements and contributions

View Set

SHONA,Culture/Tsika,Ukama/Kinship

View Set

Molybdenum-99 / 99-Mo / 66 hours / 181keV, 740keV, 778keV (γ), Thallium-201 / 201-Tl / 73 Hours / 135keV & 167keV, Xenon-133 / 133-Xe / 5.3 Days / 81kEv, Technetium-99m / 99m-Tc / 6hrs / 140KeV

View Set

Expanding World Empires Unit Test

View Set

The flow of food and introduction

View Set