Complete the code to define an output that shows the instance's public IP.
output "instance_ip" { value = [1] }
The output should expose the public IP of the instance, which is accessed via public_ip.
Complete the code to output the database endpoint after creation.
output "db_endpoint" { value = [1] }
The endpoint attribute provides the database connection address, which is useful to expose.
Fix the error in the output block to correctly expose the load balancer DNS name.
output "lb_dns" { value = aws_lb.example.[1] }
The correct attribute to get the load balancer's DNS name is dns_name.
Fill both blanks to output the subnet IDs from a list of subnets.
output "subnet_ids" { value = [for subnet in [1] : subnet.[2]] }
To get all subnet IDs, iterate over the list aws_subnet.example.* and extract the id attribute.
Fill all three blanks to output a map of instance names to their private IPs, filtering only running instances.
output "running_instances" { value = { for i in [1] : i.[2] => i.[3] if i.instance_state.name == "running" } }
This output creates a map from instance names (tags.Name) to their private IPs (private_ip) for instances in the aws_instance.all list that are running.