HashiCorp Certified: Terraform Associate Practice Exam 2020 – Exam 2 (Q1-Q30) – Cuongquach.com | Bộ đề ôn thi chứng chỉ HashiCorp Certified: Terraform Associate , Bộ đề số 2 với những câu hỏi trọng tâm trong năm 2020 và 2021 về kiến thức sử dụng công cụ Terraform quản lý hạ tầng dịch vụ. Bộ đề số 2, bao gồm 57 câu hỏi chia ra làm nhiều bài viết, bạn đang ở bài viết bao gồm câu hỏi 1 đến câu hỏi 30 của bộ đề 2.
Có thể bạn quan tâm phần 2 – Exam 2:
– HashiCorp Certified: Terraform Associate Practice Exam 2020 – Exam 2 (Q31-Q57)
Nếu bạn cảm thấy câu trả lời của các câu hỏi có sự không chính xác hoặc băn khoăn về đáp án, thì đừng ngại bình luận ở dưới.
Terraform Associate Practice Exam 2020 – Exam 2 – Question 1 to 30
Question 1:
When writing Terraform code, HashiCorp recommends that you use how many spaces between each nesting level?
A. | 2 |
B. | 5 |
C | 4 |
D | 1 |
Question 2:
A user creates three workspaces from the command line – prod, dev, and test. Which of the following commands will the user run to switch to the dev workspace?
A. | terraform workspace select dev |
B. |
terraform workspace -switch dev |
C. |
terraform workspace dev |
D. | terraform workspace switch dev |
Question 3
Where does Terraform OSS store the local state for workspaces?
A. | a file called terraform.tfstate.backup |
B. | directory called terraform.workspaces.tfstate |
C. | directory called terraform.tfstate.d |
D. | a file called terraform.tfstate |
Question 4
Which of the following terraform subcommands could be used to remove the lock on the state for the current configuration?
A. | force-unlock |
B. | Removing the lock on a state file is not possible |
C. | state-unlock |
D. | unlock |
Question 5
Elijah has created a module called “my_test_module” and committed it to GitHub. Over time, several commits have been made with updates to the module, each tagged in GitHub with an incremental version number. Which of the following lines would be required in a module configuration block in terraform to select tagged version v1.0.4?
A. | source = “git::https://example.com/my_test_module.git@tag=v1.0.4” |
B. | source = “git::https://example.com/my_test_module.git&ref=v1.0.4” |
C. | source = “git::https://example.com/my_test_module.git#tag=v1.0.4” |
D. | source = “git::https://example.com/my_test_module.git?ref=v1.0.4” |
Question 6
Harry has deployed resources on Azure for his organization using Terraform. However, he has discovered that his co-workers Ron and Ginny have manually created a few resources using the Azure console. Since it’s company policy to manage production workloads using IaC, how can Harry start managing these resources in Terraform without negatively impacting the availability of the deployed resources?
A | rewrite the Terraform configuration file to deploy new resources, run a terraform apply , and migrate users to the newly deployed resources. Manually delete the other resources created by Ron and Ginny |
B | run a terraform get to retrieve other resources that are not under Terraform management |
C | resources created outside of Terraform cannot be managed by Terraform |
D | use terraform import to import the existing resources under Terraform management |
Question 7
In the following code snippet, the block type
is identified by which string?
resource "aws_instance" "db" { ami = "ami-123456" instance_type = "t2.micro" }
A | instance_type |
B | resource |
C | “db” |
D |
“aws_instance”
|
Question 8
In order to reduce the time it takes to provision resources, Terraform uses parallelism. By default, how many resources will Terraform provision concurrently during a terraform apply
?
A | 20 |
B | 50 |
C | 10 |
D | 5 |
Question 9
Provider dependencies are created in several different ways. Select the valid provider dependencies from the following list: (select three)
A | Explicit use of a provider block in configuration, optionally including a version constraint. |
B | Existence of any resource instance belonging to a particular provider in the current state. |
C | Existence of any provider plugins found locally in the working directory |
D | Use of any resource belonging to a particular provider in a resource or data block in the configuration. |
Question 10
True or False? terraform init
cannot automatically download community providers.
A | True |
B | False |
Question 11
True of False? Rather than use state, Terraform can inspect cloud resources on every run.
A | True |
B | False |
Question 12
Which of the following is an invalid variable name?
A | count |
B | instance_name |
C | web |
D | var1 |
Question 13
What is the result of the following terraform function call?
> index(["a", "b", "c"], "c")
A | 2 |
B | 0 |
C | true |
D | 1 |
Question 14
In the example below, the depends_on
argument creates what type of dependency?
resource "aws_instance" "example" { ami = "ami-2757f631" instance_type = "t2.micro" depends_on = [aws_s3_bucket.company_data] }
A | non-dependency resource |
B |
internal dependency
|
C |
implicit dependency
|
D | explicit dependency |
Question 15
From the code below, identify the implicit dependency:
resource "aws_eip" "public_ip" { vpc = true instance = aws_instance.web_server.id } resource "aws_instance" "web_server" { ami = "ami-2757f631" instance_type = "t2.micro" depends_on = [aws_s3_bucket.company_data] }
A | The S3 bucket labeled company_data |
B |
The AMI used for the EC2 instance
|
C |
The EC2 instance labeled web_server
|
D |
The EIP with an id of ami-2757f631
|
Question 16
When using providers that require the retrieval of data, such as the HashiCorp Vault provider, in what phase does Terraform actually retrieve the data required, assuming you are following the standard workflow of write, plan, and apply?
A | terraform destroy |
B | terraform init |
C | terraform plan |
D | terraform apply |
Question 17
Choose the correct answer which fixes the syntax of the following Terraform code:
resource "aws_security_group" "vault_elb" { name = "${var.name_prefix}-vault-elb" description = Vault ELB vpc_id = var.vpc_id }
A |
resource "aws_security_group" "vault_elb" { name = "${var.name_prefix}-vault-elb" description = var_Vault ELB vpc_id = var.vpc_id } |
B |
resource "aws_security_group" "vault_elb" { name = "${var.name_prefix}-vault-elb" description = "Vault ELB" vpc_id = var.vpc_id } |
C |
resource "aws_security_group" "vault_elb" { name = "${var.name_prefix}-vault-elb" description = "${Vault ELB}" vpc_id = var.vpc_id } |
D |
resource "aws_security_group" "vault_elb" { name = "${var.name_prefix}-vault-elb" description = [Vault ELB] vpc_id = var.vpc_id } |
Question 18
A user has created three workspaces using the command line – prod, dev, and test. The user wants to create a fourth workspace named stage
. Which command will the user execute to accomplish this?
A |
terraform workspace new stage
|
B |
terraform workspace -create stage
|
C |
terraform workspace -new stage
|
D |
terraform workspace create stage
|
Question 19
True or False? By default, Terraform destroy
will prompt for confirmation before proceeding.
A | False |
B | True |
Question 20
Anyone can publish and share modules on the Terraform Public Module Registry
, and meeting the requirements for publishing a module is extremely easy. Select from the following list all valid requirements. (select three).
A |
The module must be on GitHub and must be a public repo
|
B |
The module must be PCI/HIPPA compliant
|
C |
Module repositories must use this three-part name format, terraform-<PROVIDER>-<NAME>
|
D |
The registry uses tags to identify module versions. Release tag names must be for the format x.y.z, and can optionally be prefixed with a
v . |
Question 21
Which Terraform command will check and report errors within modules, attribute names, and value types to make sure they are syntactically valid and internally consistent?
A | terraform format |
B | terraform show |
C | terraform validate |
D | terraform fmt |
Question 22
What is the result of the following terraform function call?
> lookup({a="hello", b="goodbye"}, "c", "what?")
A | c |
B | goodbye |
C | what? |
D | hello |
Question 23
Henry has been working hard on automating his infrastructure for a new application using Terraform. His organization has standardized on Azure for application workloads. Currently, he has his application running successfully, but he has added a new resource to create a DNS record using the Infoblox provider. He has added the new resource but gets an error when he runs a terraform plan
. What should Henry do first before running a plan and apply?
A | since he has introduced a new provider, a terraform init needs to be run to download the Infoblox plugin |
B | Henry should run a terraform plan -refresh=true to update the state for the new DNS resource |
C | you can’t mix resources from different providers within the same configuration file, so Henry should create a module for the DNS resource and reference it from the main configuration |
D |
the Azure plugin doesn’t support Infoblox directly, so Henry needs to put the DNS resource in another configuration file
|
Question 24
Select the most accurate statement to describe the Terraform language from the following list.
A | Terraform is an immutable, declarative, Infrastructure as Code provisioning language based on Hashicorp Configuration Language, or optionally JSON. |
B | Terraform is a mutable, procedural, Infrastructure as Code provisioning language based on Hashicorp Configuration Language, or optionally YAML. |
C |
Terraform is a mutable, declarative, Infrastructure as Code configuration management language based on Hashicorp Configuration Language, or optionally JSON.
|
D | Terraform is an immutable, procedural, Infrastructure as Code configuration management language based on Hashicorp Configuration Language, or optionally JSON. |
Question 25
What feature of Terraform Cloud and/or Terraform Enterprise can you publish and maintain a set of custom modules which can be used within your organization?
A | private module registry |
B |
remote runs
|
C | custom VCS integration |
D | Terraform registry |
Question 26:
The following is a snippet from a Terraform configuration file:
provider "aws" { region = "us-east-1" } provider "aws" { region = "us-west-1" }
which, when validated, results in the following error:-
Error: Duplicate provider configuration on main.tf line 5: 5: provider "aws" { A default provider configuration for "aws" was already given at main.tf:1,1-15. If multiple configurations are required, set the "______" argument for alternative configurations.
Fill in the blank in the error message with the correct string from the list below.
A. | alias |
B. |
multi
|
C. | label |
D. | version |
Question 27
When multiple arguments with single-line values appear on consecutive lines at the same nesting level, HashiCorp recommends that you:
module "servers" { source = "./app-cluster" servers = 5 }
A. | align their equals signs
ami = "abc123" instance_type = "t2.micro" |
B. | place all arguments using a variable at the top
ami = var.aws_ami instance_type = var.instance_size subnet_id = "subnet-0bb1c79de3EXAMPLE" tags = { Name = "HelloWorld" } |
C. | put arguments in alphabetical order
name = "www.example.com" records = [aws_eip.lb.public_ip] type = "A" ttl = "300" zone_id = aws_route53_zone.primary.zone_id |
D. | place a space in between each line
type = "A" ttl = "300" zone_id = aws_route53_zone.primary.zone_id |
Question 28
In Terraform, most resource dependencies are handled automatically. Which of the following statements describes best how Terraform resource dependencies are handled?
A. | The Terraform binary contains a built-in reference map of all defined Terraform resource dependencies. Updates to this dependency map are reflected in terraform versions. To ensure you are working with the latest resource dependency map you much be running the latest version of Terraform. |
B. | Resource dependencies are handled automatically by the depends_on meta_argument, which is set to true by default. |
C. | Resource dependencies are identified and maintained in a file called resource.dependencies . Each terraform provider is required to maintain a list of all resource dependencies for the provider and it’s included with the plugin during initialization when terraform init is executed. The file is located in the terraform.d folder. |
D. | Terraform analyzes any expressions within a resource block to find references to other objects and treats those references as implicit ordering requirements when creating, updating, or destroying resources. |
Question 29
Why might a user opt to include the following snippet in their configuration file?
terraform { required_version = ">= 0.12" }
A. | versions before Terraform 0.12 were not approved by HashiCorp to be used in production |
B. | The user wants to ensure that the application being deployed is a minimum version of 0.12 |
C. | Terraform 0.12 introduced substantial changes to the syntax used to write Terraform configuration |
D. | this ensures that all Terraform providers are above a certain version to match the application being deployed |
Question 30
Larissa is interested in using a module to create an AWS VPC. She finds this code but isn’t sure what all the declarations are beyond the source and version (such as “name, cidr, azs, etc). What are these declarations used for?
module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "2.21.0" name = var.vpc_name cidr = var.vpc_cidr azs = var.vpc_azs private_subnets = var.vpc_private_subnets public_subnets = var.vpc_public_subnets enable_nat_gateway = var.vpc_enable_nat_gateway tags = var.vpc_tags }
A. | these are variables that are passed into the child module likely used for resource creation |
B. | the value of these variables will be obtained from values created within the child module |
C. | this is where the variable declarations are so Terraform is aware of these variables within the calling module |
D. | these are the outputs that the child module will return |
Nguồn: https://cuongquach.com/