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(app-delivery): could not use PipelineDeployStackAction more than once in a Stage #8217

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,27 @@ export interface PipelineDeployStackActionProps {
*/
readonly createChangeSetRunOrder?: number;

/**
* The name of the CodePipeline action creating the ChangeSet.
*
* @default 'ChangeSet'
*/
readonly createChangeSetActionName?: string;

/**
* The runOrder for the CodePipeline action executing the ChangeSet.
*
* @default ``createChangeSetRunOrder + 1``
*/
readonly executeChangeSetRunOrder?: number;

/**
* The name of the CodePipeline action creating the ChangeSet.
*
* @default 'Execute'
*/
readonly executeChangeSetActionName?: string;

/**
* IAM role to assume when deploying changes.
*
Expand Down Expand Up @@ -116,7 +130,7 @@ export class PipelineDeployStackAction implements codepipeline.IAction {
const changeSetName = props.changeSetName || 'CDK-CodePipeline-ChangeSet';
const capabilities = cfnCapabilities(props.adminPermissions, props.capabilities);
this.prepareChangeSetAction = new cpactions.CloudFormationCreateReplaceChangeSetAction({
actionName: 'ChangeSet',
actionName: props.createChangeSetActionName ?? 'ChangeSet',
changeSetName,
runOrder: createChangeSetRunOrder,
stackName: props.stack.stackName,
Expand All @@ -126,7 +140,7 @@ export class PipelineDeployStackAction implements codepipeline.IAction {
capabilities,
});
this.executeChangeSetAction = new cpactions.CloudFormationExecuteChangeSetAction({
actionName: 'Execute',
actionName: props.executeChangeSetActionName ?? 'Execute',
changeSetName,
runOrder: executeChangeSetRunOrder,
stackName: this.stack.stackName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, haveResource, isSuperObject } from '@aws-cdk/assert';
import { expect, haveResource, haveResourceLike, isSuperObject } from '@aws-cdk/assert';
import * as cfn from '@aws-cdk/aws-cloudformation';
import * as codebuild from '@aws-cdk/aws-codebuild';
import * as codepipeline from '@aws-cdk/aws-codepipeline';
Expand Down Expand Up @@ -406,6 +406,43 @@ export = nodeunit.testCase({
);
test.done();
},

'allows overriding the ChangeSet and Execute action names'(test: nodeunit.Test) {
const stack = getTestStack();
const selfUpdatingPipeline = createSelfUpdatingStack(stack);
selfUpdatingPipeline.pipeline.addStage({
stageName: 'Deploy',
actions: [
new PipelineDeployStackAction({
input: selfUpdatingPipeline.synthesizedApp,
adminPermissions: true,
stack,
createChangeSetActionName: 'Prepare',
executeChangeSetActionName: 'Deploy',
}),
],
});

expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
Stages: [
{},
{},
{
Name: 'Deploy',
Actions: [
{
Name: 'Prepare',
},
{
Name: 'Deploy',
},
],
},
],
}));

test.done();
},
});

class FakeAction implements codepipeline.IAction {
Expand Down