100% Pass Your TA-002-P Exam Dumps at First Attempt with Prep4pass [Q156-Q181]

Share

100% Pass Your TA-002-P Exam Dumps at First Attempt with Prep4pass

Penetration testers simulate TA-002-P exam PDF

NEW QUESTION 156
Your developers are facing a lot of problem while writing complex expressions involving difficult interpolations . They have to run the terraform plan every time and check whether there are errors , and also check terraform apply to print the value as a temporary output for debugging purposes. What should be done to avoid this?

  • A. Use terraform console command to have an interactive UI with full access to the underlying terraform state to run your interpolations , and debug at real-time.
  • B. Use terraform console command to have an interactive UI , but you can only use it with local state , and it does not work with remote state.
  • C. Use terraform zipmap function , it will be able to easily do the interpolations without complex code.
  • D. Add a breakpoint in your code, using the watch keyword , and output the value to console for temporary debugging.

Answer: A

Explanation:
The terraform console command provides an interactive console for evaluating expressions. This is useful for testing interpolations before using them in configurations, and for interacting with any values currently saved in state.
https://www.terraform.io/docs/commands/console.html

 

NEW QUESTION 157
You have created an AWS EC2 instance of type t2.micro through your terraform configuration file ec2.tf .
Now you want to change the instance type from t2.micro to t2.medium. Accordingly you have changed your configuration file and and ran terraform plan. After running terraform plan you check the output and saw one instance will be updated from t2.micro --> t2.medium. After this you went to grab a coffee without running terraform apply and meanwhile a member of your team changed the instance type of that EC2 instance to t2.medium from aws console. After coming to your desk you run terraform apply. What will happen?

  • A. The instance type will be changed to t2.micro and again will be changed to t2.medium
  • B. No resource will be updated and you will see the message : Apply Complete ! Resources : 0 added, 0 changed, 0 destroyed.
  • C. terraform apply will through an error.
  • D. 1 resource will be updated and you will see the message : Apply Complete ! Resources : 0 added, 1 changed, 0 destroyed.

Answer: B

 

NEW QUESTION 158
Talal is a DevOps engineer and he has deployed the production infrastructure using Terraform. He is using a very large configuration file to maintain and update the actual infrastructure. As the infrastructure have grown to a very complex and large, he has started experiencing slowness when he run runs terraform plan. What are the options for him to resolve this slowness?

  • A. Use -refresh=false flag as well as the -target flag with terraform plan in order to work around this.
  • B. Break large configurations into several smaller configurations that can each be independently applied.
  • C. Use -refresh=true flag as well as the -target flag with terraform plan in order to work around this.
  • D. Run terraform refresh every time before running terraform plan.

Answer: A,B

Explanation:
For larger infrastructures, querying every resource is too slow. Many cloud providers do not provide APIs to query multiple resources at once, and the round trip time for each resource is hundreds of milliseconds. On top of this, cloud providers almost always have API rate limiting so Terraform can only request a certain number of resources in a period of time. Larger users of Terraform make heavy use of the -refresh=false flag as well as the -target flag in order to work around this. In these scenarios, the cached state is treated as the record of truth.
Although 'Use -refresh=false flag as well as the -target flag with terraform plan in order to work around this.' is a solution, but its not always recommended. Instead of using -target as a means to operate on isolated portions of very large configurations, prefer instead to break large configurations into several smaller configurations that can each be independently applied. Data sources can be used to access information about resources created in other configurations, allowing a complex system architecture to be broken down into more manageable parts that can be updated independently.
Option 'Run terraform refresh every time before running terraform plan.' and 'Use -refresh=true flag as well as the -target flag with terraform plan in order to work around this.' is not correct because in both the cases terraform will query every resources of the infrastructure.

 

NEW QUESTION 159
What happens when a terraform apply command is executed?

  • A. The backend is initialized and the working directory is prepped.
  • B. Applies the changes required in the target infrastructure in order to reach the desired configuration.
  • C. Reconciles the state Terraform knows about with the real-world infrastructure.
  • D. Creates the execution plan for the deployment of resources.

Answer: B

Explanation:
Explanation
The terraform apply command is used to apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.
https://www.terraform.io/docs/commands/apply.html

 

