Skip to content

Commit

Permalink
refactor(aws-codepipeline): Re-structure the CodePipeline API.
Browse files Browse the repository at this point in the history
1. [BREAKING] Introduce a new aws-codepipeline-api package, and move the Actions API there.
2. [BREAKING] Move the service-specific Actions back into their service packages.
  • Loading branch information
skinny85 committed Aug 13, 2018
1 parent 8cd07e6 commit 4682338
Show file tree
Hide file tree
Showing 82 changed files with 1,170 additions and 1,974 deletions.
24 changes: 0 additions & 24 deletions packages/@aws-cdk/aws-cloudformation-codepipeline/README.md

This file was deleted.

This file was deleted.

67 changes: 0 additions & 67 deletions packages/@aws-cdk/aws-cloudformation-codepipeline/package.json

This file was deleted.

38 changes: 0 additions & 38 deletions packages/@aws-cdk/aws-cloudformation-codepipeline/tslint.json

This file was deleted.

26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-cloudformation/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
## CDK Constructs for AWS CloudFormation

This module is part of the [AWS Cloud Development Kit](https://github.com/awslabs/aws-cdk) project.

### CodePipeline Actions for CloudFormation

This module contains Actions that allows you to deploy to CloudFormation from AWS CodePipeline.

For example, the following code fragment defines a pipeline that automatically deploys a CloudFormation template
directly from a CodeCommit repository, with a manual approval step in between to confirm the changes:

[example Pipeline to deploy CloudFormation](../aws-codepipeline/test/integ.cfn-template-from-repo.lit.ts)

See [the AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline.html)
for more details about using CloudFormation in CodePipeline.

#### Actions defined by this package

This package defines the following actions:

* **CreateUpdateStack** - Deploy a CloudFormation template directly from the pipeline. The indicated stack is created,
or updated if it already exists. If the stack is in a failure state, deployment will fail (unless `replaceOnFailure`
is set to `true`, in which case it will be destroyed and recreated).
* **DeleteStackOnly** - Delete the stack with the given name.
* **CreateReplaceChangeSet** - Prepare a change set to be applied later. You will typically use change sets if you want
to manually verify the changes that are being staged, or if you want to separate the people (or system) preparing the
changes from the people (or system) applying the changes.
* **ExecuteChangeSet** - Execute a change set prepared previously.

### Custom Resources

Custom Resources are CloudFormation resources that are implemented by
Expand Down
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-cloudformation/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './custom-resource';
export * from './pipeline-actions';

// AWS::CloudFormation CloudFormation Resources:
export * from './cloudformation.generated';
export * from './custom-resource';
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import codepipeline = require('@aws-cdk/aws-codepipeline');
import codepipeline = require('@aws-cdk/aws-codepipeline-api');
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');

/**
* Properties common to all CloudFormation actions
*/
export interface CloudFormationCommonProps {
export interface CloudFormationCommonProps extends codepipeline.CommonActionProps {
/**
* The name of the stack to apply this action to
*/
Expand Down Expand Up @@ -45,15 +45,26 @@ export abstract class CloudFormationAction extends codepipeline.DeployAction {
*/
public artifact?: codepipeline.Artifact;

constructor(parent: codepipeline.Stage, id: string, props: CloudFormationCommonProps, configuration?: any) {
super(parent, id, 'CloudFormation', { minInputs: 0, maxInputs: 10, minOutputs: 0, maxOutputs: 1 }, {
...configuration,
StackName: props.stackName,
OutputFileName: props.outputFileName,
constructor(parent: cdk.Construct, id: string, props: CloudFormationCommonProps, configuration?: any) {
super(parent, id, {
stage: props.stage,
artifactBounds: {
minInputs: 0,
maxInputs: 10,
minOutputs: 0,
maxOutputs: 1,
},
provider: 'CloudFormation',
configuration: {
StackName: props.stackName,
OutputFileName: props.outputFileName,
...configuration,
}
});

if (props.outputFileName) {
this.artifact = this.addOutputArtifact(props.outputArtifactName || (parent.name + this.name + 'Artifact'));
this.artifact = this.addOutputArtifact(props.outputArtifactName ||
(props.stage.name + this.name + 'Artifact'));
}
}
}
Expand All @@ -72,7 +83,7 @@ export interface ExecuteChangeSetProps extends CloudFormationCommonProps {
* CodePipeline action to execute a prepared change set.
*/
export class ExecuteChangeSet extends CloudFormationAction {
constructor(parent: codepipeline.Stage, id: string, props: ExecuteChangeSetProps) {
constructor(parent: cdk.Construct, id: string, props: ExecuteChangeSetProps) {
super(parent, id, props, {
ActionMode: 'CHANGE_SET_EXECUTE',
ChangeSetName: props.changeSetName,
Expand Down Expand Up @@ -168,7 +179,7 @@ export interface CloudFormationDeploymentActionCommonProps extends CloudFormatio
export abstract class CloudFormationDeploymentAction extends CloudFormationAction {
public readonly role: iam.Role;

constructor(parent: codepipeline.Stage, id: string, props: CloudFormationDeploymentActionCommonProps, configuration: any) {
constructor(parent: cdk.Construct, id: string, props: CloudFormationDeploymentActionCommonProps, configuration: any) {
const capabilities = props.fullPermissions && props.capabilities === undefined ? [CloudFormationCapabilities.NamedIAM] : props.capabilities;

super(parent, id, props, {
Expand Down Expand Up @@ -224,7 +235,7 @@ export interface CreateReplaceChangeSetProps extends CloudFormationDeploymentAct
* If the change set exists, AWS CloudFormation deletes it, and then creates a new one.
*/
export class CreateReplaceChangeSet extends CloudFormationDeploymentAction {
constructor(parent: codepipeline.Stage, id: string, props: CreateReplaceChangeSetProps) {
constructor(parent: cdk.Construct, id: string, props: CreateReplaceChangeSetProps) {
super(parent, id, props, {
ActionMode: 'CHANGE_SET_REPLACE',
ChangeSetName: props.changeSetName,
Expand Down Expand Up @@ -275,7 +286,7 @@ export interface CreateUpdateProps extends CloudFormationDeploymentActionCommonP
* troubleshooting them. You would typically choose this mode for testing.
*/
export class CreateUpdateStack extends CloudFormationDeploymentAction {
constructor(parent: codepipeline.Stage, id: string, props: CreateUpdateProps) {
constructor(parent: cdk.Construct, id: string, props: CreateUpdateProps) {
super(parent, id, props, {
ActionMode: props.replaceOnFailure ? 'REPLACE_ON_FAILURE' : 'CREATE_UPDATE',
TemplatePath: props.templatePath.location
Expand All @@ -298,7 +309,7 @@ export interface DeleteStackOnlyProps extends CloudFormationDeploymentActionComm
* without deleting a stack.
*/
export class DeleteStackOnly extends CloudFormationDeploymentAction {
constructor(parent: codepipeline.Stage, id: string, props: DeleteStackOnlyProps) {
constructor(parent: cdk.Construct, id: string, props: DeleteStackOnlyProps) {
super(parent, id, props, {
ActionMode: 'DELETE_ONLY',
});
Expand Down
6 changes: 6 additions & 0 deletions packages/@aws-cdk/aws-cloudformation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"cdk-build": {
"cloudformation": "AWS::CloudFormation"
},
"nyc": {
"lines": 50,
"branches": 20
},
"keywords": [
"aws",
"cdk",
Expand All @@ -54,6 +58,8 @@
},
"dependencies": {
"@aws-cdk/cdk": "^0.8.1",
"@aws-cdk/aws-codepipeline-api": "^0.8.1",
"@aws-cdk/aws-iam": "^0.8.1",
"@aws-cdk/aws-lambda": "^0.8.1",
"@aws-cdk/aws-sns": "^0.8.1"
},
Expand Down
17 changes: 0 additions & 17 deletions packages/@aws-cdk/aws-codebuild-codepipeline/.gitignore

This file was deleted.

19 changes: 0 additions & 19 deletions packages/@aws-cdk/aws-codebuild-codepipeline/.npmignore

This file was deleted.

Loading

0 comments on commit 4682338

Please sign in to comment.