Skip to content
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

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

RomainMuller
Copy link
Contributor

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

…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.
@RomainMuller RomainMuller added contribution/core This is a PR that came from AWS. pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Jun 5, 2023
@gitpod-io
Copy link

gitpod-io bot commented Jun 5, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team June 5, 2023 10:17
@github-actions github-actions bot added the p2 label Jun 5, 2023
Comment on lines +104 to +113
[
'arn:',
{ 'Fn::Select': [1, arnParts] },
':states:',
{ 'Fn::Select': [3, arnParts] },
':',
{ 'Fn::Select': [4, arnParts] },
':execution:',
{ 'Fn::Select': [6, arnParts] },
':*',
Copy link
Contributor Author

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".

Comment on lines +127 to 148
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',
},
],
},
});
});
Copy link
Contributor Author

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.

Comment on lines 8 to +9
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', () => {
Copy link
Contributor Author

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.

@mergify
Copy link
Contributor

mergify bot commented Jun 5, 2023

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ded7ad4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 3694670 into main Jun 5, 2023
@mergify mergify bot deleted the rmuller/fix-sfn-pipeline-action branch June 5, 2023 14:28
@mergify
Copy link
Contributor

mergify bot commented Jun 5, 2023

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants