Skip to content

Commit

Permalink
Merge pull request #24 from FitnessKeeper/casper-add-tags
Browse files Browse the repository at this point in the history
Add Tag Support
  • Loading branch information
Falpangaea authored Jul 17, 2020
2 parents 117f1e2 + 327a0a6 commit 0ec4de2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
15 changes: 3 additions & 12 deletions alb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ resource "aws_alb" "service" {
prefix = coalesce(var.lb_prefix_override, "${var.lb_log_prefix}/${var.service_identifier}/${var.task_identifier}")
}

tags = {
VPC = data.aws_vpc.vpc.tags["Name"]
Application = aws_ecs_task_definition.task.family
}
tags = var.tags
}

resource "aws_alb_listener" "service_https" {
Expand Down Expand Up @@ -79,10 +76,7 @@ resource "aws_alb_target_group" "service" {
cookie_duration = var.alb_cookie_duration
}

tags = {
VPC = data.aws_vpc.vpc.tags["Name"]
Application = aws_ecs_task_definition.task.family
}
tags = var.tags
}

resource "aws_security_group" "alb" {
Expand All @@ -91,10 +85,7 @@ resource "aws_security_group" "alb" {
description = "Security group for ${var.service_identifier}-${var.task_identifier} ALB"
vpc_id = data.aws_vpc.vpc.id

tags = {
VPC = data.aws_vpc.vpc.tags["Name"]
Application = aws_ecs_task_definition.task.family
}
tags = var.tags
}

resource "aws_security_group_rule" "alb_ingress_https" {
Expand Down
4 changes: 4 additions & 0 deletions ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ resource "aws_ecs_task_definition" "task" {
name = "data"
host_path = var.ecs_data_volume_path
}

tags = var.tags
}

resource "aws_ecs_service" "service" {
Expand Down Expand Up @@ -64,6 +66,8 @@ resource "aws_ecs_service" "service" {
aws_alb_listener.service_http,
aws_iam_role.service,
]

tags = var.tags
}

resource "aws_cloudwatch_log_group" "task" {
Expand Down
4 changes: 4 additions & 0 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ resource "aws_iam_role" "task" {
name_prefix = "${var.service_identifier}-${var.task_identifier}-ecsTaskRole"
path = "/${var.service_identifier}/"
assume_role_policy = data.aws_iam_policy_document.assume_role_task.json

tags = var.tags
}

resource "aws_iam_role_policy" "task" {
Expand All @@ -63,6 +65,8 @@ resource "aws_iam_role" "service" {
name_prefix = "${var.service_identifier}-${var.task_identifier}-ecsServiceRole"
path = "/${var.service_identifier}/"
assume_role_policy = data.aws_iam_policy_document.assume_role_service.json

tags = var.tags
}

resource "aws_iam_role_policy_attachment" "service" {
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,8 @@ variable "alb_deregistration_delay" {
description = "The amount of time in seconds to wait before deregistering a target from a target group."
default = "300"
}

variable "tags" {
description = "Map of tags for everything but an ALB."
default = {}
}

0 comments on commit 0ec4de2

Please sign in to comment.