NEW QUESTION 160
While Terraform is generally written using the HashiCorp Configuration Language (HCL), what other syntax can Terraform are expressed in?

  • A. YAML
  • B. JSON
  • C. TypeScript
  • D. XML

Answer: B

Explanation:
Explanation
The constructs in the Terraform language can also be expressed in JSON syntax, which is harder for humans to read and edit but easier to generate and parse programmatically.

 

NEW QUESTION 161
Which Terraform command will force a marked resource to be destroyed and recreated on the next apply?

  • A. terraform fmt
  • B. terraform destroy
  • C. terraform refresh
  • D. terraform taint

Answer: D

Explanation:
Explanation
The terraform taint command manually marks a Terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next apply.
This command will not modify infrastructure, but does modify the state file in order to mark a resource as tainted. Once a resource is marked as tainted, the next plan will show that the resource will be destroyed and recreated and the next apply will implement this change.
Forcing the recreation of a resource is useful when you want a certain side effect of recreation that is not visible in the attributes of a resource. For example: re-running provisioners will cause the node to be different or rebooting the machine from a base image will cause new startup scripts to run.
Note that tainting a resource for recreation may affect resources that depend on the newly tainted resource. For example, a DNS resource that uses the IP address of a server may need to be modified to reflect the potentially new IP address of a tainted server. The plan command will show this if this is the case.
https://www.terraform.io/docs/commands/taint.html

 

NEW QUESTION 162
How would you reference the "name" value of the second instance of this fictitious resource?

  • A. aws_instance.web[2].name
  • B. aws_instance.web[1]
  • C. aws_instance.web.*.name
  • D. element(aws_instance.web, 2)
  • E. aws_instance.web[1].name

Answer: D

Explanation:
Explanation/Reference: https://www.terraform.io/docs/configuration-0-11/interpolation.html

 

NEW QUESTION 163
What command should you run to display all workspaces for the current configuration?

  • A. terraform workspace show
  • B. terraform workspace
  • C. terraform workspace list
  • D. terraform show workspace

Answer: C

Explanation:
terraform workspace list
The command will list all existing workspaces.

 

NEW QUESTION 164
Your organization has moved to AWS and has manually deployed infrastructure using the console. Recently, a decision has been made to standardize on Terraform for all deployments moving forward.
What can you do to ensure that all existing is managed by Terraform moving forward without interruption to existing services?

  • A. Delete the existing resources and recreate them using new a Terraform configuration so Terraform can manage them moving forward.
  • B. Submit a ticket to AWS and ask them to export the state of all existing resources and use terraform import to import them into the state file.
  • C. Resources that are manually deployed in the AWS console cannot be imported by Terraform.
  • D. Using terraform import, import the existing infrastructure into your Terraform state.

Answer: D

Explanation:
Terraform is able to import existing infrastructure. This allows us take resources we've created by some other means (i.e. via console) and bring it under Terraform management.
This is a great way to slowly transition infrastructure to Terraform.
The terraform import command is used to import existing infrastructure.
To import a resource, first write a resource block for it in our configuration, establishing the name by which it will be known to Terraform.
Example:
resource "aws_instance" "import_example" {
# ...instance configuration...
}
Now terraform import can be run to attach an existing instance to this resource configuration.
$ terraform import aws_instance.import_example i-03efafa258104165f
aws_instance.import_example: Importing from ID "i-03efafa258104165f"...
aws_instance.import_example: Import complete!
Imported aws_instance (ID: i-03efafa258104165f)
aws_instance.import_example: Refreshing state... (ID: i-03efafa258104165f) Import successful!
The resources that were imported are shown above. These resources are now in your Terraform state and will henceforth be managed by Terraform.
This command locates the AWS instance with ID i-03efafa258104165f (which has been created outside Terraform) and attaches its existing settings, as described by the EC2 API, to the name aws_instance.import_example in the Terraform state.

 

NEW QUESTION 165
Which option can not be used to keep secrets out of Terraform configuration files?

  • A. Environment variables
  • B. A -var flag
  • C. A Terraform provider
  • D. secure string

Answer: B

 

NEW QUESTION 166
When using a module block to reference a module stored on the public Terraform Module Registry such as:

How do you specify version 1.0.0?

  • A. Modules stored on the public Terraform Module Registry do not support versioning
  • B. Add version = "1.0.0" attribute to module block
  • C. Nothing - modules stored on the public Terraform Module Registry always default to version 1.0.0
  • D. Append ?ref=v1.0.0 argument to the source path

