-
Notifications
You must be signed in to change notification settings - Fork 12
/
launch_configurations.tf
43 lines (42 loc) · 1.6 KB
/
launch_configurations.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
# Create two launch configs one for ondemand instances and the other for spot.
resource "aws_launch_configuration" "ecs_config_launch_config_spot" {
name_prefix = "${var.cluster_name}_ecs_cluster_spot"
image_id = data.aws_ami.ecs.id
instance_type = var.instance_type_spot
spot_price = var.spot_bid_price
enable_monitoring = true
associate_public_ip_address = true
lifecycle {
create_before_destroy = true
}
user_data = <<EOF
#!/bin/bash
echo ECS_CLUSTER=${var.cluster_name} >> /etc/ecs/ecs.config
echo ECS_INSTANCE_ATTRIBUTES={\"purchase-option\":\"spot\"} >> /etc/ecs/ecs.config
EOF
security_groups = [
aws_security_group.sg_for_ec2_instances.id
]
key_name = var.ssh_key_name
iam_instance_profile = aws_iam_instance_profile.ec2_iam_instance_profile.arn
}
resource "aws_launch_configuration" "ecs_config_launch_config_ondemand" {
name_prefix = "${var.cluster_name}_ecs_cluster_ondemand"
image_id = data.aws_ami.ecs.id
instance_type = var.instance_type_ondemand
enable_monitoring = true
associate_public_ip_address = true
lifecycle {
create_before_destroy = true
}
user_data = <<EOF
#!/bin/bash
echo ECS_CLUSTER=${var.cluster_name} >> /etc/ecs/ecs.config
echo ECS_INSTANCE_ATTRIBUTES={\"purchase-option\":\"ondemand\"} >> /etc/ecs/ecs.config
EOF
security_groups = [
aws_security_group.sg_for_ec2_instances.id
]
key_name = var.ssh_key_name
iam_instance_profile = aws_iam_instance_profile.ec2_iam_instance_profile.arn
}