Skip to content

Commit 9ba12af

Browse files
zirkelcclaude
andcommitted
fix(iam): handle Fn::Sub string form in getExecutionArn
Fn::Sub can be a plain string or an array [template, vars]. getExecutionArn() assumed array form, causing string destructuring to produce garbage output like { 'Fn::Sub': ['a:*', 'r'] }. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 86717b7 commit 9ba12af

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,13 @@ function getExecutionArn(stateMachineArn) {
472472
return `${stateMachineArn.replace(':stateMachine:', ':execution:')}:*`;
473473
}
474474
if (stateMachineArn['Fn::Sub']) {
475-
const [template, vars] = stateMachineArn['Fn::Sub'];
475+
const sub = stateMachineArn['Fn::Sub'];
476+
if (typeof sub === 'string') {
477+
return {
478+
'Fn::Sub': `${sub.replace(':stateMachine:', ':execution:')}:*`,
479+
};
480+
}
481+
const [template, vars] = sub;
476482
return {
477483
'Fn::Sub': [
478484
`${template.replace(':stateMachine:', ':execution:')}:*`,

lib/deploy/stepFunctions/compileIamRole.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3392,7 +3392,9 @@ describe('#compileIamRole', () => {
33923392

33933393
const executionPermissions = statements.filter(s => _.isEqual(s.Action, ['states:DescribeExecution', 'states:StopExecution']));
33943394
expect(executionPermissions).to.have.lengthOf(1);
3395-
expect(executionPermissions[0].Resource).to.equal('*');
3395+
expect(executionPermissions[0].Resource).to.deep.eq([{
3396+
'Fn::Sub': 'arn:aws:states:${AWS::Region}:${AWS::AccountId}:execution:HelloStateMachine:*',
3397+
}]);
33963398
});
33973399

33983400
it('should handle ${AWS::Partition} in resource ARN', () => {

0 commit comments

Comments
 (0)