Answer: A

Explanation:
Explanation/Reference: https://www.terraform.io/docs/language/modules/sources.html

 

NEW QUESTION 167
A user runs terraform init on their RHEL based server and per the output, two provider plugins are downloaded: $ terraform init Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.44.0...
- Downloading plugin for provider "random" (hashicorp/random) 2.2.1...
:
Terraform has been successfully initialized! Where are these plugins downloaded to?

  • A. The .terraform.plugins directory in the directory terraform init was executed in.
  • B. The .terraform/plugins directory in the directory terraform init was executed in.
  • C. /etc/terraform/plugins
  • D. The .terraform.d directory in the directory terraform init was executed in.

Answer: B

 

NEW QUESTION 168
What resource dependency information is stored in Terraform's state?

  • A. Both implicit and explicit dependencies are stored in state.
  • B. No dependency information is stored in state.
  • C. Only explicit dependencies are stored in state.
  • D. Only implicit dependencies are stored in state.

Answer: A

Explanation:
Terraform state captures all dependency information, both implicit and explicit. One purpose for state is to determine the proper order to destroy resources. When resources are created all of their dependency information is stored in the state. If you destroy a resource with dependencies, Terraform can still determine the correct destroy order for all other resources because the dependencies are stored in the state.
https://www.terraform.io/docs/state/purpose.html#metadata

 

NEW QUESTION 169
When writing Terraform code, HashiCorp recommends that you use how many spaces between each nesting level?

  • A. 0
  • B. 1
  • C. 2
  • D. 3

Answer: C

Explanation:
Explanation
The Terraform parser allows you some flexibility in how you lay out the elements in your configuration files, but the Terraform language also has some idiomatic style conventions which we recommend users always follow for consistency between files and modules written by different teams. Automatic source code formatting tools may apply these conventions automatically.
Indent two spaces for each nesting level.
When multiple arguments with single-line values appear on consecutive lines at the same nesting level, align their equals signs:
ami = "abc123"
instance_type = "t2.micro"
When both arguments and blocks appear together inside a block body, place all of the arguments together at the top and then place nested blocks below them. Use one blank line to separate the arguments from the blocks.
Use empty lines to separate logical groups of arguments within a block.
For blocks that contain both arguments and "meta-arguments" (as defined by the Terraform language semantics), list meta-arguments first and separate them from other arguments with one blank line. Place meta-argument blocks last and separate them from other blocks with one blank line.
resource "aws_instance" "example" {
count = 2 # meta-argument first
ami = "abc123"
instance_type = "t2.micro"
network_interface {
# ...
}
lifecycle { # meta-argument block last
create_before_destroy = true
}
}
Top-level blocks should always be separated from one another by one blank line. Nested blocks should also be separated by blank lines, except when grouping together related blocks of the same type (like multiple provisioner blocks in a resource).
Avoid separating multiple blocks of the same type with other blocks of a different type, unless the block types are defined by semantics to form a family. (For example: root_block_device, ebs_block_device and ephemeral_block_device on aws_instance form a family of block types describing AWS block devices, and can therefore be grouped together and mixed.)

 

