QuestionQ29

VerifiedTerraform modules

You are updating a child module that contains the following resource block in the Exhibit area on this page. The resource’s public_ip attribute must be accessible from the parent module.

resource “aws_instance” “example” \{  
  ami           = “ami-0a123456789abcdef”  
  instance_type = “t3.micro”  
\}  

How can you satisfy this requirement?

Explanation

A child module exposes resource attributes to its parent through an output block. The output can return aws_instance.example.public_ip, and the parent can reference it with module.<child_module_name>.<output_name>.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!