-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.tf
28 lines (26 loc) · 1.11 KB
/
ecs.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# cluster
resource "aws_ecs_cluster" "example-cluster" {
name = "example-cluster"
}
resource "aws_launch_configuration" "ecs-example-launchconfig" {
name_prefix = "ecs-launchconfig"
image_id = "${lookup(var.ECS_AMIS, var.AWS_REGION)}"
instance_type = "${var.ECS_INSTANCE_TYPE}"
key_name = "${aws_key_pair.mykeypair.key_name}"
iam_instance_profile = "${aws_iam_instance_profile.ecs-ec2-role.id}"
security_groups = ["${aws_security_group.ecs-securitygroup.id}"]
user_data = "#!/bin/bash\necho 'ECS_CLUSTER=example-cluster' > /etc/ecs/ecs.config\nstart ecs"
lifecycle { create_before_destroy = true }
}
resource "aws_autoscaling_group" "ecs-example-autoscaling" {
name = "ecs-example-autoscaling"
vpc_zone_identifier = ["${aws_subnet.main-public-1.id}", "${aws_subnet.main-public-2.id}"]
launch_configuration = "${aws_launch_configuration.ecs-example-launchconfig.name}"
min_size = 1
max_size = 1
tag {
key = "Name"
value = "ecs-ec2-container"
propagate_at_launch = true
}
}