Skip to content

Commit 698e4c1

Browse files
authored
feat: Added default resources for events permissions (#34)
1 parent 3f974cc commit 698e4c1

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ EOF
4646
lambda = {
4747
lambda = ["arn:aws:lambda:eu-west-1:123456789012:function:test1", "arn:aws:lambda:eu-west-1:123456789012:function:test2"]
4848
}
49+
50+
stepfunction_Sync = {
51+
stepfunction = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
52+
stepfunction_Wildcard = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
53+
54+
# Set to true to use the default events (otherwise, set this to a list of ARNs; see the docs linked in locals.tf
55+
# for more information). Without events permissions, you will get an error similar to this:
56+
# Error: AccessDeniedException: 'arn:aws:iam::xxxx:role/step-functions-role' is not authorized to
57+
# create managed-rule
58+
events = true
59+
}
4960
}
5061
5162
type = "STANDARD"

examples/complete/main.tf

+11
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ module "step_function" {
6666
xray = true
6767
}
6868

69+
stepfunction_Sync = {
70+
stepfunction = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
71+
stepfunction_Wildcard = ["arn:aws:states:eu-west-1:123456789012:stateMachine:test1"]
72+
73+
# Set to true to use the default events (otherwise, set this to a list of ARNs; see the docs linked in locals.tf
74+
# for more information). Without events permissions, you will get an error similar to this:
75+
# Error: AccessDeniedException: 'arn:aws:iam::xxxx:role/step-functions-role' is not authorized to
76+
# create managed-rule
77+
events = true
78+
}
79+
6980
# # NB: This will "Deny" everything (including logging)!
7081
# no_tasks = {
7182
# deny_all = true

locals.tf

+11
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ locals {
211211
"events:DescribeRule"
212212
]
213213
}
214+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForBatchJobsRule"]
214215
}
215216

216217
batch_WaitForTaskToken = {
@@ -269,6 +270,7 @@ locals {
269270
"events:PutRule",
270271
"events:DescribeRule"
271272
]
273+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForECSTaskRule"]
272274
}
273275
}
274276

@@ -352,6 +354,7 @@ locals {
352354
"events:DescribeRule"
353355
]
354356
}
357+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForSageMakerTrainingJobsRule"]
355358
}
356359

357360
sagemaker_CreateTrainingJob_WaitForTaskToken = {
@@ -417,6 +420,7 @@ locals {
417420
"events:PutRule",
418421
"events:DescribeRule"
419422
]
423+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForSageMakerTransformJobsRule"]
420424
}
421425
}
422426

@@ -464,6 +468,7 @@ locals {
464468
"events:PutRule",
465469
"events:DescribeRule"
466470
]
471+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRAddJobFlowStepsRule"]
467472
}
468473
}
469474

@@ -497,6 +502,7 @@ locals {
497502
"events:PutRule",
498503
"events:DescribeRule"
499504
]
505+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRRunJobFlowRule"]
500506
}
501507
}
502508

@@ -541,6 +547,7 @@ locals {
541547
"events:DescribeRule"
542548
]
543549
}
550+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventForEMRTerminateJobFlowsRule"]
544551
}
545552

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

565573
codebuild_StartBuild = {
@@ -711,6 +719,7 @@ locals {
711719
"events:PutRule",
712720
"events:DescribeRule"
713721
]
722+
default_resources = ["arn:aws:events:${local.aws_region}:${data.aws_caller_identity.current.account_id}:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule"]
714723
}
715724
}
716725

@@ -743,3 +752,5 @@ locals {
743752

744753
}
745754
}
755+
756+
data "aws_caller_identity" "current" {}

0 commit comments

Comments
 (0)