Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all terraform=true hardcoded tags #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions alb-internal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ resource "aws_lb" "ecs_internal" {
tags = merge(
var.tags,
{
"Terraform" = true,
Name = "ecs-${var.name}-internal"
Name = "ecs-${var.name}-internal"
},
)
}
Expand All @@ -47,12 +46,7 @@ resource "aws_lb_listener" "ecs_https_internal" {
target_group_arn = aws_lb_target_group.ecs_default_https_internal[0].arn
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

resource "aws_lb_listener" "ecs_test_https_internal" {
Expand All @@ -69,12 +63,7 @@ resource "aws_lb_listener" "ecs_test_https_internal" {
#target_group_arn = aws_lb_target_group.ecs_replacement_https[0].arn
target_group_arn = aws_lb_target_group.ecs_default_https_internal[0].arn
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

# Generate a random string to add it to the name of the Target Group
Expand All @@ -92,17 +81,9 @@ resource "aws_lb_target_group" "ecs_default_https_internal" {
port = 80
protocol = "HTTP"
vpc_id = var.vpc_id
tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags

lifecycle {
create_before_destroy = true
}
}



56 changes: 13 additions & 43 deletions alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ resource "aws_lb" "ecs" {
}
}

tags = merge(
var.tags,
{
"Terraform" = true,
"Name" = "ecs-${var.name}"
},
)
tags = merge(var.tags, {
"Name" = "ecs-${var.name}"
})
}

resource "aws_lb_listener" "ecs_https" {
Expand All @@ -47,12 +43,7 @@ resource "aws_lb_listener" "ecs_https" {
target_group_arn = aws_lb_target_group.ecs_default_https[0].arn
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

resource "aws_lb_listener" "ecs_http_redirect" {
Expand All @@ -71,12 +62,7 @@ resource "aws_lb_listener" "ecs_http_redirect" {
status_code = "HTTP_301"
}
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

resource "aws_lb_listener" "ecs_test_https" {
Expand All @@ -93,12 +79,7 @@ resource "aws_lb_listener" "ecs_test_https" {
#target_group_arn = aws_lb_target_group.ecs_replacement_https[0].arn
target_group_arn = aws_lb_target_group.ecs_default_https[0].arn
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

resource "aws_lb_listener" "ecs_test_http_redirect" {
Expand All @@ -117,12 +98,7 @@ resource "aws_lb_listener" "ecs_test_http_redirect" {
status_code = "HTTP_301"
}
}
tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = var.tags
}

# Generate a random string to add it to the name of the Target Group
Expand All @@ -140,12 +116,9 @@ resource "aws_lb_target_group" "ecs_default_http" {
protocol = "HTTP"
vpc_id = var.vpc_id

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = replace(substr("ecs-${var.name}-default-http-${random_string.alb_prefix.result}", 0, 32), "/-+$/", "")
})

lifecycle {
create_before_destroy = true
Expand All @@ -160,12 +133,9 @@ resource "aws_lb_target_group" "ecs_default_https" {
protocol = "HTTP"
vpc_id = var.vpc_id

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = replace(substr("ecs-${var.name}-default-https-${random_string.alb_prefix.result}", 0, 32), "/-+$/", "")
})

lifecycle {
create_before_destroy = true
Expand Down
27 changes: 9 additions & 18 deletions cloutwatch-alarms-alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ resource "aws_cloudwatch_metric_alarm" "alb_500_errors" {
insufficient_data_actions = []
treat_missing_data = "ignore"

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-alb-500-errors"
})
dimensions = {
LoadBalancer = aws_lb.ecs[0].arn_suffix
}
Expand All @@ -43,12 +40,9 @@ resource "aws_cloudwatch_metric_alarm" "alb_400_errors" {
insufficient_data_actions = []
treat_missing_data = "ignore"

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-alb-400-errors"
})
dimensions = {
LoadBalancer = aws_lb.ecs[0].arn_suffix
}
Expand Down Expand Up @@ -88,10 +82,7 @@ resource "aws_cloudwatch_metric_alarm" "alb_latency" {
}
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-alb-latency"
})
}
9 changes: 3 additions & 6 deletions cloutwatch-alarms-asg.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ resource "aws_cloudwatch_metric_alarm" "asg_high_cpu" {
AutoScalingGroupName = aws_autoscaling_group.ecs[0].name
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-asg-high-cpu"
})
}
18 changes: 6 additions & 12 deletions cloutwatch-alarms-ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ resource "aws_cloudwatch_metric_alarm" "ecs_high_memory" {
ClusterName = aws_ecs_cluster.ecs.name
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-high-memory"
})
}

