Skip to content

Commit

Permalink
swap back to dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
coilysiren committed Oct 18, 2024
1 parent 9dc57c6 commit 1f21df2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
32 changes: 20 additions & 12 deletions infra/modules/service/events_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ resource "aws_iam_policy" "run_task" {
}

data "aws_iam_policy_document" "run_task" {

statement {
sid = "StepFunctionsEvents"
actions = [
Expand All @@ -39,19 +40,26 @@ data "aws_iam_policy_document" "run_task" {
resources = ["arn:aws:events:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"]
}

statement {
actions = [
"states:StartExecution",
]
resources = [for job in aws_sfn_state_machine.file_upload_jobs : "${job.arn}"]
}
dynamic "statement" {
for_each = aws_sfn_state_machine.file_upload_jobs

statement {
actions = [
"states:DescribeExecution",
"states:StopExecution",
]
resources = [for job in aws_sfn_state_machine.file_upload_jobs : "${job.arn}:*"]
content {
actions = [
"states:StartExecution",
]
resources = [statement.value.arn]
}
}

dynamic "statement" {
for_each = aws_sfn_state_machine.file_upload_jobs

content {
actions = [
"states:DescribeExecution",
"states:StopExecution",
]
resources = ["${statement.value.arn}:*"]
}
}
}
30 changes: 19 additions & 11 deletions infra/modules/service/scheduler_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,26 @@ data "aws_iam_policy_document" "scheduler" {
resources = ["arn:aws:events:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"]
}

statement {
actions = [
"states:StartExecution",
]
resources = [for job in aws_sfn_state_machine.scheduled_jobs : "${job.arn}"]
dynamic "statement" {
for_each = aws_sfn_state_machine.scheduled_jobs

content {
actions = [
"states:StartExecution",
]
resources = [statement.value.arn]
}
}

statement {
actions = [
"states:DescribeExecution",
"states:StopExecution",
]
resources = [for job in aws_sfn_state_machine.scheduled_jobs : "${job.arn}:*"]
dynamic "statement" {
for_each = aws_sfn_state_machine.scheduled_jobs

content {
actions = [
"states:DescribeExecution",
"states:StopExecution",
]
resources = ["${statement.value.arn}:*"]
}
}
}

0 comments on commit 1f21df2

Please sign in to comment.