Skip to content

Commit

Permalink
add back the unique_name
Browse files Browse the repository at this point in the history
I had hoped that it would be possible to preserve existing resources, but only a few were saved.
  • Loading branch information
briskt committed Sep 9, 2024
1 parent 904c683 commit 7842dd5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions terraform/task/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

locals {
unique_name = "${var.name}-${random_id.name_suffix.b64_url}"
}

resource "random_id" "name_suffix" {
byte_length = 6
}

resource "aws_iam_role" "this" {
name = "ecs_events-${var.name}"
name = "ecs_events-${local.unique_name}"

assume_role_policy = jsonencode({
Version = "2012-10-17"
Expand Down Expand Up @@ -43,15 +47,15 @@ resource "aws_iam_role_policy" "this" {
}

resource "aws_cloudwatch_event_rule" "this" {
name = var.name
name = local.unique_name
description = var.event_rule_description == "" ? "Start ${var.name} task" : var.event_rule_description
schedule_expression = var.event_schedule
is_enabled = var.enable
tags = var.tags
}

resource "aws_cloudwatch_event_target" "this" {
target_id = var.name
target_id = local.unique_name
rule = aws_cloudwatch_event_rule.this.name
arn = var.ecs_cluster_arn
role_arn = aws_iam_role.this.arn
Expand Down

0 comments on commit 7842dd5

Please sign in to comment.