resource "aws_cloudwatch_metric_alarm" "ecs_high_cpu" {
Expand All @@ -48,10 +45,7 @@ resource "aws_cloudwatch_metric_alarm" "ecs_high_cpu" {
ClusterName = aws_ecs_cluster.ecs.name
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
Name = "${try(data.aws_iam_account_alias.current[0].account_alias, var.alarm_prefix)}-ecs-${var.name}-high-cpu"
})
}
8 changes: 2 additions & 6 deletions cloutwatch-alarms-efs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ resource "aws_cloudwatch_metric_alarm" "efs_credits_low" {
FileSystemId = aws_efs_file_system.ecs[0].id
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
})
}
16 changes: 4 additions & 12 deletions ec2-launch-template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ resource "aws_launch_template" "ecs" {
create_before_destroy = true
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
})
}

resource "tls_private_key" "algorithm" {
Expand All @@ -53,10 +49,6 @@ resource "aws_key_pair" "generated_key" {
key_name = "${var.name}-key"
public_key = tls_private_key.algorithm[0].public_key_openssh

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
})
}
10 changes: 3 additions & 7 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ resource "aws_ecs_cluster" "ecs" {
value = var.container_insights ? "enabled" : "disabled"
}

tags = merge(
var.tags,
{
"Terraform" = true
},
)
tags = merge(var.tags, {
})
lifecycle {
ignore_changes = []

}
}

Expand Down
24 changes: 9 additions & 15 deletions efs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ resource "aws_efs_file_system" "ecs" {
}
}

tags = merge(
var.tags,
{
Name = "ecs-${var.name}"
Backup = var.backup
},
)
tags = merge(var.tags, {
Name = "ecs-${var.name}"
Backup = var.backup
})

# lifecycle {
# prevent_destroy = true
Expand All @@ -54,14 +51,11 @@ resource "aws_security_group" "efs" {
description = "for EFS to talk to ECS cluster"
vpc_id = var.vpc_id


tags = merge(
var.tags,
{
Name = "ecs-efs-${var.name}"
Backup = var.backup
},
)

tags = merge(var.tags, {
Name = "ecs-efs-${var.name}"
Backup = var.backup
})
}

resource "aws_security_group_rule" "nfs_from_ecs_to_efs" {
Expand Down
8 changes: 2 additions & 6 deletions iam-codedeploy.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
resource "aws_iam_role" "codedeploy_service" {
count = var.code_deploy ? 1 : 0
name = "codedeploy-service-${var.name}-${data.aws_region.current.name}"
tags = merge(
var.tags,
{
"terraform" = "true"
},
)
tags = merge(var.tags, {
})
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
Expand Down
8 changes: 2 additions & 6 deletions iam-ecs-service.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
resource "aws_iam_role" "ecs_service" {
name = "ecs-service-${var.name}-${data.aws_region.current.name}"
tags = merge(
var.tags,
{
"terraform" = "true"
},
)
tags = merge(var.tags, {
})
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
Expand Down
8 changes: 2 additions & 6 deletions iam-ecs-task.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
resource "aws_iam_role" "ecs_task" {
name = "ecs-task-${var.name}-${data.aws_region.current.name}"
tags = merge(
var.tags,
{
"terraform" = "true"
},
)
tags = merge(var.tags, {
})
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
Expand Down
Loading
Loading