-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(codepipeline): incorrect cross-account permissions with StepFunct ionInvokeAction #25850
Conversation
…ionInvokeAction When the StateMachine being invoked by CodePipeline is not in the same account/region as the CodePipeline, the `DescribeExecutions` permission was granted on the incorrect account/region pair (that of the pipeline, and not that of the StateMachine), due to the transforming of the state machine's ARN into a state machine execution ARN pattern not copying the account & region of the original ARN.
[ | ||
'arn:', | ||
{ 'Fn::Select': [1, arnParts] }, | ||
':states:', | ||
{ 'Fn::Select': [3, arnParts] }, | ||
':', | ||
{ 'Fn::Select': [4, arnParts] }, | ||
':execution:', | ||
{ 'Fn::Select': [6, arnParts] }, | ||
':*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion has changed due to the change in how the executions ARN is now computed "correctly".
test('Allows the pipeline to describe this stepfunction execution (across accounts & regions)', () => { | ||
const stack = new Stack(undefined, undefined, { env: { account: '11111111111', region: 'us-east-1' } }); | ||
|
||
minimalPipeline(stack, '999999999999', 'bermuda-triangle-1337'); | ||
|
||
// The permissions are defined by the cross-account stack here... | ||
const cfnStack = Stage.of(stack)?.synth().stacks.find(({ stackName }) => stackName === 'Default-support-999999999999'); | ||
expect(cfnStack).toBeDefined(); | ||
|
||
Template.fromJSON(cfnStack!.template).hasResourceProperties('AWS::IAM::Policy', { | ||
PolicyDocument: { | ||
Statement: [ | ||
{}, | ||
{ | ||
Action: 'states:DescribeExecution', | ||
Resource: 'arn:aws:states:bermuda-triangle-1337:999999999999:execution:SimpleStateMachine:*', | ||
Effect: 'Allow', | ||
}, | ||
], | ||
}, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case is new.
describe('StepFunctions Invoke Action', () => { | ||
describe('StepFunctions Invoke Action', () => { | ||
test('Verify stepfunction configuration properties are set to specific values', () => { | ||
const stack = new Stack(); | ||
|
||
// when | ||
minimalPipeline(stack); | ||
|
||
// then | ||
Template.fromStack(stack).hasResourceProperties('AWS::CodePipeline::Pipeline', Match.objectLike({ | ||
Stages: [ | ||
// Must have a source stage | ||
{ | ||
Actions: [ | ||
{ | ||
ActionTypeId: { | ||
Category: 'Source', | ||
Owner: 'AWS', | ||
Provider: 'S3', | ||
Version: '1', | ||
}, | ||
Configuration: { | ||
S3Bucket: { | ||
Ref: 'MyBucketF68F3FF0', | ||
}, | ||
S3ObjectKey: 'some/path/to', | ||
}, | ||
test('Verify stepfunction configuration properties are set to specific values', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The describe
block was duplicated, so I removed the duplicate... This caused a bunch of indent changes down there, so I've commented on what's "really" changed here so reviewers can focus on that.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
When the StateMachine being invoked by CodePipeline is not in the same account/region as the CodePipeline, the
DescribeExecutions
permission was granted on the incorrect account/region pair (that of the pipeline, and not that of the StateMachine), due to the transforming of the state machine's ARN into a state machine execution ARN pattern not copying the account & region of the original ARN.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license