@@ -11,15 +11,27 @@ resource "aws_autoscaling_group" "auto_scaling_group" {
11
11
vpc_zone_identifier = var. subnets
12
12
wait_for_capacity_timeout = " 20m"
13
13
14
- tags = concat ([ var . tags ], [ {
14
+ tag {
15
15
key = " AmazonECSManaged"
16
16
value = " AmazonECSManaged"
17
17
propagate_at_launch = true
18
- }, {
18
+ }
19
+
20
+ tag {
19
21
key = " Name"
20
22
value = var. prefix
21
23
propagate_at_launch = true
22
- }])
24
+ }
25
+
26
+ dynamic "tag" {
27
+ for_each = var. tags
28
+
29
+ content {
30
+ key = tag. key
31
+ value = tag. value
32
+ propagate_at_launch = true
33
+ }
34
+ }
23
35
24
36
timeouts {
25
37
delete = " 15m"
@@ -34,14 +46,14 @@ resource "aws_placement_group" "placement_group" {
34
46
}
35
47
36
48
resource "aws_launch_configuration" "launch_configuration" {
37
- name_prefix = var. prefix
38
- image_id = data. aws_ami . server . id
39
- security_groups = [var . security_group_id ]
40
- instance_type = " t2.medium"
41
- iam_instance_profile = aws_iam_instance_profile. ecs_instance_profile . id
42
- enable_monitoring = true
49
+ name_prefix = var. prefix
50
+ image_id = data. aws_ami . server . id
51
+ security_groups = [var . security_group_id ]
52
+ instance_type = " t2.medium"
53
+ iam_instance_profile = aws_iam_instance_profile. ecs_instance_profile . id
54
+ enable_monitoring = true
43
55
associate_public_ip_address = false
44
- user_data = << DATA
56
+ user_data = << DATA
45
57
Content-Type: multipart/mixed; boundary="==BOUNDARY=="
46
58
MIME-Version: 1.0
47
59
189
201
}
190
202
191
203
data "aws_ami" "server" {
192
- most_recent = true
193
- name_regex = " ^amzn-ami-.*-amazon-ecs-optimized$"
194
- owners = [" amazon" ]
204
+ most_recent = true
205
+ name_regex = " ^amzn-ami-.*-amazon-ecs-optimized$"
206
+ owners = [" amazon" ]
195
207
196
208
filter {
197
209
name = " root-device-type"
0 commit comments