NEW QUESTION 170
You want to use different AMI images for different regions and for the purpose you have defined following code block.
1.variable "images"
2.{
3. type = "map"
4.
5. default = {
6. us-east-1 = "image-1234"
7. us-west-2 = "image-4567"
8. us-west-1 = "image-4589"
9. }
10.}
What of the following approaches needs to be followed in order to select image-4589?

  • A. var.images[3]
  • B. lookup(var.images["us-west-1"]
  • C. var.images[2]
  • D. var.images["us-west-1"]

Answer: D

 

NEW QUESTION 171
Module variable assignments are inherited from the parent module and do not need to be explicitly set.

  • A. False
  • B. True

Answer: A

 

NEW QUESTION 172
Your company has been using Terraform Cloud for a some time now . But every team is creating their own modules , and there is no standardization of the modules , with each team creating the resources in their own unique way . You want to enforce a standardization of the modules across the enterprise . What should be your approach.

  • A. Upload the modules in the terraform public module registry , and ask teams to reference them
  • B. Upgrade to Terraform enterprise , since this is not possible in terraform cloud.
  • C. Implement a Private module registry in Terraform cloud , and ask teams to reference them.
  • D. Create individual workspaces for each team , and ask them to share modules across workspaces.

Answer: C

Explanation:
Terraform Cloud's private module registry helps you share Terraform modules across your organization. It includes support for module versioning, a searchable and filterable list of available modules, and a configuration designer to help you build new workspaces faster.
By design, the private module registry works much like the public Terraform Registry. If you're already used the public registry, Terraform Cloud's registry will feel familiar.
Understand the different offerings in Terraform OS, Terraform Cloud and Terraform Enterprise. Terraform Cloud's private module registry helps you share Terraform modules across your organization.
https://www.terraform.io/docs/cloud/registry/index.html
https://www.terraform.io/docs/cloud/registry/publish.html

 

NEW QUESTION 173
A colleague has informed you that a new version of a Terraform module that your team hosts on an Amazon S3 bucket is broken. The Amazon S3 bucket has versioning enabled. Your colleague tells you to make sure you are not using the latest version in your configuration. You have the following configuration block in your code that refers to the module:
module "infranet" { source = "s3::https://s3-us-west-2.amazonaws.com/infrabucket/infra_module.zip"} What is the best way to ensure that you are not using the latest version of the module?

  • A. Delete the latest version of the module in S3 to rollback to the previous version.
  • B. Add a version property to the module in Terraform's state file and specify a previous version.
  • C. Add a module version constraint in your configuration's backend block and specify a previous version.
  • D. Add a version key to the module configuration and specify a previous version.

Answer: A

Explanation:
Only Terraform Registries support module versioning by using the version key, one cannot configure a previous version of the module in the configuration. Deleting the latest version of the module in S3 is the only option of the available options that ensures you won't use the latest version. You could also modify the source URL to specify a versionId URL parameter for a previous version.
https://www.terraform.io/docs/configuration/modules.html#source

 

NEW QUESTION 174
What is the name assigned by Terraform to reference this resource?

  • A. azurerm
  • B. test
  • C. azurerm_resource_group
  • D. dev

Answer: B

 

NEW QUESTION 175
Which option can not be used to keep secrets out of Terraform configuration files?

  • A. Environment variables
  • B. A -var flag
  • C. A Terraform provider
  • D. secure string

Answer: B

Explanation:
Explanation/Reference: https://secrethub.io/blog/secret-management-for-terraform/

 

NEW QUESTION 176
How is terraform import run?

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

Answer: D

 

NEW QUESTION 177
Terraform providers are always installed from the Internet.

  • A. False
  • B. True

Answer: A

Explanation:
Terraform configurations must declare which providers they require, so that Terraform can install and use them.

 

NEW QUESTION 178
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 PCI/HIPPA compliant.
  • B. The module must be on GitHub and must be a public repo.
  • C. The registry uses tags to identify module versions.
  • D. Module repositories must use this three-part name format, terraform-- .
  • E. Release tag names must be for the format x.y.z, and can optionally be prefixed with a v .

Answer: B,C,E

Explanation:
Explanation
https://www.terraform.io/docs/registry/modules/publish.html#requirements

 

NEW QUESTION 179
Terraform-specific settings and behaviors are declared in which configuration block type?

  • A. resource
  • B. provider
  • C. terraform
  • D. data

Answer: C

Explanation:
Explanation
The special terraform configuration block type is used to configure some behaviors of Terraform itself, such as requiring a minimum Terraform version to apply your configuration.
Example
terraform {
required_version = "> 0.12.0"
}
https://www.terraform.io/docs/configuration/terraform.html

 

NEW QUESTION 180
What command does Terraform require the first time you run it within a configuration directory?

  • A. terraform init
  • B. terraform import
  • C. terraform workspace
  • D. terraform plan

Answer: A

Explanation:
terraform init command is used to initialize a working directory containing Terraform configuration files.
Reference: https://www.terraform.io/docs/cli/commands/init.html

 

NEW QUESTION 181
......

All TA-002-P Dumps and Training Courses: https://www.prep4pass.com/TA-002-P_exam-braindumps.html

Help candidates to study and pass the HashiCorp Certified: Terraform Associate Exams hassle-free: https://drive.google.com/open?id=1kRYGi-MWKeCzfAXmQb_yAdeR8B42x1SW