Skip to content

Instantly share code, notes, and snippets.

@elliotforbes
Created July 3, 2018 20:12
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 elliotforbes/50789b651761c7c6c0b7f4545e80ec7d to your computer and use it in GitHub Desktop.
Save elliotforbes/50789b651761c7c6c0b7f4545e80ec7d to your computer and use it in GitHub Desktop.
resource "aws_autoscaling_group" "example" {
launch_configuration = "${aws_launch_configuration.example.id}"
load_balancers = ["${aws_elb.example.name}"]
availability_zones = ["eu-west-1b", "eu-west-1a"]
min_size = 2
max_size = 5
tag {
key = "Name"
value = "terraform-go-api"
propagate_at_launch = true
}
}
resource "aws_security_group" "elb" {
name = "terraform-go-api"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_elb" "example" {
name = "terraform-go-api"
availability_zones = ["eu-west-1b", "eu-west-1a"]
security_groups = ["${aws_security_group.elb.id}"]
listener {
lb_port = 80
lb_protocol = "http"
instance_port = 80
instance_protocol = "http"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 3
interval = 30
target = "HTTP:80/"
}
}
output "elb_dns_name" {
value = "${aws_elb.example.dns_name}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment