-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codebuild): validate if a CodePipeline action that is cross-accou…
…nt does not have outputs (#4171) CodeBuild does not honor the key set on the project if the key is from a different account. That means a cross-account CodeBuild action effectively cannot have outputs (as they will be written with the default S3 key of the CodeBuild account, which the other actions won't have access to). Add validation that throws an error if there is an attempt to add a cross-account CodeBuild action with outputs. Fixes #4032
- Loading branch information
Showing
3 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
packages/@aws-cdk/aws-codepipeline-actions/test/codebuild/test.codebuild-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import codebuild = require('@aws-cdk/aws-codebuild'); | ||
import codecommit = require('@aws-cdk/aws-codecommit'); | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import { App, Stack } from '@aws-cdk/core'; | ||
import { Test } from 'nodeunit'; | ||
import cpactions = require('../../lib'); | ||
|
||
// tslint:disable:object-literal-key-quotes | ||
|
||
export = { | ||
'a cross-account CodeBuild action with outputs': { | ||
'causes an error'(test: Test) { | ||
const app = new App(); | ||
|
||
const projectStack = new Stack(app, 'ProjectStack', { | ||
env: { | ||
region: 'us-west-2', | ||
account: '012345678901', | ||
}, | ||
}); | ||
const project = new codebuild.PipelineProject(projectStack, 'Project'); | ||
|
||
const pipelineStack = new Stack(app, 'PipelineStack', { | ||
env: { | ||
region: 'us-west-2', | ||
account: '123456789012', | ||
}, | ||
}); | ||
const sourceOutput = new codepipeline.Artifact(); | ||
const pipeline = new codepipeline.Pipeline(pipelineStack, 'Pipeline', { | ||
stages: [ | ||
{ | ||
stageName: 'Source', | ||
actions: [new cpactions.CodeCommitSourceAction({ | ||
actionName: 'CodeCommit', | ||
repository: codecommit.Repository.fromRepositoryName(pipelineStack, 'Repo', 'repo-name'), | ||
output: sourceOutput, | ||
})], | ||
}, | ||
], | ||
}); | ||
const buildStage = pipeline.addStage({ | ||
stageName: 'Build', | ||
}); | ||
|
||
// this works fine - no outputs! | ||
buildStage.addAction(new cpactions.CodeBuildAction({ | ||
actionName: 'Build1', | ||
input: sourceOutput, | ||
project, | ||
})); | ||
|
||
const buildAction2 = new cpactions.CodeBuildAction({ | ||
actionName: 'Build2', | ||
input: sourceOutput, | ||
project, | ||
outputs: [new codepipeline.Artifact()], | ||
}); | ||
|
||
test.throws(() => { | ||
buildStage.addAction(buildAction2); | ||
}, /https:\/\/github\.com\/aws\/aws-cdk\/issues\/4169/); | ||
|
||
test.done(); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters