-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathecs-ec2.tf
45 lines (38 loc) · 1.27 KB
/
ecs-ec2.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
resource "aws_autoscaling_group" "drone_agent" {
name = "drone-agent"
vpc_zone_identifier = ["${aws_subnet.drone_a.id}", "${aws_subnet.drone_c.id}"]
min_size = "1"
max_size = "3"
desired_capacity = "${var.drone_desired_count_agent}"
launch_configuration = "${aws_launch_configuration.app.name}"
}
data "template_file" "cloud_config" {
template = "${file("${path.module}/cloud-config.yml")}"
vars {
ecs_cluster_name = "${aws_ecs_cluster.drone.name}"
}
}
data "aws_ami" "stable_coreos" {
filter {
name = "image-id"
values = ["${lookup(var.amis, var.aws_region)}"]
}
}
resource "aws_key_pair" "drone" {
key_name_prefix = "drone"
public_key = "${var.ssh_public_key}"
}
resource "aws_launch_configuration" "app" {
security_groups = [
"${aws_security_group.ec2_sg.id}",
]
key_name = "${aws_key_pair.drone.key_name}"
image_id = "${data.aws_ami.stable_coreos.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${aws_iam_instance_profile.drone.name}"
user_data = "${data.template_file.cloud_config.rendered}"
associate_public_ip_address = true
lifecycle {
create_before_destroy = true
}
}