Skip to content

Commit

Permalink
Create service module policies based on regions they are used in (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
klejejs authored Oct 1, 2024
1 parent 3fb6b0f commit 6ba5554
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .modules/service/module.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
data "tfe_outputs" "infrastructure" {
organization = "home_assistant"
workspace = "infrastructure"
}
}

data "aws_region" "current" {}
6 changes: 3 additions & 3 deletions .modules/service/policy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data "aws_iam_policy_document" "ecs-role-policy" {
}

resource "aws_iam_role" "ecs-execution" {
name = "${var.service_name}-ExecutionRole-role"
name = "${var.service_name}-${data.aws_region.current.name}-ExecutionRole-role"
assume_role_policy = data.aws_iam_policy_document.ecs-role-policy.json
}

Expand Down Expand Up @@ -46,11 +46,11 @@ data "aws_iam_policy_document" "task-assume-role" {
}

resource "aws_iam_role" "task-execution" {
name = "${var.service_name}-TaskRole-role"
name = "${var.service_name}-${data.aws_region.current.name}-TaskRole-role"
assume_role_policy = data.aws_iam_policy_document.task-assume-role.json
}

resource "aws_iam_role_policy" "task-role" {
policy = data.aws_iam_policy_document.task-policy.json
role = aws_iam_role.task-execution.id
}
}

0 comments on commit 6ba5554

Please sign in to comment.