-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stepfunctions: using itemProcessor
with mode = DISTRIBUTED
doesn't work out of the box due to permission error
#28820
Comments
Thank you. Can you share the full error messages? |
|
This should work in the meantime: const policy = new Policy(this, 'sfn-map-policy', {
document: new PolicyDocument({
statements: [new PolicyStatement({ resources: [machine.stateMachineArn], actions: ['states:StartExecution'] })],
}),
})
policy.attachToRole(machine.role) |
The new Distributed Map construct should also work - #28821 |
I have this issue and am using a I attempted this: self.state_machine.add_to_role_policy(
iam.PolicyStatement(
actions=["states:StartExecution"],
resources=[self.state_machine.state_machine_arn],
),
) But I get |
...but the form given by @rogerchi does work instead policy = iam.Policy(
self,
"sfn-map-policy",
document=iam.PolicyDocument(
statements=[
iam.PolicyStatement(
resources=[self.state_machine.state_machine_arn],
actions=["states:StartExecution"],
),
iam.PolicyStatement(
resources=[
f"arn:aws:states:*:{Aws.ACCOUNT_ID}:execution:{self.state_machine.state_machine_name}/*"
],
actions=["states:RedriveExecution"],
),
],
),
)
policy.attach_to_role(self.state_machine.role) I had to add another missing permission, to allow re-driving failed distributed map run. Maybe there are other missing perms that I haven't run into yet. Anyway, the point is that |
Relevant docs: https://docs.aws.amazon.com/step-functions/latest/dg/iam-policies-eg-dist-map.html Seems like at a minimum, you want:
Also, if you have a resultWriter S3 bucket, you'll need all the various permissions mentioned in the doc above for the bucket. |
I see that the PR that added the /**
* Binds this StateGraph to the StateMachine it defines and updates state machine permissions
*/
public bind(stateMachine: StateMachine) {
for (const state of this.allStates) {
if (DistributedMap.isDistributedMap(state)) {
stateMachine.role.attachInlinePolicy(new iam.Policy(stateMachine, 'DistributedMapPolicy', {
document: new iam.PolicyDocument({
statements: [
new iam.PolicyStatement({
actions: ['states:StartExecution'],
resources: [stateMachine.stateMachineArn],
}),
new iam.PolicyStatement({
actions: ['states:DescribeExecution', 'states:StopExecution'],
resources: [`${stateMachine.stateMachineArn}:*`],
}),
],
}),
}));
break;
}
}
} But I'm still hitting errors like the following at runtime:
I have no cc @abdelnn |
Describe the bug
Deploying a map state in a state machine using distributed processing mode (and standard execution type for the child executions) causes an IAM permissions issue since the parent state machine role doesn't have permission to start executions on itself. Trying to grant permissions via
stateMachine.grantStartExecution(stateMachine)
causes a circular dependency.Expected Behavior
When using distributed processing mode, necessary permissions should be generated by default.
Current Behavior
Start execution permission for the child executions is not granted to the parent state machine.
Reproduction Steps
Possible Solution
Automatically add the necessary IAM policy to the parent state machine's default role
Additional Information/Context
No response
CDK CLI Version
2.122.0 (build 7e77e02)
Framework Version
No response
Node.js Version
v18.16.1
OS
MacOS Sonoma 14.0 (M2 Pro)
Language
TypeScript
Language Version
No response
Other information
technically I am using vanilla JS CDK language but that's not an option in the language dropdown.
The text was updated successfully, but these errors were encountered: