aws / aws/aws-cdk

(aws_stepfunctions_tasks): (Incorrect service name in generated IAM role for step function excecution)

Open
#23,824 6 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-stepfunctions-tasks bug documentation effort/small p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When using the `CallAwsService` construct to call the startExecution action, the automatically generated IAM policy has `sfn` as the service name instead of the expected `states` service name

### Expected Behavior

Expected the IAM policy to have the correct service name, eg

`"Action": "states:startExecution"`

### Current Behavior

IAM policy instead has the incorrect service name e.g
`"Action": "sfn:startExecution"`

### Reproduction Steps

```
const executeStateMachine = new sfntasks.CallAwsService(this, "executeStateMachine", {
service: 'sfn',
action: "startExecution",
parameters: {
StateMachineArn: stateMachine.stateMachineArn,
Input: {
"StatePayload": "Hello from Step Functions!",
"AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$": "$$.Execution.Id"
}
},
iamResources: ['*']
});
```

### Possible Solution

CallAwsServiceProps state that `iamResources` will be set as `service:action` by default
Assuming the `service` referenced here is the `service` value in the props it will be incorrect in the case of the step function service

### Additional Information/Context

_No response_

### CDK CLI Version

2.61.1 (build d319d9c)

### Framework Version

_No response_

### Node.js Version

v16.17.1

### OS

macOS Monterey

### Language

Typescript

### Language Version

_No response_

### Other information

Thanks for your consideration, this is the first time I've logged a bug anywhere so hopefully I given the correct information.

I should say I was able to work around it with the following
```
additionalIamStatements: [new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['states:startExecution'],
resources: [],
})]
```
Edit: Have noticed the same problem with sesv2 as well (iam policy should be `ses` not `sesv2`)

Contributor guide

Open the contributing guide

Research direction

Start at the CallAwsService construct and its generated IAM policy handling, using the reproduction for startExecution as the entry point. Check how service names are mapped for sfn and sesv2, then add regression coverage showing that the generated actions use states:startExecution and the corresponding ses service name.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
authorization, cloud, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.