Created
July 3, 2018 14:02
-
-
Save elliotforbes/ddf46060e79a2cea0128288a8af2943e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
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