Tenth Flashcards Preview

P211A000N02F > Tenth > Flashcards

Flashcards in Tenth Deck (5)
Loading flashcards...
1

You have a module stored on a local the local path /home/provision/terraform/modules/my_module.

How can you reference in your Terraform local code? The directory of your terraform local code is/home/provision/terraform/

A. module "whizhlabs" {
source = "./my_module"
}

B. module "whizhlabs" {
source = "./modules/my_module"
}

C. module "whizhlabs" {
source = "my_module"
}

D. B & C

B. module "whizhlabs" {
source = "./modules/my_module"
}

Terraform local path must o start by “.” or “./”

A is incorrect because our module is under the directory “modules” and we have to have one level up

C is incorrect because we are not specifying any path. Just the name of the module

D is incorrect because A and C are incorrect

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

2

You have the following code:

module "whizlabs_exam" {
name = var.name
mark = var.mark
tags = var.tags
}

The module has an output variable called “dns_record”
How can you access to this variable to be used in your terraform code?

A. module.whizlabs_exam.dns_record.output
B. module.whizlabs_exam.output.dns_record
C. output.module.whizlabs_exam.dns_record
D. module.whizlabs_exam.dns_record

D. module.whizlabs_exam.dns_record

The way we access an output variable defined in a module is: module.MODULE_NAME.OUTPUT_NAME

A, B and C are incorrect because the output attribute is not valid when you want to do a reference to an output variable

https://learn.hashicorp.com/tutorials/terraform/module-use

3

What are all the arguments and meta-arguments that you can use in a module block?

A. source and version
B. source, version, providers
C. source, version, count, for_each, providers, and depends_on
D. source, version, count, for_each, providers, and depend_at

C. source, version, count, for_each, providers, and depends_on

The argument source is the only one that is mandatory.

However, you can specify other arguments if you need to create dependencies (depends_on), executed with different providers (providers), or create multiple instances of a module using count or for_each

A is incorrect because there are more meta arguments that you can define, however source is mandatory and version is recommendable

B is incorrect because there are more arguments that you can define

D is incorrect because depend_at is not a meta-argument

https://www.terraform.io/docs/language/modules/syntax.html#meta-arguments

4

You are a DevOps Engineer in a small team of three. You need to use EKS and, instead of writing a module from scratch, you decided to explore the public Terraform Registry.

How would be your code to access the EKS Registry Terraform Module?

A. module "eks" {
source = "hashicorp/eks/aws"
version = "14.0.0"
}

B. module "eks" {
source = "registry.terraform.io/eks/aws"
version = "14.0.0"
}

C. module "eks" {
source = "app.terraform.io/hashicorp/eks/aws"
version = "14.0.0"
}

D. module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "14.0.0"
}

D. module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "14.0.0"
}

Generally, you have to access to check the provision instructions (Right side).

A and B are incorrect because are not following the guidance to provision the module that is documented. When you execute
terraform init the module would not be found

C is incorrect because is trying to access a private registry, and the question was referencing the public Terraform Registry

https://registry.terraorm.io
https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest
https://www.terraform.io/docs/registry/modules/use.html#using-modules
https://www.terraform.io/docs/registry/modules/use.html#private-registry-module-sources

5

One of the main benefits of IaC is versioning. What happens if you don’t specify a version in your module block definition?

A. The latest version will be used
B. An error will occur as you have to specify a version
C. Terraform will be prompt a message listing all the versions available where you have to type which one you want
D. Terraform will be cloned all the versions available but the latest version will be used

A. The latest version will be used

By default, the latest version of the module will be used if you don’t specify a version in the block definition

B is incorrect because this argument is not mandatory

C is incorrect as this is not happening in terraform. When you run terraform init to initialize theterraform directory, this is cloning the module based on a version given (or latest)

D is incorrect because terraform will not clone all the versions of a particular module.

https://www.terraform.io/docs/language/modules/syntax.html#version
https://www.terraform.io/docs/language/modules/syntax.html#calling-a-child-module