stepfunctions: Generated Policy for StateMachine Incorrect for StepFunctionsStartExecution step with Aliasing/Versioning
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When Creating a StateMachine construct that has a StepFunctionsStartExecution step that starts a state machine with an alias the generated policy is not correct.
```typescript
const startStateMachineAlias = new StepFunctionsStartExecution(stack, 'StartStepFunctionAlias', {
stateMachine: StateMachine.fromStateMachineArn(stack, 'StateMachineAlias', 'arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1:alias'),
});
new StateMachine(stack, 'StateMachine', {
stateMachineEntryPoint: startStateMachineAlias,
});
```
the created policy will have a statement that looks like
```json
{
"Action": "states:StartExecution",
"Effect": "Allow",
"Resource": "arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1:alias",
}
```
### Expected Behavior
Based on the [AWS doc](https://docs.aws.amazon.com/step-functions/latest/dg/auth-version-alias.html) For executing aliases or versions you need to have a policy statement that looks like this
```json
{
"Action": "states:StartExecution",
"Effect": "Allow",
"Resource": "arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1",
}
```
or this
```json
{
"Action": "states:StartExecution",
"Effect": "Allow",
"Resource": "arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1",
"Condition": {
"ForAnyValue:StringEquals": {
"states:StateMachineQualifier": [
"alias"
]
}
}
}
```
### Current Behavior
the created policy looks like this which is incorrect for executing an alias
```json
{
"Action": "states:StartExecution",
"Effect": "Allow",
"Resource": "arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1:alias",
}
```
### Reproduction Steps
Create a StateMachine Construct that has a step that calls another state machine
```typescript
const startStateMachineAlias = new StepFunctionsStartExecution(stack, 'StartStepFunctionAlias', {
stateMachine: StateMachine.fromStateMachineArn(stack, 'StateMachineAlias', 'arn:aws:states:us-west-2:12345678900:stateMachine:stateMachine1:alias'),
});
new StateMachine(stack, 'StateMachine', {
stateMachineEntryPoint: startStateMachineAlias,
});
```
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### CDK CLI Version
2.115.0
### Framework Version
_No response_
### Node.js Version
18
### OS
Amazon Linux 2
### Language
TypeScript
### Language Version
4.9.5
### Other information
_No response_
Contributor guide
Research direction
Start with the StepFunctionsStartExecution and StateMachine.fromStateMachineArn constructs shown in the reproduction, then synthesize the example to inspect its generated IAM policy. Compare the policy for an aliased state machine with the AWS authorization documentation; done means the generated statement matches one of the documented valid forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100