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

feat(codepipeline): move all of the Pipeline Actions to their dedicated package #2098

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
50 changes: 0 additions & 50 deletions packages/@aws-cdk/alexa-ask/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,3 @@
```ts
const alexaAsk = require('@aws-cdk/alexa-ask');
```

### Alexa as deploy target for CodePipeline

You can deploy to Alexa using CodePipeline with the following DeployAction.

```ts
// Read the secrets from ParameterStore
const clientId = new cdk.SecretParameter(this, 'AlexaClientId', { ssmParameter: '/Alexa/ClientId' });
const clientSecret = new cdk.SecretParameter(this, 'AlexaClientSecret', { ssmParameter: '/Alexa/ClientSecret' });
const refreshToken = new cdk.SecretParameter(this, 'AlexaRefreshToken', { ssmParameter: '/Alexa/RefreshToken' });

// Add deploy action
new alexaAsk.AlexaSkillDeployAction({
actionName: 'DeploySkill',
runOrder: 1,
inputArtifact: sourceAction.outputArtifact,
clientId: clientId.value,
clientSecret: clientSecret.value,
refreshToken: refreshToken.value,
skillId: 'amzn1.ask.skill.12345678-1234-1234-1234-123456789012',
});
```

If you need manifest overrides you can specify them as `parameterOverridesArtifact` in the action:

```ts
const cloudformation = require('@aws-cdk/aws-cloudformation');

// Deploy some CFN change set and store output
const executeChangeSetAction = new cloudformation.PipelineExecuteChangeSetAction({
actionName: 'ExecuteChangesTest',
runOrder: 2,
stackName,
changeSetName,
outputFileName: 'overrides.json',
outputArtifactName: 'CloudFormation',
});

// Provide CFN output as manifest overrides
new alexaAsk.AlexaSkillDeployAction({
actionName: 'DeploySkill',
runOrder: 1,
inputArtifact: sourceAction.outputArtifact,
parameterOverridesArtifact: executeChangeSetAction.outputArtifact,
clientId: clientId.value,
clientSecret: clientSecret.value,
refreshToken: refreshToken.value,
skillId: 'amzn1.ask.skill.12345678-1234-1234-1234-123456789012',
});
```
1 change: 0 additions & 1 deletion packages/@aws-cdk/alexa-ask/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Alexa::ASK CloudFormation Resources:
export * from './ask.generated';
export * from './pipeline-actions';
4 changes: 1 addition & 3 deletions packages/@aws-cdk/alexa-ask/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@
"pkglint": "^0.27.0"
},
"dependencies": {
"@aws-cdk/aws-codepipeline-api": "^0.27.0",
"@aws-cdk/cdk": "^0.27.0"
},
"peerDependencies": {
"@aws-cdk/aws-codepipeline-api": "^0.27.0",
"@aws-cdk/cdk": "^0.27.0"
},
"engines": {
"node": ">= 8.10.0"
}
}
}
7 changes: 5 additions & 2 deletions packages/@aws-cdk/app-delivery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ The example below defines a *CDK App* that contains 3 stacks:
```

#### `index.ts`

```typescript
import codebuild = require('@aws-cdk/aws-codebuild');
import codepipeline = require('@aws-cdk/aws-codepipeline');
import codepipeline_actions = require('@aws-cdk/aws-codepipeline-actions');
import cdk = require('@aws-cdk/cdk');
import cicd = require('@aws-cdk/cicd');

Expand All @@ -48,7 +50,7 @@ const pipeline = new codepipeline.Pipeline(pipelineStack, 'CodePipeline', {
});

