Free TA-002-P Exam Braindumps

Pass your HashiCorp Certified: Terraform Associate exam with these free Questions and Answers

Page 15 of 19
QUESTION 66

- (Exam Topic 4)
Terraform configuration (including any module references) can contain only one Terraform provider type.

  1. A. True
  2. B. False

Correct Answer: B

QUESTION 67

- (Exam Topic 4)
Given the Terraform configuration below, in which order will the resources be created?
* 1. resource "aws_instance" "web_server"
* 2. {
* 3. ami = "ami-b374d5a5"
* 4. instance_type = "t2.micro"
* 5. }
* 6. resource "aws_eip" "web_server_ip"
* 7. {
* 8. vpc = true instance = aws_instance.web_server.id
* 9. }

  1. A. aws_eip will be created first aws_instance will be created second
  2. B. aws_eip will be created first aws_instance will be created second
  3. C. Resources will be created simultaneously
  4. D. aws_instance will be created first aws_eip will be created second

Correct Answer: D
Implicit and Explicit Dependencies
By studying the resource attributes used in interpolation expressions, Terraform can automatically infer when one resource depends on another. In the example above, the reference to aws_instance.web_server.id creates an implicit dependency on the aws_instance named web_server.
Terraform uses this dependency information to determine the correct order in which to create the different resources.
# Example of Implicit Dependency resource "aws_instance" "web_server" { ami = "ami-b374d5a5"
instance_type = "t2.micro"
}
resource "aws_eip" "web_server_ip" { vpc = true
instance = aws_instance.web_server.id
}
In the example above, Terraform knows that the aws_instance must be created before the aws_eip. Implicit dependencies via interpolation expressions are the primary way to inform Terraform about these
relationships, and should be used whenever possible.
Sometimes there are dependencies between resources that are not visible to Terraform. The depends_on argument is accepted by any resource and accepts a list of resources to create explicit dependencies for.
For example, perhaps an application we will run on our EC2 instance expects to use a specific Amazon S3 bucket, but that dependency is configured inside the application code and thus not visible to Terraform. In that case, we can use depends_on to explicitly declare the dependency:
# Example of Explicit Dependency
# New resource for the S3 bucket our application will use. resource "aws_s3_bucket" "example" {
bucket = "terraform-getting-started-guide" acl = "private"
}
# Change the aws_instance we declared earlier to now include "depends_on" resource "aws_instance" "example" {
ami = "ami-2757f631" instance_type = "t2.micro"
# Tells Terraform that this EC2 instance must be created only after the
# S3 bucket has been created. depends_on = [aws_s3_bucket.example]
}
https://learn.hashicorp.com/terraform/getting-started/dependencies.html

QUESTION 68

- (Exam Topic 4)
Terraform plan updates your state file.

  1. A. True
  2. B. False

Correct Answer: B
The terraform plan command creates an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure. The plan command alone will not actually carry out the proposed changes, and so you can use this command to check whether the proposed changes match what you expected before you apply the changes or share your changes with your team for broader review. Source: https://www.terraform.io/cli/commands/plan

QUESTION 69

- (Exam Topic 4)
Which is the best way to specify a tag of v1.0.0 when referencing a module stored in Git (for example
git::https://example.com/vpc.git)?

  1. A. Append ref=v1. 0. 0 argument to the source path Most Voted
  2. B. Add version = "1.0.0" parameter to module block
  3. C. Nothing " modules stored on GitHub always default to version 1.0.0
  4. D. Modules stored on GitHub do not support versioning

Correct Answer: A
https://www.terraform.io/language/modules/sources#selecting-a-revision

QUESTION 70

- (Exam Topic 2)
Matt wants to import a manually created EC2 instance into terraform so that he can manage the EC2 instance through terraform going forward. He has written the configuration file of the EC2 instance before importing it to Terraform. Following is the code:
resource "aws_instance" "matt_ec2" { ami = "ami-bg2640de" instance_type = "t2.micro" vpc_security_group_ids = ["sg-6ae7d613", "sg-53370035"] key_name = "mysecret" subnet_id =
"subnet-9e3cfbc5" }
The instance id of that EC2 instance is i-0260835eb7e9bd40 How he can import data of EC2 to state file?

  1. A. terraform import aws_instance.id = i-0260835eb7e9bd40
  2. B. terraform import i-0260835eb7e9bd40
  3. C. terraform import aws_instance.i-0260835eb7e9bd40
  4. D. terraform import aws_instance.matt_ec2 i-0260835eb7e9bd40

Correct Answer: D
https://www.terraform.io/docs/import/usage.html

Page 15 of 19

Post your Comments and Discuss HashiCorp TA-002-P exam with other Community members: