Skip to content

Commit

Permalink
feat: Added default resources for events permissions (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Octogonapus authored Apr 11, 2022
1 parent 3f974cc commit 698e4c1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ EOF
lambda = {
lambda = ["arn:aws:lambda:eu-west-1:123456789012:function:test1", "arn:aws:lambda:eu-west-1:123456789012:function:test2"]
}
stepfunction_Sync = {
stepfunction = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
stepfunction_Wildcard = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
# Set to true to use the default events (otherwise, set this to a list of ARNs; see the docs linked in locals.tf
# for more information). Without events permissions, you will get an error similar to this:
# Error: AccessDeniedException: 'arn:aws:iam::xxxx:role/step-functions-role' is not authorized to
# create managed-rule
events = true
}
}
type = "STANDARD"
Expand Down
11 changes: 11 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ module "step_function" {
xray = true
}

stepfunction_Sync = {
stepfunction = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
stepfunction_Wildcard = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]

# Set to true to use the default events (otherwise, set this to a list of ARNs; see the docs linked in locals.tf
# for more information). Without events permissions, you will get an error similar to this:
# Error: AccessDeniedException: 'arn:aws:iam::xxxx:role/step-functions-role' is not authorized to
# create managed-rule
events = true
}

# # NB: This will "Deny" everything (including logging)!
# no_tasks = {
# deny_all = true
Expand Down
11 changes: 11 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ locals {
"events:DescribeRule"
]
}
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForBatchJobsRule"]
}

batch_WaitForTaskToken = {
Expand Down Expand Up @@ -269,6 +270,7 @@ locals {
"events:PutRule",
"events:DescribeRule"
]
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForECSTaskRule"]
}
}

Expand Down Expand Up @@ -352,6 +354,7 @@ locals {
"events:DescribeRule"
]
}
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForSageMakerTrainingJobsRule"]
}

sagemaker_CreateTrainingJob_WaitForTaskToken = {
Expand Down Expand Up @@ -417,6 +420,7 @@ locals {
"events:PutRule",
"events:DescribeRule"
]
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForSageMakerTransformJobsRule"]
}
}

Expand Down Expand Up @@ -464,6 +468,7 @@ locals {
"events:PutRule",
"events:DescribeRule"
]
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRAddJobFlowStepsRule"]
}
}

Expand Down Expand Up @@ -497,6 +502,7 @@ locals {
"events:PutRule",
"events:DescribeRule"
]
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRRunJobFlowRule"]
}
}

Expand Down Expand Up @@ -541,6 +547,7 @@ locals {
"events:DescribeRule"
]
}
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRTerminateJobFlowsRule"]
}

# https://docs.aws.amazon.com/step-functions/latest/dg/codebuild-iam.html
Expand All @@ -560,6 +567,7 @@ locals {
"events:DescribeRule"
]
}
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForCodeBuildStartBuildRule"]
}

codebuild_StartBuild = {
Expand Down Expand Up @@ -711,6 +719,7 @@ locals {
"events:PutRule",
"events:DescribeRule"
]
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"]
}
}

Expand Down Expand Up @@ -743,3 +752,5 @@ locals {

}
}

data "aws_caller_identity" "current" {}

0 comments on commit 698e4c1

Please sign in to comment.