// Configure the CodePipeline source - where your CDK App's source code is hosted
const source = new codepipeline.GitHubSourceAction({
const source = new codepipeline_actions.GitHubSourceAction({
actionName: 'GitHub',
/* ... */
});
Expand All @@ -67,8 +69,9 @@ const project = new codebuild.PipelineProject(pipelineStack, 'CodeBuild', {
* },
*/
});
const buildAction = project.toCodePipelineBuildAction({
const buildAction = new codepipeline_actions.CodeBuildBuildAction({
actionName: 'CodeBuild',
project,
inputArtifact: source.outputArtifact,
});
pipeline.addStage({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cfn = require('@aws-cdk/aws-cloudformation');
import codepipeline = require('@aws-cdk/aws-codepipeline-api');
import codepipeline = require('@aws-cdk/aws-codepipeline');
import cpactions = require('@aws-cdk/aws-codepipeline-actions');
import iam = require('@aws-cdk/aws-iam');
import cdk = require('@aws-cdk/cdk');
import cxapi = require('@aws-cdk/cx-api');
Expand Down Expand Up @@ -120,7 +121,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
const changeSetName = props.changeSetName || 'CDK-CodePipeline-ChangeSet';

const capabilities = cfnCapabilities(props.adminPermissions, props.capabilities);
const changeSetAction = new cfn.PipelineCreateReplaceChangeSetAction({
const changeSetAction = new cpactions.CloudFormationCreateReplaceChangeSetAction({
actionName: 'ChangeSet',
changeSetName,
runOrder: createChangeSetRunOrder,
Expand All @@ -131,7 +132,7 @@ export class PipelineDeployStackAction extends cdk.Construct {
capabilities,
});
props.stage.addAction(changeSetAction);
props.stage.addAction(new cfn.PipelineExecuteChangeSetAction({
props.stage.addAction(new cpactions.CloudFormationExecuteChangeSetAction({
actionName: 'Execute',
changeSetName,
runOrder: executeChangeSetRunOrder,
Expand Down
9 changes: 5 additions & 4 deletions packages/@aws-cdk/app-delivery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
"dependencies": {
"@aws-cdk/aws-cloudformation": "^0.27.0",
"@aws-cdk/aws-codebuild": "^0.27.0",
"@aws-cdk/aws-codepipeline-api": "^0.27.0",
"@aws-cdk/aws-codepipeline": "^0.27.0",
"@aws-cdk/aws-codepipeline-actions": "^0.27.0",
"@aws-cdk/aws-iam": "^0.27.0",
"@aws-cdk/cdk": "^0.27.0",
"@aws-cdk/cx-api": "^0.27.0"
},
"devDependencies": {
"@aws-cdk/assert": "^0.27.0",
"@aws-cdk/aws-codepipeline": "^0.27.0",
"@aws-cdk/aws-s3": "^0.27.0",
"cdk-build-tools": "^0.27.0",
"cdk-integ-tools": "^0.27.0",
Expand All @@ -70,11 +70,12 @@
],
"peerDependencies": {
"@aws-cdk/aws-cloudformation": "^0.27.0",
"@aws-cdk/aws-codepipeline-api": "^0.27.0",
"@aws-cdk/aws-codepipeline": "^0.27.0",
"@aws-cdk/aws-codepipeline-actions": "^0.27.0",
"@aws-cdk/aws-iam": "^0.27.0",
"@aws-cdk/cdk": "^0.27.0"
},
"engines": {
"node": ">= 8.10.0"
}
}
}
7 changes: 4 additions & 3 deletions packages/@aws-cdk/app-delivery/test/integ.cicd.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import cfn = require('@aws-cdk/aws-cloudformation');
import code = require('@aws-cdk/aws-codepipeline');
import codepipeline = require('@aws-cdk/aws-codepipeline');
import cpactions = require('@aws-cdk/aws-codepipeline-actions');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import cicd = require('../lib');

const app = new cdk.App();

const stack = new cdk.Stack(app, 'CICD');
const pipeline = new code.Pipeline(stack, 'CodePipeline', {
const pipeline = new codepipeline.Pipeline(stack, 'CodePipeline', {
artifactBucket: new s3.Bucket(stack, 'ArtifactBucket', {
removalPolicy: cdk.RemovalPolicy.Destroy
})
});
const source = new code.GitHubSourceAction({
const source = new cpactions.GitHubSourceAction({
actionName: 'GitHub',
owner: 'awslabs',
repo: 'aws-cdk',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cfn = require('@aws-cdk/aws-cloudformation');
import codebuild = require('@aws-cdk/aws-codebuild');
import code = require('@aws-cdk/aws-codepipeline');
import api = require('@aws-cdk/aws-codepipeline-api');
import codepipeline = require('@aws-cdk/aws-codepipeline');
import cpactions = require('@aws-cdk/aws-codepipeline-actions');
import iam = require('@aws-cdk/aws-iam');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
Expand All @@ -13,8 +13,8 @@ import { countResources, expect, haveResource, isSuperObject } from '@aws-cdk/as
import { PipelineDeployStackAction } from '../lib/pipeline-deploy-stack-action';

interface SelfUpdatingPipeline {
synthesizedApp: api.Artifact;
pipeline: code.Pipeline;
synthesizedApp: codepipeline.Artifact;
pipeline: codepipeline.Pipeline;
}
const accountId = fc.array(fc.integer(0, 9), 12, 12).map(arr => arr.join());

Expand All @@ -28,7 +28,7 @@ export = nodeunit.testCase({
test.throws(() => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Test', { env: { account: pipelineAccount } });
const pipeline = new code.Pipeline(stack, 'Pipeline');
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
const fakeAction = new FakeAction('Fake');
pipeline.addStage({
name: 'FakeStage',
Expand Down Expand Up @@ -57,7 +57,7 @@ export = nodeunit.testCase({
test.throws(() => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Test');
const pipeline = new code.Pipeline(stack, 'Pipeline');
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
const fakeAction = new FakeAction('Fake');
pipeline.addStage({
name: 'FakeStage',
Expand Down Expand Up @@ -272,7 +272,7 @@ export = nodeunit.testCase({
(assetCount) => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'Test');
const pipeline = new code.Pipeline(stack, 'Pipeline');
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');
const fakeAction = new FakeAction('Fake');
pipeline.addStage({
name: 'FakeStage',
Expand All @@ -299,21 +299,21 @@ export = nodeunit.testCase({
}
});

class FakeAction extends api.Action {
public readonly outputArtifact: api.Artifact;
class FakeAction extends codepipeline.Action {
public readonly outputArtifact: codepipeline.Artifact;

constructor(actionName: string) {
super({
actionName,
artifactBounds: api.defaultBounds(),
category: api.ActionCategory.Test,
artifactBounds: codepipeline.defaultBounds(),
category: codepipeline.ActionCategory.Test,
provider: 'Test',
});

this.outputArtifact = new api.Artifact('OutputArtifact');
this.outputArtifact = new codepipeline.Artifact('OutputArtifact');
}

protected bind(_info: api.ActionBind): void {
protected bind(_info: codepipeline.ActionBind): void {
// do nothing
}
}
Expand All @@ -323,13 +323,13 @@ function getTestStack(): cdk.Stack {
}

function createSelfUpdatingStack(pipelineStack: cdk.Stack): SelfUpdatingPipeline {
const pipeline = new code.Pipeline(pipelineStack, 'CodePipeline', {
const pipeline = new codepipeline.Pipeline(pipelineStack, 'CodePipeline', {
restartExecutionOnUpdate: true,
});

// simple source
const bucket = s3.Bucket.import( pipeline, 'PatternBucket', { bucketArn: 'arn:aws:s3:::totally-fake-bucket' });
const sourceAction = new s3.PipelineSourceAction({
const sourceAction = new cpactions.S3SourceAction({
actionName: 'S3Source',
bucket,
bucketKey: 'the-great-key',
Expand All @@ -340,8 +340,9 @@ function createSelfUpdatingStack(pipelineStack: cdk.Stack): SelfUpdatingPipeline
});

const project = new codebuild.PipelineProject(pipelineStack, 'CodeBuild');
const buildAction = project.toCodePipelineBuildAction({
const buildAction = new cpactions.CodeBuildBuildAction({
actionName: 'CodeBuild',
project,
inputArtifact: sourceAction.outputArtifact,
});
pipeline.addStage({
Expand Down
25 changes: 0 additions & 25 deletions packages/@aws-cdk/aws-cloudformation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@

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:

* **PipelineCreateUpdateStackAction** - 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).
* **PipelineDeleteStackAction** - Delete the stack with the given name.
* **PipelineCreateReplaceChangeSetAction** - 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.
* **PipelineExecuteChangeSetAction** - Execute a change set prepared previously.

### Custom Resources

Custom Resources are CloudFormation resources that are implemented by
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Capabilities that affect whether CloudFormation is allowed to change IAM resources
*/
export enum CloudFormationCapabilities {
/**
* No IAM Capabilities
*
* Pass this capability if you wish to block the creation IAM resources.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#using-iam-capabilities
*/
None = '',

/**
* Capability to create anonymous IAM resources
*
* Pass this capability if you're only creating anonymous resources.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#using-iam-capabilities
*/
AnonymousIAM = 'CAPABILITY_IAM',

/**
* Capability to create named IAM resources.
*
* Pass this capability if you're creating IAM resources that have physical
* names.
*
* `CloudFormationCapabilities.NamedIAM` implies `CloudFormationCapabilities.IAM`; you don't have to pass both.
* @link https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#using-iam-capabilities
*/
NamedIAM = 'CAPABILITY_NAMED_IAM',
}
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-cloudformation/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './cloud-formation-capabilities';
export * from './custom-resource';
export * from './pipeline-actions';

// AWS::CloudFormation CloudFormation Resources:
export * from './cloudformation.generated';
Loading