Skip to content

Commit

Permalink
fix(app-delivery): add parameters to deploy stack action
Browse files Browse the repository at this point in the history
[PipelineDeployStackAction] is a construct for deploying cdk apps via
CodePipeline but I couldn't figure out how to access pipeline artifacts
in the application stack. The [app-delivery] readme includes a
self-updating pipeline example but the service stacks don't use build
artifacts.

I added passthru props to PipelineDeployStackAction to set parameters
for the created stacks, based on the pattern in [codepipeline example].

 - Did I miss another way to pass build outputs to a stack?
 - What are the differences between [PipelineDeployStackAction] and
   [CloudFormationCreateUpdateStackAction]?

[app-delivery]: https://docs.aws.amazon.com/cdk/api/latest/docs/app-delivery-readme.html
[PipelineDeployStackAction]: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_app-delivery.PipelineDeployStackAction.html
[CloudFormationCreateUpdateStackAction]: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-codepipeline-actions.CloudFormationCreateUpdateStackAction.html
[codepipeline example]: https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html
  • Loading branch information
Caleb ツ Everett committed Feb 3, 2020
1 parent b19d038 commit ab5a6bb
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,57 @@ export interface PipelineDeployStackActionProps {
* deployment is allowed to do.
*/
readonly adminPermissions: boolean;

// tslint:disable:max-line-length Because of long URLs in documentation
/**
* Input artifact to use for template parameters values and stack policy.
*
* The template configuration file should contain a JSON object that should look like this:
* `{ "Parameters": {...}, "Tags": {...}, "StackPolicy": {... }}`. For more information,
* see [AWS CloudFormation Artifacts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-cfn-artifacts.html).
*
* Note that if you include sensitive information, such as passwords, restrict access to this
* file.
*
* @default No template configuration based on input artifacts
*/
readonly templateConfiguration?: codepipeline.ArtifactPath;

/**
* Additional template parameters.
*
* Template parameters specified here take precedence over template parameters
* found in the artifact specified by the `templateConfiguration` property.
*
* We recommend that you use the template configuration file to specify
* most of your parameter values. Use parameter overrides to specify only
* dynamic parameter values (values that are unknown until you run the
* pipeline).
*
* All parameter names must be present in the stack template.
*
* Note: the entire object cannot be more than 1kB.
*
* @default No overrides
*/
readonly parameterOverrides?: { [name: string]: any };

/**
* The list of additional input Artifacts for this Action.
* This is especially useful when used in conjunction with the `parameterOverrides` property.
* For example, if you have:
*
* parameterOverrides: {
* 'Param1': action1.outputArtifact.bucketName,
* 'Param2': action2.outputArtifact.objectKey,
* }
*
* , if the output Artifacts of `action1` and `action2` were not used to
* set either the `templateConfiguration` or the `templatePath` properties,
* you need to make sure to include them in the `extraInputs` -
* otherwise, you'll get an "unrecognized Artifact" error during your Pipeline's execution.
*/
readonly extraInputs?: codepipeline.Artifact[];
}

/**
Expand Down Expand Up @@ -124,6 +175,9 @@ export class PipelineDeployStackAction implements codepipeline.IAction {
adminPermissions: props.adminPermissions,
deploymentRole: props.role,
capabilities,
templateConfiguration: props.templateConfiguration,
parameterOverrides: props.parameterOverrides,
extraInputs: props.extraInputs,
});
this.executeChangeSetAction = new cpactions.CloudFormationExecuteChangeSetAction({
actionName: 'Execute',
Expand Down

0 comments on commit ab5a6bb

Please sign in to comment.