File tree 3 files changed +34
-8
lines changed
3 files changed +34
-8
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ ecs_additional_iam_statements = [
93
93
| cluster_arn | The ECS cluster ARN |
94
94
| cluster_asg_name | The ECS cluster Auto Scaling Group name, used to attach Auto Scaling Policies |
95
95
| cluster_asg_arn | The ECS cluster Auto Scaling Group arn, used for ECS capacity providers |
96
+ | cluster_aws_launch_configuration_name | The ECS cluster AutoScaling Group aws_launch_configuration Name |
96
97
| cluster_iam_role_arn | The ECS cluster IAM role ARN, useful for attaching to ECR repos |
97
98
98
99
## Authors
Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ data "template_file" "user_data" {
18
18
template = file (" ${ path . module } /user_data.tpl" )
19
19
vars = {
20
20
ecs_cluster_name = var.ecs_name
21
- efs_id = var.efs_id
22
- http_proxy = var.http_proxy
23
- http_proxy_port = var.http_proxy_port
21
+ efs_id = var.efs_id
22
+ http_proxy = var.http_proxy
23
+ http_proxy_port = var.http_proxy_port
24
24
}
25
25
}
26
26
@@ -81,6 +81,21 @@ resource "aws_ecs_cluster" "this" {
81
81
depends_on = [aws_ecs_capacity_provider . this ]
82
82
}
83
83
84
+ # #NB: https://github.com/hashicorp/terraform-provider-aws/issues/4852
85
+ # # The Cluster cannot be deleted/renamed while Container Instances are active or draining.
86
+ resource "null_resource" "asg-scale-to-0-on-destroy" {
87
+ triggers = {
88
+ cluster_arn = aws_ecs_cluster.this.arn
89
+ capacity_providers_arn = join (" ," , aws_ecs_cluster. this . capacity_providers )
90
+ asg_name = aws_autoscaling_group.this.name
91
+ }
92
+ provisioner "local-exec" {
93
+ when = destroy
94
+ command = " aws autoscaling update-auto-scaling-group --auto-scaling-group-name ${ self . triggers . asg_name } --min-size 0 --max-size 0 --desired-capacity 0"
95
+ }
96
+ depends_on = [aws_ecs_cluster . this ]
97
+ }
98
+
84
99
resource "aws_autoscaling_group" "this" {
85
100
name = var. ecs_name
86
101
min_size = var. ecs_min_size
Original file line number Diff line number Diff line change 2
2
# Outputs
3
3
# ------------------------------------------------------------------------------
4
4
output "cluster_id" {
5
- value = aws_ecs_cluster. this . id
5
+ description = " Cluster ID"
6
+ value = aws_ecs_cluster. this . id
6
7
}
7
8
8
9
output "cluster_arn" {
9
- value = aws_ecs_cluster. this . arn
10
+ description = " Cluster ARN"
11
+ value = aws_ecs_cluster. this . arn
10
12
}
11
13
12
14
output "cluster_asg_name" {
13
- value = aws_autoscaling_group. this . name
15
+ description = " Cluster AutoScaling Group Name"
16
+ value = aws_autoscaling_group. this . name
14
17
}
15
18
16
19
output "cluster_asg_arn" {
17
- value = aws_autoscaling_group. this . arn
20
+ description = " Cluster AutoScaling Group ARN"
21
+ value = aws_autoscaling_group. this . arn
18
22
}
19
23
20
24
output "cluster_iam_role_arn" {
21
- value = aws_iam_role. this . arn
25
+ description = " Cluster IAM role ARN"
26
+ value = aws_iam_role. this . arn
27
+ }
28
+
29
+ output "cluster_aws_launch_configuration_name" {
30
+ description = " Cluster AutoScaling Group aws_launch_configuration Name"
31
+ value = aws_launch_configuration. this . name
22
32
}
You can’t perform that action at this time.
0 commit comments