Complete the code to define an output variable in a Terraform module.
output "instance_ip" { value = [1] }
The output value should reference the resource attribute you want to expose, here the public IP of the AWS instance.
Complete the code to access an output from a child module in the root module.
output "db_endpoint" { value = module.database.[1] }
To access a module output, use the exact output name defined in the child module, here 'db_endpoint'.
Fix the error in the output block to correctly expose the subnet ID from the module.
output "subnet_id" { value = [1] description = "Subnet ID from the network module" }
The output should reference the module's output attribute, not a variable or local value.
Fill both blanks to define and access an output named 'bucket_name' from a module.
module "storage" { source = "./modules/storage" } output "bucket_name" { value = module.storage.[1] } # Inside the storage module: output "[2]" { value = aws_s3_bucket.main.bucket }
The output name must be consistent inside the module and when accessed outside. Both blanks should be 'bucket_name'.
Fill all three blanks to correctly define outputs in a module and access them in the root module.
module "web" { source = "./modules/webserver" } output "web_ip" { value = module.web.[1] } # Inside the webserver module: output "[2]" { value = aws_instance.web.public_ip } output "[3]" { value = aws_instance.web.id }
The root module accesses outputs by the exact names defined inside the child module. Here, 'web_ip' and 'instance_id' are the output names inside the module, and 'web_ip' is accessed outside.