Skip to content

Instantly share code, notes, and snippets.

@shreeegupta
Created May 26, 2023 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shreeegupta/aae39144eea2fbb20bf57a238ade60cd to your computer and use it in GitHub Desktop.
Save shreeegupta/aae39144eea2fbb20bf57a238ade60cd to your computer and use it in GitHub Desktop.
outputs.tf
# Outputs
output "web_server_public_ip" {
description = "Public IP of Web Servers"
value = [for i in aws_instance.web_server[*] : i.public_ip]
}
output "ec2_ssh_access" {
description = "SSH Remote Access to the first EC2 instance"
value = "ssh -i ${var.ssh_key}.pem ubuntu@${aws_instance.web_server[0].public_ip}"
}
output "db_name" {
description = "Database Name"
value = aws_db_instance.db_instance.db_name
}
output "db_address" {
description = "The hostname of the RDS instance"
value = aws_db_instance.db_instance.address
}
output "connect_to_database" {
description = "Command to connect to database from EC2"
value = "mysql --host=${aws_db_instance.db_instance.address} --user=${var.db_username} -p"
}
output "alb_public_url" {
description = "Public URL for Application Load Balancer"
value = aws_lb.alb.dns_name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment