diff --git a/.modules/service/module.tf b/.modules/service/module.tf index 6759f5e..98a4f36 100644 --- a/.modules/service/module.tf +++ b/.modules/service/module.tf @@ -1,4 +1,6 @@ data "tfe_outputs" "infrastructure" { organization = "home_assistant" workspace = "infrastructure" -} \ No newline at end of file +} + +data "aws_region" "current" {} diff --git a/.modules/service/policy.tf b/.modules/service/policy.tf index cdbf186..4728dc0 100644 --- a/.modules/service/policy.tf +++ b/.modules/service/policy.tf @@ -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 } @@ -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 -} \ No newline at end of file +}