Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 108


FILL BLANK -

In the below configuration, how would you reference the module output vpc_id?

Type your answer in the field provided. The text field is not case sensitive and all variations of the correct answer are accepted.

Show Answer
Correct Answer:

To reference the module output 'vpc_id' in the given configuration, you would use the following syntax: module.vpc.vpc_id. In this syntax, 'module' is the prefix to reference a module, 'vpc' is the name of the module, and 'vpc_id' is the name of the output variable within that module. This allows you to access the 'vpc_id' output from other parts of your Terraform configuration.

Discussion

17 comments
Sign in to comment
Hizumi
Sep 2, 2022

module.vpc.vpc_id Reference: https://cloudcasts.io/course/terraform/community-vpc-module

shopkitty
Sep 8, 2022

it should be module.vpc.vpc_id

TechHero
Jan 19, 2023

To reference the output vpc_id from the above module configuration, you would use the following syntax: module.vpc.vpc_id Here, module is the prefix used to reference outputs from a module, vpc is the name of the module, and vpc_id is the name of the output being referenced.

alec123
Jan 28, 2023

correct

Nunyabiznes
Mar 27, 2023

To reference the vpc_id output of the vpc module in the above configuration, you would use the following syntax: module.vpc.vpc_id This would allow you to reference the vpc_id output from other parts of your Terraform configuration, such as when creating resources that depend on the VPC. For example: resource "aws_subnet" "subnet_1" { vpc_id = module.vpc.vpc_id cidr_block = "10.0.1.0/24" } In this example, the aws_subnet resource is referencing the vpc_id output of the vpc module to ensure that the subnet is created in the correct VPC.

KingFvsher
Sep 15, 2023

You can reference the vpc_id output of a module in Terraform using the module.<MODULE_NAME>.<OUTPUT_NAME> syntax. In this case, if the name of the module block is vpc, you would reference the vpc_id output as module.vpc.vpc_id.

keiffo2
Sep 6, 2022

module.vpc.id

RVivek
Sep 26, 2022

It should be module.vpc.vpc_id

joyboy23
Jul 6, 2023

module.vpc.vpc_id

debabrata6983
Aug 27, 2023

module.vpc.vpc_id

5719d28
Feb 28, 2024

module.vpc.vpc_id

temor
Mar 28, 2024

module.vpc.vpc_id

alexsandroe
Feb 25, 2023

module.vpc.id

Ni33
May 9, 2023

module.vpc.vpc_id

IK912
Jun 18, 2023

module.vpc.vpc_id

abhi6199
Jun 22, 2023

its module.vpc.vpc_id

arunrkaushik
Aug 12, 2023

resource "aws_vpc" "my_vpc" { cidr_block = "10.0.0.0/16" ... } output "vpc_id" { value = aws_vpc.my_vpc.id }

NashP
Feb 2, 2024

To reference the module output `vpc_id` in the given configuration, you would use the following syntax: ```hcl module.vpc.vpc_id ``` This assumes that the output variable `vpc_id` is declared in the "example" module. Replace `vpc` with the actual name you gave to your module. So, if your module is named "vpc," the reference would be: ```hcl module.vpc.vpc_id ``` This syntax allows you to access the output value `vpc_id` from the specified module in your Terraform configuration.