-
Notifications
You must be signed in to change notification settings - Fork 108
/
ecs.tf
38 lines (35 loc) · 1.18 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
27
28
29
30
31
32
33
34
35
36
37
38
/* SSH key pair */
resource "aws_key_pair" "ecs" {
key_name = "${var.key_name}"
public_key = "${file(var.key_file)}"
}
/**
* Launch configuration used by autoscaling group
*/
resource "aws_launch_configuration" "ecs" {
name = "ecs"
image_id = "${lookup(var.amis, var.region)}"
/* @todo - split out to a variable */
instance_type = "${var.instance_type}"
key_name = "${aws_key_pair.ecs.key_name}"
iam_instance_profile = "${aws_iam_instance_profile.ecs.id}"
security_groups = ["${aws_security_group.ecs.id}"]
iam_instance_profile = "${aws_iam_instance_profile.ecs.name}"
user_data = "#!/bin/bash\necho ECS_CLUSTER=${aws_ecs_cluster.default.name} > /etc/ecs/ecs.config"
}
/**
* Autoscaling group.
*/
resource "aws_autoscaling_group" "ecs" {
name = "ecs-asg"
availability_zones = ["${split(",", var.availability_zones)}"]
launch_configuration = "${aws_launch_configuration.ecs.name}"
/* @todo - variablize */
min_size = 1
max_size = 10
desired_capacity = 1
}
/* ecs service cluster */
resource "aws_ecs_cluster" "default" {
name = "${var.ecs_cluster_name}"
}