diff --git a/packages/@aws-cdk/alexa-ask/README.md b/packages/@aws-cdk/alexa-ask/README.md index ce3247e40160e..d9b65d34f8459 100644 --- a/packages/@aws-cdk/alexa-ask/README.md +++ b/packages/@aws-cdk/alexa-ask/README.md @@ -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', -}); -``` diff --git a/packages/@aws-cdk/alexa-ask/lib/index.ts b/packages/@aws-cdk/alexa-ask/lib/index.ts index a691e2ef6e3cb..59194e547cc5a 100644 --- a/packages/@aws-cdk/alexa-ask/lib/index.ts +++ b/packages/@aws-cdk/alexa-ask/lib/index.ts @@ -1,3 +1,2 @@ // Alexa::ASK CloudFormation Resources: export * from './ask.generated'; -export * from './pipeline-actions'; diff --git a/packages/@aws-cdk/alexa-ask/package.json b/packages/@aws-cdk/alexa-ask/package.json index 79098e0965ff9..ceaaa282c16f1 100644 --- a/packages/@aws-cdk/alexa-ask/package.json +++ b/packages/@aws-cdk/alexa-ask/package.json @@ -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" } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/app-delivery/README.md b/packages/@aws-cdk/app-delivery/README.md index a7e877b954f25..c19886892a86c 100644 --- a/packages/@aws-cdk/app-delivery/README.md +++ b/packages/@aws-cdk/app-delivery/README.md @@ -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'); @@ -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', /* ... */ }); @@ -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({ diff --git a/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts b/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts index dc6ff8ebc2f8a..e215739318cd4 100644 --- a/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts +++ b/packages/@aws-cdk/app-delivery/lib/pipeline-deploy-stack-action.ts @@ -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'); @@ -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, @@ -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, diff --git a/packages/@aws-cdk/app-delivery/package.json b/packages/@aws-cdk/app-delivery/package.json index 7b7c5eccfaf1d..f3b6b3124b9d0 100644 --- a/packages/@aws-cdk/app-delivery/package.json +++ b/packages/@aws-cdk/app-delivery/package.json @@ -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", @@ -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" } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/app-delivery/test/integ.cicd.ts b/packages/@aws-cdk/app-delivery/test/integ.cicd.ts index 261cd071307b0..3d48907bc39b5 100644 --- a/packages/@aws-cdk/app-delivery/test/integ.cicd.ts +++ b/packages/@aws-cdk/app-delivery/test/integ.cicd.ts @@ -1,5 +1,6 @@ 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'); @@ -7,12 +8,12 @@ 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', diff --git a/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts b/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts index 48c040e522213..1ecffba85f323 100644 --- a/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts +++ b/packages/@aws-cdk/app-delivery/test/test.pipeline-deploy-stack-action.ts @@ -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'); @@ -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()); @@ -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', @@ -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', @@ -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', @@ -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 } } @@ -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', @@ -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({ diff --git a/packages/@aws-cdk/aws-cloudformation/README.md b/packages/@aws-cdk/aws-cloudformation/README.md index 8ea59a126634c..20a82664f5aba 100644 --- a/packages/@aws-cdk/aws-cloudformation/README.md +++ b/packages/@aws-cdk/aws-cloudformation/README.md @@ -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 diff --git a/packages/@aws-cdk/aws-cloudformation/lib/cloud-formation-capabilities.ts b/packages/@aws-cdk/aws-cloudformation/lib/cloud-formation-capabilities.ts new file mode 100644 index 0000000000000..55a4cb1b29f75 --- /dev/null +++ b/packages/@aws-cdk/aws-cloudformation/lib/cloud-formation-capabilities.ts @@ -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', +} diff --git a/packages/@aws-cdk/aws-cloudformation/lib/index.ts b/packages/@aws-cdk/aws-cloudformation/lib/index.ts index 2a9dc1178f2fe..3d4971d16542b 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/index.ts +++ b/packages/@aws-cdk/aws-cloudformation/lib/index.ts @@ -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'; diff --git a/packages/@aws-cdk/aws-cloudformation/package.json b/packages/@aws-cdk/aws-cloudformation/package.json index d8cd77b542e52..558d7e9b335b0 100644 --- a/packages/@aws-cdk/aws-cloudformation/package.json +++ b/packages/@aws-cdk/aws-cloudformation/package.json @@ -45,11 +45,6 @@ "cdk-build": { "cloudformation": "AWS::CloudFormation" }, - "nyc": { - "statements": 50, - "lines": 50, - "branches": 20 - }, "keywords": [ "aws", "cdk", @@ -65,15 +60,12 @@ "devDependencies": { "@aws-cdk/assert": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", - "@types/lodash": "^4.14.118", "cdk-build-tools": "^0.27.0", "cdk-integ-tools": "^0.27.0", "cfn2ts": "^0.27.0", - "lodash": "^4.17.11", "pkglint": "^0.27.0" }, "dependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-lambda": "^0.27.0", "@aws-cdk/aws-sns": "^0.27.0", @@ -81,7 +73,6 @@ }, "homepage": "https://github.com/awslabs/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-lambda": "^0.27.0", "@aws-cdk/aws-sns": "^0.27.0", @@ -96,4 +87,4 @@ "construct-ctor:@aws-cdk/aws-cloudformation.PipelineCloudFormationDeployAction." ] } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-codebuild/README.md b/packages/@aws-cdk/aws-codebuild/README.md index 54489fa39f39a..4ed74c7a64a8d 100644 --- a/packages/@aws-cdk/aws-codebuild/README.md +++ b/packages/@aws-cdk/aws-codebuild/README.md @@ -165,87 +165,6 @@ const rule = project.onStateChange('BuildStateChange'); rule.addTarget(lambdaFunction); ``` -## Using a CodeBuild Project as an AWS CodePipeline action - -Example of a Project used in CodePipeline, alongside CodeCommit: - -```typescript -import codebuild = require('@aws-cdk/aws-codebuild'); -import codecommit = require('@aws-cdk/aws-codecommit'); -import codepipeline = require('@aws-cdk/aws-codepipeline'); - -const repository = new codecommit.Repository(this, 'MyRepository', { - repositoryName: 'MyRepository', -}); -const project = new codebuild.PipelineProject(this, 'MyProject'); - -const sourceAction = repository.toCodePipelineSourceAction({ actionName: 'CodeCommit' }); -const buildAction = new codebuild.PipelineBuildAction({ - actionName: 'CodeBuild', - project, - inputArtifact: sourceAction.outputArtifact, -}); - -new codepipeline.Pipeline(this, 'MyPipeline', { - stages: [ - { - name: 'Source', - actions: [sourceAction], - }, - { - name: 'Build', - actions: [buildAction], - }, - ], -}); -``` - -The `PipelineProject` utility class is a simple sugar around the `Project` -class, it's equivalent to: - -```ts -const project = new codebuild.Project(this, 'MyProject', { - source: new codebuild.CodePipelineSource(), - artifacts: new codebuild.CodePipelineBuildArtifacts(), - // rest of the properties from PipelineProject are passed unchanged... -} -``` - -You can also create the action from the Project directly: - -```ts -// equivalent to the code above: -const buildAction = project.toCodePipelineBuildAction({ - actionName: 'CodeBuild', - inputArtifact: sourceAction.outputArtifact, -}); -``` - -In addition to the build Action, there is also a test Action. It works very -similarly to the build Action, the only difference is that the test Action does -not always produce an output artifact. - -Examples: - -```typescript -const testAction = new codebuild.PipelineTestAction({ - actionName: 'IntegrationTest', - project, - inputArtifact: sourceAction.outputArtifact, - // outputArtifactName is optional - if you don't specify it, - // the Action will have an undefined `outputArtifact` property - outputArtifactName: 'IntegrationTestOutput', -}); - -// equivalent to the code above: -const testAction = project.toCodePipelineTestAction({ - actionName: 'IntegrationTest', - inputArtifact: sourceAction.outputArtifact, - // of course, this property is optional here as well - outputArtifactName: 'IntegrationTestOutput', -}); -``` - ## Secondary sources and artifacts CodeBuild Projects can get their sources from multiple places, and produce @@ -255,16 +174,16 @@ multiple outputs. For example: const project = new codebuild.Project(this, 'MyProject', { secondarySources: [ new codebuild.CodeCommitSource({ - identifier: 'source2', - repository: repo, + identifier: 'source2', + repository: repo, }), ], secondaryArtifacts: [ new codebuild.S3BucketBuildArtifacts({ - identifier: 'artifact2', - bucket: bucket, - path: 'some/path', - name: 'file.zip', + identifier: 'artifact2', + bucket: bucket, + path: 'some/path', + name: 'file.zip', }), ], // ... @@ -290,91 +209,23 @@ const project = new codebuild.Project(this, 'MyProject', { buildSpec: { version: '0.2', phases: { - build: { - commands: [ - 'cd $CODEBUILD_SRC_DIR_source2', - 'touch output2.txt', - ], - }, - }, - artifacts: { - 'secondary-artifacts': { - 'artifact2': { - 'base-directory': '$CODEBUILD_SRC_DIR_source2', - 'files': [ - 'output2.txt', - ], - }, - }, - }, - }, -}); -``` - -### Multiple inputs and outputs in CodePipeline - -When you want to have multiple inputs and/or outputs for a Project used in a -Pipeline, instead of using the `secondarySources` and `secondaryArtifacts` -properties, you need to use the `additionalInputArtifacts` and -`additionalOutputArtifactNames` properties of the CodeBuild CodePipeline -Actions. Example: - -```ts -const sourceAction1 = repository1.toCodePipelineSourceAction({ - actionName: 'Source1', -}); -const sourceAction2 = repository2.toCodePipelineSourceAction({ - actionName: 'Source2', - outputArtifactName: 'source2', -}); - -const buildAction = project.toCodePipelineBuildAction({ - actionName: 'Build', - inputArtifact: sourceAction1.outputArtifact, - outputArtifactName: 'artifact1', // for better buildspec readability - see below - additionalInputArtifacts: [ - sourceAction2.outputArtifact, // this is where 'source2' comes from - ], - additionalOutputArtifactNames: [ - 'artifact2', - ], -}); -``` - -**Note**: when a CodeBuild Action in a Pipeline has more than one output, it -only uses the `secondary-artifacts` field of the buildspec, never the -primary output specification directly under `artifacts`. Because of that, it -pays to name even your primary output artifact on the Pipeline, like we did -above, so that you know what name to use in the buildspec. - -Example buildspec for the above project: - -```ts -const project = new codebuild.PipelineProject(this, 'MyProject', { - buildSpec: { - version: '0.2', - phases: { - build: { - commands: [ - // By default, you're in a directory with the contents of the repository from sourceAction1. - // Use the CODEBUILD_SRC_DIR_source2 environment variable - // to get a path to the directory with the contents of the second input repository. + build: { + commands: [ + 'cd $CODEBUILD_SRC_DIR_source2', + 'touch output2.txt', ], }, }, artifacts: { 'secondary-artifacts': { - 'artifact1': { - // primary Action output artifact, - // available as buildAction.outputArtifact - }, 'artifact2': { - // additional output artifact, - // available as buildAction.additionalOutputArtifact('artifact2') + 'base-directory': '$CODEBUILD_SRC_DIR_source2', + 'files': [ + 'output2.txt', + ], }, }, }, }, - // ... }); ``` diff --git a/packages/@aws-cdk/aws-codebuild/lib/index.ts b/packages/@aws-cdk/aws-codebuild/lib/index.ts index 77571a2a92c05..7fbe814d26429 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/index.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/index.ts @@ -1,4 +1,3 @@ -export * from './pipeline-actions'; export * from './pipeline-project'; export * from './project'; export * from './source'; diff --git a/packages/@aws-cdk/aws-codebuild/lib/project.ts b/packages/@aws-cdk/aws-codebuild/lib/project.ts index 83b62e543c32b..8cbef294970dd 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/project.ts +++ b/packages/@aws-cdk/aws-codebuild/lib/project.ts @@ -9,10 +9,6 @@ import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); import { BuildArtifacts, CodePipelineBuildArtifacts, NoBuildArtifacts } from './artifacts'; import { CfnProject } from './codebuild.generated'; -import { - CommonPipelineBuildActionProps, CommonPipelineTestActionProps, - PipelineBuildAction, PipelineTestAction -} from './pipeline-actions'; import { BuildSource, NoSource, SourceType } from './source'; const CODEPIPELINE_TYPE = 'CODEPIPELINE'; @@ -29,22 +25,6 @@ export interface IProject extends cdk.IConstruct, events.IEventRuleTarget { /** The IAM service Role of this Project. Undefined for imported Projects. */ readonly role?: iam.IRole; - /** - * Convenience method for creating a new {@link PipelineBuildAction CodeBuild build Action}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineBuildAction CodeBuild build Action} - */ - toCodePipelineBuildAction(props: CommonPipelineBuildActionProps): PipelineBuildAction; - - /** - * Convenience method for creating a new {@link PipelineTestAction CodeBuild test Action}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineTestAction CodeBuild test Action} - */ - toCodePipelineTestAction(props: CommonPipelineTestActionProps): PipelineTestAction; - /** * Defines a CloudWatch event rule triggered when the build project state * changes. You can filter specific build status events using an event @@ -189,20 +169,6 @@ export abstract class ProjectBase extends cdk.Construct implements IProject { public abstract export(): ProjectImportProps; - public toCodePipelineBuildAction(props: CommonPipelineBuildActionProps): PipelineBuildAction { - return new PipelineBuildAction({ - ...props, - project: this, - }); - } - - public toCodePipelineTestAction(props: CommonPipelineTestActionProps): PipelineTestAction { - return new PipelineTestAction({ - ...props, - project: this, - }); - } - /** * Defines a CloudWatch event rule triggered when the build project state * changes. You can filter specific build status events using an event diff --git a/packages/@aws-cdk/aws-codebuild/package.json b/packages/@aws-cdk/aws-codebuild/package.json index a33e23a67a674..cd285d8a51df6 100644 --- a/packages/@aws-cdk/aws-codebuild/package.json +++ b/packages/@aws-cdk/aws-codebuild/package.json @@ -76,7 +76,6 @@ "@aws-cdk/assets-docker": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", "@aws-cdk/aws-codecommit": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-ecr": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", @@ -90,7 +89,6 @@ "@aws-cdk/assets-docker": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", "@aws-cdk/aws-codecommit": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-ecr": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", @@ -101,4 +99,4 @@ "engines": { "node": ">= 8.10.0" } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-codecommit/README.md b/packages/@aws-cdk/aws-codecommit/README.md index 7bc6d9ff341d8..85165e9469dd8 100644 --- a/packages/@aws-cdk/aws-codecommit/README.md +++ b/packages/@aws-cdk/aws-codecommit/README.md @@ -23,33 +23,6 @@ To add an Amazon SNS trigger to your repository: repo.notify('arn:aws:sns:*:123456789012:my_topic'); ``` -## AWS CodePipeline - -To use a CodeCommit Repository in a CodePipeline: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', { - pipelineName: 'MyPipeline', -}); -const sourceAction = new codecommit.PipelineSourceAction({ - actionName: 'CodeCommit', - repository: repo, -}); -pipeline.addStage({ - name: 'Source', - actions: [sourceAction], -}); -``` - -You can also create the action from the Repository directly: - -```ts -// equivalent to the code above: -const sourceAction = repo.toCodePipelineSourceAction({ actionName: 'CodeCommit' }); -``` - ## Events CodeCommit repositories emit Amazon CloudWatch events for certain activities. diff --git a/packages/@aws-cdk/aws-codecommit/lib/index.ts b/packages/@aws-cdk/aws-codecommit/lib/index.ts index d2e8bb4a6494c..2fa63e2e6ef94 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/index.ts +++ b/packages/@aws-cdk/aws-codecommit/lib/index.ts @@ -1,4 +1,3 @@ -export * from './pipeline-action'; export * from './repository'; // AWS::CodeCommit CloudFormation Resources: diff --git a/packages/@aws-cdk/aws-codecommit/lib/repository.ts b/packages/@aws-cdk/aws-codecommit/lib/repository.ts index a1327ecdffde4..a524c0580b677 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/repository.ts +++ b/packages/@aws-cdk/aws-codecommit/lib/repository.ts @@ -1,7 +1,6 @@ import events = require('@aws-cdk/aws-events'); import cdk = require('@aws-cdk/cdk'); import { CfnRepository } from './codecommit.generated'; -import { CommonPipelineSourceActionProps, PipelineSourceAction } from './pipeline-action'; export interface IRepository extends cdk.IConstruct { /** The ARN of this Repository. */ @@ -16,14 +15,6 @@ export interface IRepository extends cdk.IConstruct { /** The SSH clone URL */ readonly repositoryCloneUrlSsh: string; - /** - * Convenience method for creating a new {@link PipelineSourceAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineSourceAction} - */ - toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): PipelineSourceAction; - /** * Defines a CloudWatch event rule which triggers for repository events. Use * `rule.addEventPattern(pattern)` to specify a filter. @@ -119,13 +110,6 @@ export abstract class RepositoryBase extends cdk.Construct implements IRepositor public abstract export(): RepositoryImportProps; - public toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): PipelineSourceAction { - return new PipelineSourceAction({ - ...props, - repository: this, - }); - } - /** * Defines a CloudWatch event rule which triggers for repository events. Use * `rule.addEventPattern(pattern)` to specify a filter. diff --git a/packages/@aws-cdk/aws-codecommit/package.json b/packages/@aws-cdk/aws-codecommit/package.json index e16f0af4f3d7a..e2469a1561182 100644 --- a/packages/@aws-cdk/aws-codecommit/package.json +++ b/packages/@aws-cdk/aws-codecommit/package.json @@ -48,7 +48,7 @@ "nyc": { "statements": 30, "lines": 30, - "branches": 38 + "branches": 36 }, "keywords": [ "aws", @@ -72,14 +72,12 @@ "pkglint": "^0.27.0" }, "dependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/cdk": "^0.27.0" }, "homepage": "https://github.com/awslabs/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/cdk": "^0.27.0" diff --git a/packages/@aws-cdk/aws-codedeploy/README.md b/packages/@aws-cdk/aws-codedeploy/README.md index 565949185d053..5e8d3b9aa74be 100644 --- a/packages/@aws-cdk/aws-codedeploy/README.md +++ b/packages/@aws-cdk/aws-codedeploy/README.md @@ -160,42 +160,6 @@ const deploymentConfig = codedeploy.ServerDeploymentConfig.import(this, 'Existin }); ``` -### Use in CodePipeline - -This module also contains an Action that allows you to use CodeDeploy with AWS CodePipeline. - -Example: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', { - pipelineName: 'MyPipeline', -}); - -// add the source and build Stages to the Pipeline... - -const deployAction = new codedeploy.PipelineDeployAction({ - actionName: 'CodeDeploy', - inputArtifact: buildAction.outputArtifact, - deploymentGroup, -}); -pipeline.addStage({ - name: 'Deploy', - actions: [deployAction], -}); -``` - -You can also create an action from the Deployment Group directly: - -```ts -// equivalent to the code above: -const deployAction = deploymentGroup.toCodePipelineDeployAction({ - actionName: 'CodeDeploy', - inputArtifact: buildAction.outputArtifact, -}); -``` - ### Lambda Applications To create a new CodeDeploy Application that deploys to a Lambda function: diff --git a/packages/@aws-cdk/aws-codedeploy/lib/index.ts b/packages/@aws-cdk/aws-codedeploy/lib/index.ts index d1d50615e1c8b..7b78d58755771 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/index.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/index.ts @@ -1,6 +1,5 @@ export * from './rollback-config'; export * from './lambda'; -export * from './pipeline-action'; export * from './server'; // AWS::CodeDeploy CloudFormation Resources: diff --git a/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-group.ts b/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-group.ts index 935aeec1ef99c..0b0200220aba2 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-group.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/server/deployment-group.ts @@ -6,7 +6,6 @@ import iam = require('@aws-cdk/aws-iam'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); import { CfnDeploymentGroup } from '../codedeploy.generated'; -import { CommonPipelineDeployActionProps, PipelineDeployAction } from '../pipeline-action'; import { AutoRollbackConfig } from '../rollback-config'; import { deploymentGroupNameToArn, renderAlarmConfiguration, renderAutoRollbackConfiguration } from '../utils'; import { IServerApplication, ServerApplication } from './application'; @@ -20,14 +19,6 @@ export interface IServerDeploymentGroup extends cdk.IConstruct { readonly deploymentConfig: IServerDeploymentConfig; readonly autoScalingGroups?: autoscaling.AutoScalingGroup[]; export(): ServerDeploymentGroupImportProps; - - /** - * Convenience method for creating a new {@link PipelineDeployAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineDeployAction} - */ - toCodePipelineDeployAction(props: CommonPipelineDeployActionProps): PipelineDeployAction; } /** @@ -81,14 +72,6 @@ export abstract class ServerDeploymentGroupBase extends cdk.Construct implements } public abstract export(): ServerDeploymentGroupImportProps; - - public toCodePipelineDeployAction(props: CommonPipelineDeployActionProps): - PipelineDeployAction { - return new PipelineDeployAction({ - ...props, - deploymentGroup: this, - }); - } } class ImportedServerDeploymentGroup extends ServerDeploymentGroupBase { diff --git a/packages/@aws-cdk/aws-codedeploy/package.json b/packages/@aws-cdk/aws-codedeploy/package.json index 476ca3fa1be3e..1fc461ede7280 100644 --- a/packages/@aws-cdk/aws-codedeploy/package.json +++ b/packages/@aws-cdk/aws-codedeploy/package.json @@ -74,7 +74,6 @@ "@aws-cdk/aws-autoscaling": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", "@aws-cdk/aws-codedeploy-api": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-lambda": "^0.27.0", "@aws-cdk/aws-s3": "^0.27.0", @@ -85,7 +84,6 @@ "@aws-cdk/aws-autoscaling": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", "@aws-cdk/aws-codedeploy-api": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-lambda": "^0.27.0", "@aws-cdk/cdk": "^0.27.0" @@ -98,4 +96,4 @@ "construct-ctor:@aws-cdk/aws-codedeploy.ServerDeploymentGroupBase..params[2]" ] } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-codepipeline-actions/.gitignore b/packages/@aws-cdk/aws-codepipeline-actions/.gitignore new file mode 100644 index 0000000000000..76066ee170e9f --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/.gitignore @@ -0,0 +1,17 @@ +*.js +tsconfig.json +tslint.json +*.js.map +*.d.ts +*.generated.ts +dist +lib/generated/resources.ts +*.tgz +.jsii + +.LAST_BUILD +.nyc_output +coverage +.nycrc +.LAST_PACKAGE +*.snk \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/.npmignore b/packages/@aws-cdk/aws-codepipeline-actions/.npmignore new file mode 100644 index 0000000000000..b757d55c46996 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/.npmignore @@ -0,0 +1,16 @@ +# Don't include original .ts files when doing `npm pack` +*.ts +!*.d.ts +coverage +.nyc_output +*.tgz + +dist +.LAST_PACKAGE +.LAST_BUILD +!*.js + +# Include .jsii +!.jsii + +*.snk \ No newline at end of file diff --git a/packages/@aws-cdk/aws-codepipeline-actions/LICENSE b/packages/@aws-cdk/aws-codepipeline-actions/LICENSE new file mode 100644 index 0000000000000..46c185646b439 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/NOTICE b/packages/@aws-cdk/aws-codepipeline-actions/NOTICE new file mode 100644 index 0000000000000..8585168af8b7d --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/NOTICE @@ -0,0 +1,2 @@ +AWS Cloud Development Kit (AWS CDK) +Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. diff --git a/packages/@aws-cdk/aws-codepipeline-actions/README.md b/packages/@aws-cdk/aws-codepipeline-actions/README.md new file mode 100644 index 0000000000000..1eaa460a66531 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/README.md @@ -0,0 +1,485 @@ +## AWS CodePipeline Actions + +This package contains Actions that can be used in a CodePipeline. + +```typescript +import codepipeline = require('@aws-cdk/aws-codepipeline'); +import codepipeline_actions = require('@aws-cdk/aws-codepipeline-actions'); +``` + +### Sources + +#### AWS CodeCommit + +To use a CodeCommit Repository in a CodePipeline: + +```ts +import codecommit = require('@aws-cdk/aws-codecommit'); + +const repo = new codecommit.Repository(this, 'Repo', { + // ... +}); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', { + pipelineName: 'MyPipeline', +}); +const sourceAction = new codepipeline_actions.CodeCommitSourceAction({ + actionName: 'CodeCommit', + repository: repo, +}); +pipeline.addStage({ + name: 'Source', + actions: [sourceAction], +}); +``` + +#### GitHub + +To use GitHub as the source of a CodePipeline: + +```typescript +// Read the secret from ParameterStore +const token = new cdk.SecretParameter(this, 'GitHubToken', { ssmParameter: 'my-github-token' }); +const sourceAction = new codepipeline_actions.GitHubSourceAction({ + actionName: 'GitHub_Source', + owner: 'awslabs', + repo: 'aws-cdk', + oauthToken: token.value, + outputArtifactName: 'SourceOutput', // this will be the name of the output artifact in the Pipeline + branch: 'develop', // default: 'master' +}); +pipeline.addStage({ + name: 'Source', + actions: [sourceAction], +}); +``` + +#### AWS S3 + +To use an S3 Bucket as a source in CodePipeline: + +```ts +import s3 = require('@aws-cdk/aws-s3'); + +const sourceBucket = new s3.Bucket(this, 'MyBucket', { + versioned: true, // a Bucket used as a source in CodePipeline must be versioned +}); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); +const sourceAction = new codepipeline_actions.S3SourceAction({ + actionName: 'S3Source', + bucket: sourceBucket, + bucketKey: 'path/to/file.zip', +}); +pipeline.addStage({ + name: 'Source', + actions: [sourceAction], +}); +``` + +By default, the Pipeline will poll the Bucket to detect changes. +You can change that behavior to use CloudWatch Events by setting the `pollForSourceChanges` +property to `false` (it's `true` by default). +If you do that, make sure the source Bucket is part of an AWS CloudTrail Trail - +otherwise, the CloudWatch Events will not be emitted, +and your Pipeline will not react to changes in the Bucket. +You can do it through the CDK: + +```typescript +import cloudtrail = require('@aws-cdk/aws-cloudtrail'); + +const key = 'some/key.zip'; +const trail = new cloudtrail.CloudTrail(this, 'CloudTrail'); +trail.addS3EventSelector([sourceBucket.arnForObjects(key)], cloudtrail.ReadWriteType.WriteOnly); +const sourceAction = new codepipeline_actions.S3SourceAction({ + actionName: 'S3Source', + bucketKey: key, + bucket: sourceBucket, + pollForSourceChanges: false, // default: true +}); +``` + +#### AWS ECR + +To use an ECR Repository as a source in a Pipeline: + +```ts +import ecr = require('@aws-cdk/aws-ecr'); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); +const sourceAction = new codepipeline_actions.EcrSourceAction({ + actionName: 'ECR', + repository: ecrRepository, + imageTag: 'some-tag', // optional, default: 'latest' + outputArtifactName: 'SomeName', // optional +}); +pipeline.addStage({ + actionName: 'Source', + actions: [sourceAction], +}); +``` + +### Build & test + +#### AWS CodeBuild + +Example of a CodeBuild Project used in a Pipeline, alongside CodeCommit: + +```typescript +import codebuild = require('@aws-cdk/aws-codebuild'); +import codecommit = require('@aws-cdk/aws-codecommit'); + +const repository = new codecommit.Repository(this, 'MyRepository', { + repositoryName: 'MyRepository', +}); +const project = new codebuild.PipelineProject(this, 'MyProject'); + +const sourceAction = new codepipeline_actions.CodeCommitSourceAction({ + actionName: 'CodeCommit', + repository, +}); +const buildAction = new codepipeline_actions.CodeBuildBuildAction({ + actionName: 'CodeBuild', + project, + inputArtifact: sourceAction.outputArtifact, +}); + +new codepipeline.Pipeline(this, 'MyPipeline', { + stages: [ + { + name: 'Source', + actions: [sourceAction], + }, + { + name: 'Build', + actions: [buildAction], + }, + ], +}); +``` + +The `PipelineProject` utility class is a simple sugar around the `Project` +class, it's equivalent to: + +```ts +const project = new codebuild.Project(this, 'MyProject', { + source: new codebuild.CodePipelineSource(), + artifacts: new codebuild.CodePipelineBuildArtifacts(), + // rest of the properties from PipelineProject are passed unchanged... +} +``` + +In addition to the build Action, there is also a test Action. It works very +similarly to the build Action, the only difference is that the test Action does +not always produce an output artifact. Example: + +```typescript +const testAction = new codepipeline_actions.CodeBuildTestAction({ + actionName: 'IntegrationTest', + project, + inputArtifact: sourceAction.outputArtifact, + // outputArtifactName is optional - if you don't specify it, + // the Action will have an undefined `outputArtifact` property + outputArtifactName: 'IntegrationTestOutput', +}); +``` + +##### Multiple inputs and outputs + +When you want to have multiple inputs and/or outputs for a Project used in a +Pipeline, instead of using the `secondarySources` and `secondaryArtifacts` +properties of the `Project` class, you need to use the `additionalInputArtifacts` and +`additionalOutputArtifactNames` properties of the CodeBuild CodePipeline +Actions. Example: + +```ts +const sourceAction1 = new codepipeline_actions.CodeCommitSourceAction({ + actionName: 'Source1', + repository: repository1, +}); +const sourceAction2 = new codepipeline_actions.CodeCommitSourceAction({ + actionName: 'Source2', + repository: repository2, + outputArtifactName: 'source2', +}); + +const buildAction = new codepipeline_actions.CodeBuildBuildAction({ + actionName: 'Build', + project, + inputArtifact: sourceAction1.outputArtifact, + outputArtifactName: 'artifact1', // for better buildspec readability - see below + additionalInputArtifacts: [ + sourceAction2.outputArtifact, // this is where 'source2' comes from + ], + additionalOutputArtifactNames: [ + 'artifact2', + ], +}); +``` + +**Note**: when a CodeBuild Action in a Pipeline has more than one output, it +only uses the `secondary-artifacts` field of the buildspec, never the +primary output specification directly under `artifacts`. Because of that, it +pays to name even your primary output artifact on the Pipeline, like we did +above, so that you know what name to use in the buildspec. + +Example buildspec for the above project: + +```ts +const project = new codebuild.PipelineProject(this, 'MyProject', { + buildSpec: { + version: '0.2', + phases: { + build: { + commands: [ + // By default, you're in a directory with the contents of the repository from sourceAction1. + // Use the CODEBUILD_SRC_DIR_source2 environment variable + // to get a path to the directory with the contents of the second input repository. + ], + }, + }, + artifacts: { + 'secondary-artifacts': { + 'artifact1': { + // primary Action output artifact, + // available as buildAction.outputArtifact + }, + 'artifact2': { + // additional output artifact, + // available as buildAction.additionalOutputArtifact('artifact2') + }, + }, + }, + }, + // ... +}); +``` + +#### Jenkins + +In order to use Jenkins Actions in the Pipeline, +you first need to create a `JenkinsProvider`: + +```ts +const jenkinsProvider = new codepipeline_actions.JenkinsProvider(this, 'JenkinsProvider', { + providerName: 'MyJenkinsProvider', + serverUrl: 'http://my-jenkins.com:8080', + version: '2', // optional, default: '1' +}); +``` + +If you've registered a Jenkins provider in a different CDK app, +or outside the CDK (in the CodePipeline AWS Console, for example), +you can import it: + +```ts +const jenkinsProvider = codepipeline_actions.JenkinsProvider.import(this, 'JenkinsProvider', { + providerName: 'MyJenkinsProvider', + serverUrl: 'http://my-jenkins.com:8080', + version: '2', // optional, default: '1' +}); +``` + +Note that a Jenkins provider +(identified by the provider name-category(build/test)-version tuple) +must always be registered in the given account, in the given AWS region, +before it can be used in CodePipeline. + +With a `JenkinsProvider`, +we can create a Jenkins Action: + +```ts +const buildAction = new codepipeline_actions.JenkinsBuildAction({ + actionName: 'JenkinsBuild', + jenkinsProvider: jenkinsProvider, + projectName: 'MyProject', +}); +// there's also a JenkinsTestAction that works identically +``` + +### Deploy + +#### AWS 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](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: + +* **CloudFormationCreateUpdateStackAction** - 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). +* **CloudFormationDeleteStackAction** - Delete the stack with the given name. +* **CloudFormationCreateReplaceChangeSetAction** - 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. +* **CloudFormationExecuteChangeSetAction** - Execute a change set prepared previously. + +#### AWS CodeDeploy + +To use CodeDeploy in a Pipeline: + +```ts +import codedeploy = require('@aws-cdk/aws-codedeploy'); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline', { + pipelineName: 'MyPipeline', +}); + +// add the source and build Stages to the Pipeline... + +const deployAction = new codepipeline_actions.CodeDeployServerDeployAction({ + actionName: 'CodeDeploy', + inputArtifact: buildAction.outputArtifact, + deploymentGroup, +}); +pipeline.addStage({ + name: 'Deploy', + actions: [deployAction], +}); +``` + +#### AWS S3 + +To use an S3 Bucket as a deployment target in CodePipeline: + +```ts +const targetBucket = new s3.Bucket(this, 'MyBucket', {}); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); +const deployAction = new codepipeline_actions.S3DeployAction({ + actionName: 'S3Deploy', + stage: deployStage, + bucket: targetBucket, + inputArtifact: sourceAction.outputArtifact, +}); +const deployStage = pipeline.addStage({ + name: 'Deploy', + actions: [deployAction], +}); +``` + +#### Alexa Skill + +You can deploy to Alexa using CodePipeline with the following Action: + +```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 codepipeline_actions.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 codepipeline_actions.CloudFormationExecuteChangeSetAction({ + actionName: 'ExecuteChangesTest', + runOrder: 2, + stackName, + changeSetName, + outputFileName: 'overrides.json', + outputArtifactName: 'CloudFormation', +}); + +// Provide CFN output as manifest overrides +new codepipeline_actions.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', +}); +``` + +### Approve & invoke + +#### Manual approval Action + +This package contains an Action that stops the Pipeline until someone manually clicks the approve button: + +```typescript +const manualApprovalAction = new codepipeline.ManualApprovalAction({ + actionName: 'Approve', + notificationTopic: new sns.Topic(this, 'Topic'), // optional + notifyEmails: [ + 'some_email@example.com', + ], // optional + additionalInformation: 'additional info', // optional +}); +approveStage.addAction(manualApprovalAction); +// `manualApprovalAction.notificationTopic` can be used to access the Topic +// after the Action has been added to a Pipeline +``` + +If the `notificationTopic` has not been provided, +but `notifyEmails` were, +a new SNS Topic will be created +(and accessible through the `notificationTopic` property of the Action). + +#### AWS Lambda + +This module contains an Action that allows you to invoke a Lambda function in a Pipeline: + +```ts +import lambda = require('@aws-cdk/aws-lambda'); + +const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); +const lambdaAction = new codepipeline_actions.LambdaInvokeAction({ + actionName: 'Lambda', + lambda: fn, +}); +pipeline.addStage({ + actionName: 'Lambda', + actions: [lambdaAction], +}); +``` + +The Lambda Action can have up to 5 inputs, +and up to 5 outputs: + +```typescript +const lambdaAction = new codepipeline_actions.LambdaInvokeAction({ + actionName: 'Lambda', + inputArtifacts: [ + sourceAction.outputArtifact, + buildAction.outputArtifact, + ], + outputArtifactNames: [ + 'Out1', + 'Out2', + ], +}); + +lambdaAction.outputArtifacts(); // returns the list of output Artifacts +lambdaAction.outputArtifact('Out2'); // returns the named output Artifact, or throws an exception if not found +``` + +See [the AWS documentation](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html) +on how to write a Lambda function invoked from CodePipeline. diff --git a/packages/@aws-cdk/alexa-ask/lib/pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/alexa-ask/deploy-action.ts similarity index 96% rename from packages/@aws-cdk/alexa-ask/lib/pipeline-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/alexa-ask/deploy-action.ts index c41e41df77cb2..e8ddff227b048 100644 --- a/packages/@aws-cdk/alexa-ask/lib/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/alexa-ask/deploy-action.ts @@ -1,4 +1,4 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); /** diff --git a/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts similarity index 83% rename from packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts index d717fe04baa76..f6aa697bd6489 100644 --- a/packages/@aws-cdk/aws-cloudformation/lib/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/cloudformation/pipeline-actions.ts @@ -1,11 +1,12 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import cloudformation = require('@aws-cdk/aws-cloudformation'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); /** * Properties common to all CloudFormation actions */ -export interface PipelineCloudFormationActionProps extends codepipeline.CommonActionProps { +export interface CloudFormationActionProps extends codepipeline.CommonActionProps { /** * The name of the stack to apply this action to */ @@ -57,7 +58,7 @@ export interface PipelineCloudFormationActionProps extends codepipeline.CommonAc /** * Base class for Actions that execute CloudFormation */ -export abstract class PipelineCloudFormationAction extends codepipeline.Action { +export abstract class CloudFormationAction extends codepipeline.Action { /** * CfnOutput artifact containing the CloudFormation call response * @@ -65,7 +66,7 @@ export abstract class PipelineCloudFormationAction extends codepipeline.Action { */ public outputArtifact?: codepipeline.Artifact; - constructor(props: PipelineCloudFormationActionProps, configuration?: any) { + constructor(props: CloudFormationActionProps, configuration?: any) { super({ ...props, region: props.region, @@ -92,9 +93,9 @@ export abstract class PipelineCloudFormationAction extends codepipeline.Action { } /** - * Properties for the PipelineExecuteChangeSetAction. + * Properties for the CloudFormationExecuteChangeSetAction. */ -export interface PipelineExecuteChangeSetActionProps extends PipelineCloudFormationActionProps { +export interface CloudFormationExecuteChangeSetActionProps extends CloudFormationActionProps { /** * Name of the change set to execute. */ @@ -104,10 +105,10 @@ export interface PipelineExecuteChangeSetActionProps extends PipelineCloudFormat /** * CodePipeline action to execute a prepared change set. */ -export class PipelineExecuteChangeSetAction extends PipelineCloudFormationAction { - private readonly props: PipelineExecuteChangeSetActionProps; +export class CloudFormationExecuteChangeSetAction extends CloudFormationAction { + private readonly props: CloudFormationExecuteChangeSetActionProps; - constructor(props: PipelineExecuteChangeSetActionProps) { + constructor(props: CloudFormationExecuteChangeSetActionProps) { super(props, { ActionMode: 'CHANGE_SET_EXECUTE', ChangeSetName: props.changeSetName, @@ -125,7 +126,7 @@ export class PipelineExecuteChangeSetAction extends PipelineCloudFormationAction /** * Properties common to CloudFormation actions that stage deployments */ -export interface PipelineCloudFormationDeployActionProps extends PipelineCloudFormationActionProps { +export interface CloudFormationDeployActionProps extends CloudFormationActionProps { /** * IAM role to assume when deploying changes. * @@ -148,7 +149,7 @@ export interface PipelineCloudFormationDeployActionProps extends PipelineCloudFo * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-iam-template.html#using-iam-capabilities * @default None, unless `adminPermissions` is true */ - readonly capabilities?: CloudFormationCapabilities; + readonly capabilities?: cloudformation.CloudFormationCapabilities; /** * Whether to grant full permissions to CloudFormation while deploying this template. @@ -222,12 +223,14 @@ export interface PipelineCloudFormationDeployActionProps extends PipelineCloudFo /** * Base class for all CloudFormation actions that execute or stage deployments. */ -export abstract class PipelineCloudFormationDeployAction extends PipelineCloudFormationAction { +export abstract class CloudFormationDeployAction extends CloudFormationAction { private _deploymentRole?: iam.IRole; - private readonly props: PipelineCloudFormationDeployActionProps; + private readonly props: CloudFormationDeployActionProps; - constructor(props: PipelineCloudFormationDeployActionProps, configuration: any) { - const capabilities = props.adminPermissions && props.capabilities === undefined ? CloudFormationCapabilities.NamedIAM : props.capabilities; + constructor(props: CloudFormationDeployActionProps, configuration: any) { + const capabilities = props.adminPermissions && props.capabilities === undefined + ? cloudformation.CloudFormationCapabilities.NamedIAM + : props.capabilities; super(props, { ...configuration, // None evaluates to empty string which is falsey and results in undefined @@ -282,9 +285,9 @@ export abstract class PipelineCloudFormationDeployAction extends PipelineCloudFo } /** - * Properties for the PipelineCreateReplaceChangeSetAction. + * Properties for the CloudFormationCreateReplaceChangeSetAction. */ -export interface PipelineCreateReplaceChangeSetActionProps extends PipelineCloudFormationDeployActionProps { +export interface CloudFormationCreateReplaceChangeSetActionProps extends CloudFormationDeployActionProps { /** * Name of the change set to create or update. */ @@ -302,10 +305,10 @@ export interface PipelineCreateReplaceChangeSetActionProps extends PipelineCloud * Creates the change set if it doesn't exist based on the stack name and template that you submit. * If the change set exists, AWS CloudFormation deletes it, and then creates a new one. */ -export class PipelineCreateReplaceChangeSetAction extends PipelineCloudFormationDeployAction { - private readonly props2: PipelineCreateReplaceChangeSetActionProps; +export class CloudFormationCreateReplaceChangeSetAction extends CloudFormationDeployAction { + private readonly props2: CloudFormationCreateReplaceChangeSetActionProps; - constructor(props: PipelineCreateReplaceChangeSetActionProps) { + constructor(props: CloudFormationCreateReplaceChangeSetActionProps) { super(props, { ActionMode: 'CHANGE_SET_REPLACE', ChangeSetName: props.changeSetName, @@ -328,9 +331,9 @@ export class PipelineCreateReplaceChangeSetAction extends PipelineCloudFormation } /** - * Properties for the PipelineCreateUpdateStackAction. + * Properties for the CloudFormationCreateUpdateStackAction. */ -export interface PipelineCreateUpdateStackActionProps extends PipelineCloudFormationDeployActionProps { +export interface CloudFormationCreateUpdateStackActionProps extends CloudFormationDeployActionProps { /** * Input artifact with the CloudFormation template to deploy */ @@ -366,10 +369,10 @@ export interface PipelineCreateUpdateStackActionProps extends PipelineCloudForma * Use this action to automatically replace failed stacks without recovering or * troubleshooting them. You would typically choose this mode for testing. */ -export class PipelineCreateUpdateStackAction extends PipelineCloudFormationDeployAction { - private readonly props2: PipelineCreateUpdateStackActionProps; +export class CloudFormationCreateUpdateStackAction extends CloudFormationDeployAction { + private readonly props2: CloudFormationCreateUpdateStackActionProps; - constructor(props: PipelineCreateUpdateStackActionProps) { + constructor(props: CloudFormationCreateUpdateStackActionProps) { super(props, { ActionMode: props.replaceOnFailure ? 'REPLACE_ON_FAILURE' : 'CREATE_UPDATE', TemplatePath: props.templatePath.location @@ -391,10 +394,10 @@ export class PipelineCreateUpdateStackAction extends PipelineCloudFormationDeplo } /** - * Properties for the PipelineDeleteStackAction. + * Properties for the CloudFormationDeleteStackAction. */ // tslint:disable-next-line:no-empty-interface -export interface PipelineDeleteStackActionProps extends PipelineCloudFormationDeployActionProps { +export interface CloudFormationDeleteStackActionProps extends CloudFormationDeployActionProps { } /** @@ -403,10 +406,10 @@ export interface PipelineDeleteStackActionProps extends PipelineCloudFormationDe * Deletes a stack. If you specify a stack that doesn't exist, the action completes successfully * without deleting a stack. */ -export class PipelineDeleteStackAction extends PipelineCloudFormationDeployAction { - private readonly props2: PipelineDeleteStackActionProps; +export class CloudFormationDeleteStackAction extends CloudFormationDeployAction { + private readonly props2: CloudFormationDeleteStackActionProps; - constructor(props: PipelineDeleteStackActionProps) { + constructor(props: CloudFormationDeleteStackActionProps) { super(props, { ActionMode: 'DELETE_ONLY', }); @@ -421,38 +424,6 @@ export class PipelineDeleteStackAction extends PipelineCloudFormationDeployActio } } -/** - * 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', -} - /** * Manages a bunch of singleton-y statements on the policy of an IAM Role. * Dedicated methods can be used to add specific permissions to the role policy diff --git a/packages/@aws-cdk/aws-codebuild/lib/pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/pipeline-actions.ts similarity index 72% rename from packages/@aws-cdk/aws-codebuild/lib/pipeline-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/pipeline-actions.ts index 9d0728f6b7176..21ab3255eec60 100644 --- a/packages/@aws-cdk/aws-codebuild/lib/pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codebuild/pipeline-actions.ts @@ -1,11 +1,16 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codebuild = require('@aws-cdk/aws-codebuild'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); -import { IProject } from './project'; /** * Common construction properties of all CodeBuild Pipeline Actions. */ -export interface CommonCodeBuildActionProps { +export interface CommonCodeBuildActionProps extends codepipeline.CommonActionProps { + /** + * The source to use as input for this Action. + */ + readonly inputArtifact: codepipeline.Artifact; + /** * The list of additional input Artifacts for this Action. */ @@ -17,20 +22,17 @@ export interface CommonCodeBuildActionProps { * method of the Action. */ readonly additionalOutputArtifactNames?: string[]; -} -/** - * Common properties for creating {@link PipelineBuildAction} - - * either directly, through its constructor, - * or through {@link IProject#toCodePipelineBuildAction}. - */ -export interface CommonPipelineBuildActionProps extends CommonCodeBuildActionProps, - codepipeline.CommonActionProps { /** - * The source to use as input for this build. + * The Action's Project. */ - readonly inputArtifact: codepipeline.Artifact; + readonly project: codebuild.IProject; +} +/** + * Construction properties of the {@link CodeBuildBuildAction CodeBuild build CodePipeline Action}. + */ +export interface CodeBuildBuildActionProps extends CommonCodeBuildActionProps { /** * The name of the build's output artifact. * @@ -39,23 +41,13 @@ export interface CommonPipelineBuildActionProps extends CommonCodeBuildActionPro readonly outputArtifactName?: string; } -/** - * Construction properties of the {@link PipelineBuildAction CodeBuild build CodePipeline Action}. - */ -export interface PipelineBuildActionProps extends CommonPipelineBuildActionProps { - /** - * The build project - */ - readonly project: IProject; -} - /** * CodePipeline build Action that uses AWS CodeBuild. */ -export class PipelineBuildAction extends codepipeline.BuildAction { - private readonly props: PipelineBuildActionProps; +export class CodeBuildBuildAction extends codepipeline.BuildAction { + private readonly props: CodeBuildBuildActionProps; - constructor(props: PipelineBuildActionProps) { + constructor(props: CodeBuildBuildActionProps) { super({ ...props, provider: 'CodeBuild', @@ -70,6 +62,7 @@ export class PipelineBuildAction extends codepipeline.BuildAction { handleAdditionalInputOutputArtifacts(props, this, // pass functions to get around protected members + this.actionInputArtifacts, (artifact) => this.addInputArtifact(artifact), (artifactName) => this.addOutputArtifact(artifactName)); } @@ -83,8 +76,7 @@ export class PipelineBuildAction extends codepipeline.BuildAction { * @see #additionalOutputArtifact */ public additionalOutputArtifacts(): codepipeline.Artifact[] { - // TODO: remove "as any" when we centralize all actions - return (this as any)._outputArtifacts.slice(1); + return this.actionOutputArtifacts.slice(1); } /** @@ -108,17 +100,9 @@ export class PipelineBuildAction extends codepipeline.BuildAction { } /** - * Common properties for creating {@link PipelineTestAction} - - * either directly, through its constructor, - * or through {@link IProject#toCodePipelineTestAction}. + * Construction properties of the {@link CodeBuildTestAction CodeBuild test CodePipeline Action}. */ -export interface CommonPipelineTestActionProps extends CommonCodeBuildActionProps, - codepipeline.CommonActionProps { - /** - * The source to use as input for this test. - */ - readonly inputArtifact: codepipeline.Artifact; - +export interface CodeBuildTestActionProps extends CommonCodeBuildActionProps { /** * The optional name of the primary output artifact. * If you provide a value here, @@ -131,19 +115,12 @@ export interface CommonPipelineTestActionProps extends CommonCodeBuildActionProp } /** - * Construction properties of the {@link PipelineTestAction CodeBuild test CodePipeline Action}. + * CodePipeline test Action that uses AWS CodeBuild. */ -export interface PipelineTestActionProps extends CommonPipelineTestActionProps { - /** - * The build Project. - */ - readonly project: IProject; -} - -export class PipelineTestAction extends codepipeline.TestAction { - private readonly props: PipelineTestActionProps; +export class CodeBuildTestAction extends codepipeline.TestAction { + private readonly props: CodeBuildTestActionProps; - constructor(props: PipelineTestActionProps) { + constructor(props: CodeBuildTestActionProps) { super({ ...props, provider: 'CodeBuild', @@ -157,6 +134,7 @@ export class PipelineTestAction extends codepipeline.TestAction { handleAdditionalInputOutputArtifacts(props, this, // pass functions to get around protected members + this.actionInputArtifacts, (artifact) => this.addInputArtifact(artifact), (artifactName) => this.addOutputArtifact(artifactName)); } @@ -170,10 +148,9 @@ export class PipelineTestAction extends codepipeline.TestAction { * @see #additionalOutputArtifact */ public additionalOutputArtifacts(): codepipeline.Artifact[] { - // TODO: revert "as any" when we centralize pipeline actions. return this.outputArtifact === undefined - ? (this as any)._outputArtifacts - : (this as any)._outputArtifacts.slice(1); + ? this.actionOutputArtifacts + : this.actionOutputArtifacts.slice(1); } /** @@ -192,12 +169,11 @@ export class PipelineTestAction extends codepipeline.TestAction { } protected bind(info: codepipeline.ActionBind): void { - // TODO: revert "as any" when we centralize pipeline actions - setCodeBuildNeededPermissions(info, this.props.project, (this as any)._outputArtifacts.length > 0); + setCodeBuildNeededPermissions(info, this.props.project, this.actionOutputArtifacts.length > 0); } } -function setCodeBuildNeededPermissions(info: codepipeline.ActionBind, project: IProject, +function setCodeBuildNeededPermissions(info: codepipeline.ActionBind, project: codebuild.IProject, needsPipelineBucketWrite: boolean): void { // grant the Pipeline role the required permissions to this Project info.role.addToPolicy(new iam.PolicyStatement() @@ -217,12 +193,12 @@ function setCodeBuildNeededPermissions(info: codepipeline.ActionBind, project: I } function handleAdditionalInputOutputArtifacts(props: CommonCodeBuildActionProps, action: codepipeline.Action, + inputArtifacts: codepipeline.Artifact[], addInputArtifact: (_: codepipeline.Artifact) => void, addOutputArtifact: (_: string) => void) { if ((props.additionalInputArtifacts || []).length > 0) { // we have to set the primary source in the configuration - // TODO: revert "as any" when we centralize pipeline actions - action.configuration.PrimarySource = (action as any)._inputArtifacts[0].artifactName; + action.configuration.PrimarySource = inputArtifacts[0].artifactName; // add the additional artifacts for (const additionalInputArtifact of props.additionalInputArtifacts || []) { addInputArtifact(additionalInputArtifact); diff --git a/packages/@aws-cdk/aws-codecommit/lib/pipeline-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts similarity index 67% rename from packages/@aws-cdk/aws-codecommit/lib/pipeline-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts index ce3332ecca275..3a44d307c5d4c 100644 --- a/packages/@aws-cdk/aws-codecommit/lib/pipeline-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts @@ -1,16 +1,14 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); -import { IRepository } from './repository'; /** - * Common properties for creating {@link PipelineSourceAction} - - * either directly, through its constructor, - * or through {@link IRepository#toCodePipelineSourceAction}. + * Construction properties of the {@link CodeCommitSourceAction CodeCommit source CodePipeline Action}. */ -export interface CommonPipelineSourceActionProps extends codepipeline.CommonActionProps { +export interface CodeCommitSourceActionProps extends codepipeline.CommonActionProps { /** * The name of the source's output artifact. - * CfnOutput artifacts are used by CodePipeline as inputs into other actions. + * Output artifacts are used by CodePipeline as inputs into other actions. * * @default a name will be auto-generated */ @@ -28,25 +26,20 @@ export interface CommonPipelineSourceActionProps extends codepipeline.CommonActi * @default false */ readonly pollForSourceChanges?: boolean; -} -/** - * Construction properties of the {@link PipelineSourceAction CodeCommit source CodePipeline Action}. - */ -export interface PipelineSourceActionProps extends CommonPipelineSourceActionProps { /** * The CodeCommit repository. */ - readonly repository: IRepository; + readonly repository: codecommit.IRepository; } /** * CodePipeline Source that is provided by an AWS CodeCommit repository. */ -export class PipelineSourceAction extends codepipeline.SourceAction { - private readonly props: PipelineSourceActionProps; +export class CodeCommitSourceAction extends codepipeline.SourceAction { + private readonly props: CodeCommitSourceActionProps; - constructor(props: PipelineSourceActionProps) { + constructor(props: CodeCommitSourceActionProps) { super({ ...props, provider: 'CodeCommit', diff --git a/packages/@aws-cdk/aws-codedeploy/lib/pipeline-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/server-deploy-action.ts similarity index 65% rename from packages/@aws-cdk/aws-codedeploy/lib/pipeline-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/server-deploy-action.ts index 6f8eefe426881..f576c40ed359e 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/pipeline-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/server-deploy-action.ts @@ -1,33 +1,26 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codedeploy = require('@aws-cdk/aws-codedeploy'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); -import { IServerDeploymentGroup } from './server'; /** - * Common properties for creating a {@link PipelineDeployAction}, - * either directly, through its constructor, - * or through {@link IServerDeploymentGroup#toCodePipelineDeployAction}. + * Construction properties of the {@link CodeDeployServerDeployAction CodeDeploy server deploy CodePipeline Action}. */ -export interface CommonPipelineDeployActionProps extends codepipeline.CommonActionProps { +export interface CodeDeployServerDeployActionProps extends codepipeline.CommonActionProps { /** * The source to use as input for deployment. */ readonly inputArtifact: codepipeline.Artifact; -} -/** - * Construction properties of the {@link PipelineDeployAction CodeDeploy deploy CodePipeline Action}. - */ -export interface PipelineDeployActionProps extends CommonPipelineDeployActionProps { /** - * The CodeDeploy Deployment Group to deploy to. + * The CodeDeploy server Deployment Group to deploy to. */ - readonly deploymentGroup: IServerDeploymentGroup; + readonly deploymentGroup: codedeploy.IServerDeploymentGroup; } -export class PipelineDeployAction extends codepipeline.DeployAction { - private readonly deploymentGroup: IServerDeploymentGroup; +export class CodeDeployServerDeployAction extends codepipeline.DeployAction { + private readonly deploymentGroup: codedeploy.IServerDeploymentGroup; - constructor(props: PipelineDeployActionProps) { + constructor(props: CodeDeployServerDeployActionProps) { super({ ...props, artifactBounds: { minInputs: 1, maxInputs: 1, minOutputs: 0, maxOutputs: 0 }, diff --git a/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts similarity index 93% rename from packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts index d1920ac6e7195..ed5881287509d 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/custom-action-registration.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/custom-action-registration.ts @@ -1,6 +1,5 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import { CfnCustomActionType } from './codepipeline.generated'; /** * The creation attributes used for defining a configuration property @@ -71,12 +70,12 @@ export interface CustomActionRegistrationProps { /** * The category of the Action. */ - category: cpapi.ActionCategory; + category: codepipeline.ActionCategory; /** * The artifact bounds of the Action. */ - artifactBounds: cpapi.ActionArtifactBounds; + artifactBounds: codepipeline.ActionArtifactBounds; /** * The provider of the Action. @@ -119,7 +118,7 @@ export class CustomActionRegistration extends cdk.Construct { constructor(parent: cdk.Construct, id: string, props: CustomActionRegistrationProps) { super(parent, id); - new CfnCustomActionType(this, 'Resource', { + new codepipeline.CfnCustomActionType(this, 'Resource', { category: props.category, inputArtifactDetails: { minimumCount: props.artifactBounds.minInputs, diff --git a/packages/@aws-cdk/aws-ecr/lib/pipeline-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts similarity index 61% rename from packages/@aws-cdk/aws-ecr/lib/pipeline-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts index 22d49211d23b5..be2f4f964e144 100644 --- a/packages/@aws-cdk/aws-ecr/lib/pipeline-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts @@ -1,13 +1,11 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); +import ecr = require('@aws-cdk/aws-ecr'); import iam = require('@aws-cdk/aws-iam'); -import { IRepository } from './repository-ref'; /** - * Common properties for the {@link PipelineSourceAction CodePipeline source Action}, - * whether creating it directly, - * or through the {@link IRepository#toCodePipelineSourceAction} method. + * Construction properties of {@link EcrSourceAction}. */ -export interface CommonPipelineSourceActionProps extends codepipeline.CommonActionProps { +export interface EcrSourceActionProps extends codepipeline.CommonActionProps { /** * The image tag that will be checked for changes. * @@ -22,25 +20,20 @@ export interface CommonPipelineSourceActionProps extends codepipeline.CommonActi * @default a name will be auto-generated */ readonly outputArtifactName?: string; -} -/** - * Construction properties of {@link PipelineSourceAction}. - */ -export interface PipelineSourceActionProps extends CommonPipelineSourceActionProps { /** * The repository that will be watched for changes. */ - readonly repository: IRepository; + readonly repository: ecr.IRepository; } /** * The ECR Repository source CodePipeline Action. */ -export class PipelineSourceAction extends codepipeline.SourceAction { - private readonly props: PipelineSourceActionProps; +export class EcrSourceAction extends codepipeline.SourceAction { + private readonly props: EcrSourceActionProps; - constructor(props: PipelineSourceActionProps) { + constructor(props: EcrSourceActionProps) { super({ ...props, provider: 'ECR', diff --git a/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts similarity index 86% rename from packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts index 294cfe9371bff..763df2a635eaf 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/github-source-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/github/source-action.ts @@ -1,11 +1,10 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import { CfnWebhook } from './codepipeline.generated'; /** * Construction properties of the {@link GitHubSourceAction GitHub source action}. */ -export interface GitHubSourceActionProps extends cpapi.CommonActionProps { +export interface GitHubSourceActionProps extends codepipeline.CommonActionProps { /** * The name of the source's output artifact. CfnOutput artifacts are used by CodePipeline as * inputs into other actions. @@ -52,7 +51,7 @@ export interface GitHubSourceActionProps extends cpapi.CommonActionProps { /** * Source that is provided by a GitHub repository. */ -export class GitHubSourceAction extends cpapi.SourceAction { +export class GitHubSourceAction extends codepipeline.SourceAction { private readonly props: GitHubSourceActionProps; constructor(props: GitHubSourceActionProps) { @@ -73,9 +72,9 @@ export class GitHubSourceAction extends cpapi.SourceAction { this.props = props; } - protected bind(info: cpapi.ActionBind): void { + protected bind(info: codepipeline.ActionBind): void { if (!this.props.pollForSourceChanges) { - new CfnWebhook(info.scope, 'WebhookResource', { + new codepipeline.CfnWebhook(info.scope, 'WebhookResource', { authentication: 'GITHUB_HMAC', authenticationConfiguration: { secretToken: this.props.oauthToken.toString(), diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/index.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/index.ts new file mode 100644 index 0000000000000..6ae1d7f82ea89 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/index.ts @@ -0,0 +1,13 @@ +export * from './alexa-ask/deploy-action'; +export * from './cloudformation/pipeline-actions'; +export * from './codebuild/pipeline-actions'; +export * from './codecommit/source-action'; +export * from './codedeploy/server-deploy-action'; +export * from './ecr/source-action'; +export * from './github/source-action'; +export * from './jenkins/jenkins-actions'; +export * from './jenkins/jenkins-provider'; +export * from './lambda/invoke-action'; +export * from './manual-approval-action'; +export * from './s3/deploy-action'; +export * from './s3/source-action'; diff --git a/packages/@aws-cdk/aws-codepipeline/lib/jenkins-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-actions.ts similarity index 68% rename from packages/@aws-cdk/aws-codepipeline/lib/jenkins-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-actions.ts index d7569b5ddcb76..70a58fe5e2118 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/jenkins-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-actions.ts @@ -1,10 +1,10 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import { IJenkinsProvider, jenkinsArtifactsBounds } from "./jenkins-provider"; /** * Common construction properties of all Jenkins Pipeline Actions. */ -export interface BasicJenkinsActionProps extends cpapi.CommonActionProps { +export interface CommonJenkinsActionProps extends codepipeline.CommonActionProps { /** * The name of the project (sometimes also called job, or task) * on your Jenkins installation that will be invoked by this Action. @@ -16,31 +16,24 @@ export interface BasicJenkinsActionProps extends cpapi.CommonActionProps { /** * The source to use as input for this build. */ - readonly inputArtifact: cpapi.Artifact; -} + readonly inputArtifact: codepipeline.Artifact; -/** - * Common properties for creating {@link JenkinsBuildAction} - - * either directly, through its constructor, - * or through {@link IJenkinsProvider#toCodePipelineBuildAction}. - */ -export interface BasicJenkinsBuildActionProps extends BasicJenkinsActionProps { /** - * The name of the build's output artifact. - * - * @default an auto-generated name will be used + * The Jenkins Provider for this Action. */ - readonly outputArtifactName?: string; + readonly jenkinsProvider: IJenkinsProvider; } /** * Construction properties of {@link JenkinsBuildAction}. */ -export interface JenkinsBuildActionProps extends BasicJenkinsBuildActionProps { +export interface JenkinsBuildActionProps extends CommonJenkinsActionProps { /** - * The Jenkins Provider for this Action. + * The name of the build's output artifact. + * + * @default an auto-generated name will be used */ - readonly jenkinsProvider: IJenkinsProvider; + readonly outputArtifactName?: string; } /** @@ -48,7 +41,7 @@ export interface JenkinsBuildActionProps extends BasicJenkinsBuildActionProps { * * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-four-stage-pipeline.html */ -export class JenkinsBuildAction extends cpapi.BuildAction { +export class JenkinsBuildAction extends codepipeline.BuildAction { private readonly jenkinsProvider: IJenkinsProvider; constructor(props: JenkinsBuildActionProps) { @@ -67,17 +60,15 @@ export class JenkinsBuildAction extends cpapi.BuildAction { this.jenkinsProvider = props.jenkinsProvider; } - protected bind(_info: cpapi.ActionBind): void { + protected bind(_info: codepipeline.ActionBind): void { this.jenkinsProvider._registerBuildProvider(); } } /** - * Common properties for creating {@link JenkinsTestAction} - - * either directly, through its constructor, - * or through {@link IJenkinsProvider#toCodePipelineTestAction}. + * Construction properties of {@link JenkinsTestAction}. */ -export interface BasicJenkinsTestActionProps extends BasicJenkinsActionProps { +export interface JenkinsTestActionProps extends CommonJenkinsActionProps { /** * The optional name of the primary output artifact. * If you provide a value here, @@ -89,22 +80,12 @@ export interface BasicJenkinsTestActionProps extends BasicJenkinsActionProps { readonly outputArtifactName?: string; } -/** - * Construction properties of {@link JenkinsTestAction}. - */ -export interface JenkinsTestActionProps extends BasicJenkinsTestActionProps { - /** - * The Jenkins Provider for this Action. - */ - readonly jenkinsProvider: IJenkinsProvider; -} - /** * Jenkins test CodePipeline Action. * * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-four-stage-pipeline.html */ -export class JenkinsTestAction extends cpapi.TestAction { +export class JenkinsTestAction extends codepipeline.TestAction { private readonly jenkinsProvider: IJenkinsProvider; constructor(props: JenkinsTestActionProps) { @@ -122,7 +103,7 @@ export class JenkinsTestAction extends cpapi.TestAction { this.jenkinsProvider = props.jenkinsProvider; } - protected bind(_info: cpapi.ActionBind): void { + protected bind(_info: codepipeline.ActionBind): void { this.jenkinsProvider._registerTestProvider(); } } diff --git a/packages/@aws-cdk/aws-codepipeline/lib/jenkins-provider.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts similarity index 81% rename from packages/@aws-cdk/aws-codepipeline/lib/jenkins-provider.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts index 942338f1e6723..58287ce3346e5 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/jenkins-provider.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/jenkins/jenkins-provider.ts @@ -1,12 +1,6 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import { CustomActionRegistration } from "./custom-action-registration"; -import { - BasicJenkinsBuildActionProps, - BasicJenkinsTestActionProps, - JenkinsBuildAction, - JenkinsTestAction -} from "./jenkins-actions"; +import { CustomActionRegistration } from "../custom-action-registration"; /** * A Jenkins provider. @@ -22,24 +16,6 @@ export interface IJenkinsProvider extends cdk.IConstruct { readonly serverUrl: string; readonly version: string; - /** - * Convenience method for creating a new {@link JenkinsBuildAction}. - * - * @param props construction properties of the new Action - * @returns the newly created {@link JenkinsBuildAction} - */ - toCodePipelineBuildAction(props: BasicJenkinsBuildActionProps): - JenkinsBuildAction; - - /** - * Convenience method for creating a new {@link JenkinsTestAction}. - * - * @param props construction properties of the new Action - * @returns the newly created {@link JenkinsTestAction} - */ - toCodePipelineTestAction(props: BasicJenkinsTestActionProps): - JenkinsTestAction; - /** * Registers a Jenkins Provider for the build category. * This method will be automatically called when creating @@ -147,20 +123,6 @@ export abstract class BaseJenkinsProvider extends cdk.Construct implements IJenk }; } - public toCodePipelineBuildAction(props: BasicJenkinsBuildActionProps): JenkinsBuildAction { - return new JenkinsBuildAction({ - ...props, - jenkinsProvider: this, - }); - } - - public toCodePipelineTestAction(props: BasicJenkinsTestActionProps): JenkinsTestAction { - return new JenkinsTestAction({ - ...props, - jenkinsProvider: this, - }); - } - /** * @internal */ @@ -218,7 +180,7 @@ export class JenkinsProvider extends BaseJenkinsProvider { return; } this.buildIncluded = true; - this.registerJenkinsCustomAction('JenkinsBuildProviderResource', cpapi.ActionCategory.Build); + this.registerJenkinsCustomAction('JenkinsBuildProviderResource', codepipeline.ActionCategory.Build); } /** @@ -229,10 +191,10 @@ export class JenkinsProvider extends BaseJenkinsProvider { return; } this.testIncluded = true; - this.registerJenkinsCustomAction('JenkinsTestProviderResource', cpapi.ActionCategory.Test); + this.registerJenkinsCustomAction('JenkinsTestProviderResource', codepipeline.ActionCategory.Test); } - private registerJenkinsCustomAction(id: string, category: cpapi.ActionCategory) { + private registerJenkinsCustomAction(id: string, category: codepipeline.ActionCategory) { new CustomActionRegistration(this, id, { category, artifactBounds: jenkinsArtifactsBounds, @@ -276,7 +238,7 @@ function appendToUrl(baseUrl: string, path: string): string { return baseUrl.endsWith('/') ? baseUrl + path : `${baseUrl}/${path}`; } -export const jenkinsArtifactsBounds: cpapi.ActionArtifactBounds = { +export const jenkinsArtifactsBounds: codepipeline.ActionArtifactBounds = { minInputs: 0, maxInputs: 5, minOutputs: 0, diff --git a/packages/@aws-cdk/aws-lambda/lib/pipeline-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts similarity index 76% rename from packages/@aws-cdk/aws-lambda/lib/pipeline-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts index 80939280f7345..660f261a73dad 100644 --- a/packages/@aws-cdk/aws-lambda/lib/pipeline-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts @@ -1,13 +1,11 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); -import { IFunction } from './function-base'; +import lambda = require('@aws-cdk/aws-lambda'); /** - * Common properties for creating a {@link PipelineInvokeAction} - - * either directly, through its constructor, - * or through {@link IFunction#toCodePipelineInvokeAction}. + * Construction properties of the {@link LambdaInvokeAction Lambda invoke CodePipeline Action}. */ -export interface CommonPipelineInvokeActionProps extends codepipeline.CommonActionProps { +export interface LambdaInvokeActionProps extends codepipeline.CommonActionProps { // because of @see links // tslint:disable:max-line-length @@ -55,22 +53,16 @@ export interface CommonPipelineInvokeActionProps extends codepipeline.CommonActi * (the pipeline references) the Lambda and the Lambda needs permissions on * the pipeline. * - * @see - * https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-create-function + * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-create-function * * @default true */ readonly addPutJobResultPolicy?: boolean; -} -/** - * Construction properties of the {@link PipelineInvokeAction Lambda invoke CodePipeline Action}. - */ -export interface PipelineInvokeActionProps extends CommonPipelineInvokeActionProps { /** * The lambda function to invoke. */ - readonly lambda: IFunction; + readonly lambda: lambda.IFunction; } /** @@ -78,10 +70,10 @@ export interface PipelineInvokeActionProps extends CommonPipelineInvokeActionPro * * @see https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html */ -export class PipelineInvokeAction extends codepipeline.Action { - private readonly props: PipelineInvokeActionProps; +export class LambdaInvokeAction extends codepipeline.Action { + private readonly props: LambdaInvokeActionProps; - constructor(props: PipelineInvokeActionProps) { + constructor(props: LambdaInvokeActionProps) { super({ ...props, category: codepipeline.ActionCategory.Invoke, @@ -107,13 +99,11 @@ export class PipelineInvokeAction extends codepipeline.Action { } public outputArtifacts(): codepipeline.Artifact[] { - // TODO: revert "as any" once we merge all actions into a single package - return (this as any)._outputArtifacts; + return this.actionOutputArtifacts; } public outputArtifact(artifactName: string): codepipeline.Artifact { - // TODO: revert "as any" once we merge all actions into a single package - const result = (this as any)._outputArtifacts.find((a: any) => (a.artifactName === artifactName)); + const result = this.actionOutputArtifacts.find(a => (a.artifactName === artifactName)); if (result === undefined) { throw new Error(`Could not find the output Artifact with name '${artifactName}'`); } else { diff --git a/packages/@aws-cdk/aws-codepipeline/lib/manual-approval-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts similarity index 86% rename from packages/@aws-cdk/aws-codepipeline/lib/manual-approval-action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts index 6214f7b408bc4..6acb9487f6610 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/manual-approval-action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/manual-approval-action.ts @@ -1,11 +1,11 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); /** * Construction properties of the {@link ManualApprovalAction}. */ -export interface ManualApprovalActionProps extends cpapi.CommonActionProps { +export interface ManualApprovalActionProps extends codepipeline.CommonActionProps { /** * Optional SNS topic to send notifications to when an approval is pending. */ @@ -27,7 +27,7 @@ export interface ManualApprovalActionProps extends cpapi.CommonActionProps { /** * Manual approval action. */ -export class ManualApprovalAction extends cpapi.Action { +export class ManualApprovalAction extends codepipeline.Action { /** * The SNS Topic passed when constructing the Action. * If no Topic was passed, but `notifyEmails` were provided, @@ -39,7 +39,7 @@ export class ManualApprovalAction extends cpapi.Action { constructor(props: ManualApprovalActionProps) { super({ ...props, - category: cpapi.ActionCategory.Approval, + category: codepipeline.ActionCategory.Approval, provider: 'Manual', artifactBounds: { minInputs: 0, maxInputs: 0, minOutputs: 0, maxOutputs: 0 }, configuration: new cdk.Token(() => this.actionConfiguration()), @@ -52,7 +52,7 @@ export class ManualApprovalAction extends cpapi.Action { return this._notificationTopic; } - protected bind(info: cpapi.ActionBind): void { + protected bind(info: codepipeline.ActionBind): void { if (this.props.notificationTopic) { this._notificationTopic = this.props.notificationTopic; } else if ((this.props.notifyEmails || []).length > 0) { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts new file mode 100644 index 0000000000000..af0ef9eef5202 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts @@ -0,0 +1,61 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); +import s3 = require('@aws-cdk/aws-s3'); + +/** + * Construction properties of the {@link S3DeployAction S3 deploy Action}. + */ +export interface S3DeployActionProps extends codepipeline.CommonActionProps { + /** + * Should the deploy action extract the artifact before deploying to Amazon S3. + * + * @default true + */ + readonly extract?: boolean; + + /** + * The key of the target object. This is required if extract is false. + */ + readonly objectKey?: string; + + /** + * The inputArtifact to deploy to Amazon S3. + */ + readonly inputArtifact: codepipeline.Artifact; + + /** + * The Amazon S3 bucket that is the deploy target. + */ + readonly bucket: s3.IBucket; +} + +/** + * Deploys the sourceArtifact to Amazon S3. + */ +export class S3DeployAction extends codepipeline.DeployAction { + private readonly bucket: s3.IBucket; + + constructor(props: S3DeployActionProps) { + super({ + ...props, + provider: 'S3', + artifactBounds: { + minInputs: 1, + maxInputs: 1, + minOutputs: 0, + maxOutputs: 0, + }, + configuration: { + BucketName: props.bucket.bucketName, + Extract: (props.extract === false) ? 'false' : 'true', + ObjectKey: props.objectKey, + }, + }); + + this.bucket = props.bucket; + } + + protected bind(info: codepipeline.ActionBind): void { + // pipeline needs permissions to write to the S3 bucket + this.bucket.grantWrite(info.role); + } +} diff --git a/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts new file mode 100644 index 0000000000000..5e6f255776888 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts @@ -0,0 +1,70 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); +import s3 = require('@aws-cdk/aws-s3'); + +/** + * Construction properties of the {@link S3SourceAction S3 source Action}. + */ +export interface S3SourceActionProps extends codepipeline.CommonActionProps { + /** + * The name of the source's output artifact. Output artifacts are used by CodePipeline as + * inputs into other actions. + * + * @default a name will be auto-generated + */ + readonly outputArtifactName?: string; + + /** + * The key within the S3 bucket that stores the source code. + * + * @example 'path/to/file.zip' + */ + readonly bucketKey: string; + + /** + * Whether AWS CodePipeline should poll for source changes. + * If this is `false`, the Pipeline will use CloudWatch Events to detect source changes instead. + * Note that if this is `false`, you need to make sure to include the source Bucket in a CloudTrail Trail, + * as otherwise the CloudWatch Events will not be emitted. + * + * @default true + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/log-s3-data-events.html + */ + readonly pollForSourceChanges?: boolean; + + /** + * The Amazon S3 bucket that stores the source code + */ + readonly bucket: s3.IBucket; +} + +/** + * Source that is provided by a specific Amazon S3 object. + */ +export class S3SourceAction extends codepipeline.SourceAction { + private readonly props: S3SourceActionProps; + + constructor(props: S3SourceActionProps) { + super({ + ...props, + provider: 'S3', + outputArtifactName: props.outputArtifactName || `Artifact_${props.actionName}_${props.bucket.node.uniqueId}`, + configuration: { + S3Bucket: props.bucket.bucketName, + S3ObjectKey: props.bucketKey, + PollForSourceChanges: props.pollForSourceChanges, + }, + }); + + this.props = props; + } + + protected bind(info: codepipeline.ActionBind): void { + if (this.props.pollForSourceChanges === false) { + this.props.bucket.onPutObject(info.pipeline.node.uniqueId + 'SourceEventRule', + info.pipeline, this.props.bucketKey); + } + + // pipeline needs permissions to read from the S3 bucket + this.props.bucket.grantRead(info.role); + } +} diff --git a/packages/@aws-cdk/aws-cloudformation/package-lock.json b/packages/@aws-cdk/aws-codepipeline-actions/package-lock.json similarity index 89% rename from packages/@aws-cdk/aws-cloudformation/package-lock.json rename to packages/@aws-cdk/aws-codepipeline-actions/package-lock.json index c14452da56f29..7c59ec4be6731 100644 --- a/packages/@aws-cdk/aws-cloudformation/package-lock.json +++ b/packages/@aws-cdk/aws-codepipeline-actions/package-lock.json @@ -1,6 +1,6 @@ { - "name": "@aws-cdk/aws-cloudformation", - "version": "0.26.0", + "name": "@aws-cdk/aws-codepipeline-actions", + "version": "0.27.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/@aws-cdk/aws-codepipeline-actions/package.json b/packages/@aws-cdk/aws-codepipeline-actions/package.json new file mode 100644 index 0000000000000..53890dd9c34a7 --- /dev/null +++ b/packages/@aws-cdk/aws-codepipeline-actions/package.json @@ -0,0 +1,103 @@ +{ + "name": "@aws-cdk/aws-codepipeline-actions", + "version": "0.27.0", + "description": "Concrete Actions for AWS Code Pipeline", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "jsii": { + "outdir": "dist", + "targets": { + "java": { + "package": "software.amazon.awscdk.services.codepipeline.actions", + "maven": { + "groupId": "software.amazon.awscdk", + "artifactId": "codepipeline-actions" + } + }, + "dotnet": { + "namespace": "Amazon.CDK.AWS.Codepipeline.Actions", + "packageId": "Amazon.CDK.AWS.Codepipeline.Actions", + "signAssembly": true, + "assemblyOriginatorKeyFile": "../../key.snk" + }, + "sphinx": {}, + "python": { + "distName": "aws-cdk.aws-codepipeline-actions", + "module": "aws_cdk.aws_codepipeline_actions" + } + } + }, + "repository": { + "type": "git", + "url": "https://github.com/awslabs/aws-cdk.git" + }, + "scripts": { + "build": "cdk-build", + "watch": "cdk-watch", + "lint": "cdk-lint", + "test": "cdk-test", + "integ": "cdk-integ", + "pkglint": "pkglint -f", + "package": "cdk-package", + "awslint": "cdk-awslint" + }, + "nyc": { + "statements": 70 + }, + "keywords": [ + "aws", + "aws-clib", + "aws-cloudlib", + "cdk", + "cloudlib", + "codepipeline", + "pipeline" + ], + "author": { + "name": "Amazon Web Services", + "url": "https://aws.amazon.com", + "organization": true + }, + "license": "Apache-2.0", + "devDependencies": { + "@aws-cdk/aws-cloudtrail": "^0.27.0", + "@aws-cdk/assert": "^0.27.0", + "cdk-build-tools": "^0.27.0", + "cdk-integ-tools": "^0.27.0", + "pkglint": "^0.27.0", + "@types/lodash": "^4.14.118", + "lodash": "^4.17.11" + }, + "dependencies": { + "@aws-cdk/aws-cloudformation": "^0.27.0", + "@aws-cdk/aws-codebuild": "^0.27.0", + "@aws-cdk/aws-codecommit": "^0.27.0", + "@aws-cdk/aws-codedeploy": "^0.27.0", + "@aws-cdk/aws-codepipeline": "^0.27.0", + "@aws-cdk/aws-ecr": "^0.27.0", + "@aws-cdk/aws-events": "^0.27.0", + "@aws-cdk/aws-iam": "^0.27.0", + "@aws-cdk/aws-lambda": "^0.27.0", + "@aws-cdk/aws-s3": "^0.27.0", + "@aws-cdk/aws-sns": "^0.27.0", + "@aws-cdk/cdk": "^0.27.0" + }, + "homepage": "https://github.com/awslabs/aws-cdk", + "peerDependencies": { + "@aws-cdk/aws-cloudformation": "^0.27.0", + "@aws-cdk/aws-codebuild": "^0.27.0", + "@aws-cdk/aws-codecommit": "^0.27.0", + "@aws-cdk/aws-codedeploy": "^0.27.0", + "@aws-cdk/aws-codepipeline": "^0.27.0", + "@aws-cdk/aws-ecr": "^0.27.0", + "@aws-cdk/aws-events": "^0.27.0", + "@aws-cdk/aws-iam": "^0.27.0", + "@aws-cdk/aws-lambda": "^0.27.0", + "@aws-cdk/aws-s3": "^0.27.0", + "@aws-cdk/aws-sns": "^0.27.0", + "@aws-cdk/cdk": "^0.27.0" + }, + "engines": { + "node": ">= 8.10.0" + } +} diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.cloudformation-pipeline-actions.ts similarity index 86% rename from packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.cloudformation-pipeline-actions.ts index cb65b3292595b..abb3021358a60 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.cloudformation-pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.cloudformation-pipeline-actions.ts @@ -1,13 +1,12 @@ import { expect, haveResource, haveResourceLike } from '@aws-cdk/assert'; -import { PipelineCreateReplaceChangeSetAction, PipelineCreateUpdateStackAction, PipelineExecuteChangeSetAction } from '@aws-cdk/aws-cloudformation'; -import { CodePipelineBuildArtifacts, CodePipelineSource, PipelineBuildAction, Project } from '@aws-cdk/aws-codebuild'; -import { PipelineSourceAction, Repository } from '@aws-cdk/aws-codecommit'; -import cpapi = require('@aws-cdk/aws-codepipeline-api'); -import { PolicyStatement, ServicePrincipal } from '@aws-cdk/aws-iam'; +import { CodePipelineBuildArtifacts, CodePipelineSource, Project } from '@aws-cdk/aws-codebuild'; +import { Repository } from '@aws-cdk/aws-codecommit'; +import codepipeline = require('@aws-cdk/aws-codepipeline'); import { Role } from '@aws-cdk/aws-iam'; +import { PolicyStatement, ServicePrincipal } from '@aws-cdk/aws-iam'; import cdk = require('@aws-cdk/cdk'); import { Test } from 'nodeunit'; -import { Pipeline } from '../lib'; +import cpactions = require('../../lib'); // tslint:disable:object-literal-key-quotes @@ -15,7 +14,7 @@ export = { 'CreateChangeSetAction can be used to make a change set from a CodePipeline'(test: Test) { const stack = new cdk.Stack(); - const pipeline = new Pipeline(stack, 'MagicPipeline'); + const pipeline = new codepipeline.Pipeline(stack, 'MagicPipeline'); const changeSetExecRole = new Role(stack, 'ChangeSetRole', { assumedBy: new ServicePrincipal('cloudformation.amazonaws.com'), @@ -24,7 +23,7 @@ export = { /** Source! */ const repo = new Repository(stack, 'MyVeryImportantRepo', { repositoryName: 'my-very-important-repo' }); - const source = new PipelineSourceAction({ + const source = new cpactions.CodeCommitSourceAction({ actionName: 'source', outputArtifactName: 'SourceArtifact', repository: repo, @@ -43,7 +42,7 @@ export = { artifacts: buildArtifacts, }); - const buildAction = new PipelineBuildAction({ + const buildAction = new cpactions.CodeBuildBuildAction({ actionName: 'build', project, inputArtifact: source.outputArtifact, @@ -64,16 +63,16 @@ export = { pipeline.addStage({ name: 'prod', actions: [ - new PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'BuildChangeSetProd', stackName, changeSetName, deploymentRole: changeSetExecRole, - templatePath: new cpapi.ArtifactPath(buildAction.outputArtifact, 'template.yaml'), - templateConfiguration: new cpapi.ArtifactPath(buildAction.outputArtifact, 'templateConfig.json'), + templatePath: new codepipeline.ArtifactPath(buildAction.outputArtifact, 'template.yaml'), + templateConfiguration: new codepipeline.ArtifactPath(buildAction.outputArtifact, 'templateConfig.json'), adminPermissions: false, }), - new PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChangeSetProd', stackName, changeSetName, @@ -209,7 +208,7 @@ export = { const stack = new TestFixture(); // WHEN - stack.deployStage.addAction(new PipelineCreateUpdateStackAction({ + stack.deployStage.addAction(new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CreateUpdate', stackName: 'MyStack', templatePath: stack.source.outputArtifact.atPath('template.yaml'), @@ -264,7 +263,7 @@ export = { const stack = new TestFixture(); // WHEN - stack.deployStage.addAction(new PipelineCreateUpdateStackAction({ + stack.deployStage.addAction(new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CreateUpdate', stackName: 'MyStack', templatePath: stack.source.outputArtifact.atPath('template.yaml'), @@ -296,7 +295,7 @@ export = { const stack = new TestFixture(); // WHEN - stack.deployStage.addAction(new PipelineCreateUpdateStackAction({ + stack.deployStage.addAction(new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CreateUpdate', stackName: 'MyStack', templatePath: stack.source.outputArtifact.atPath('template.yaml'), @@ -330,7 +329,7 @@ export = { const stack = new TestFixture(); // WHEN - stack.deployStage.addAction(new PipelineCreateUpdateStackAction({ + stack.deployStage.addAction(new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CreateUpdate', stackName: 'MyStack', templatePath: stack.source.outputArtifact.atPath('template.yaml'), @@ -375,14 +374,14 @@ export = { assumedBy: new ServicePrincipal('magicservice') }); - stack.deployStage.addAction(new PipelineExecuteChangeSetAction({ + stack.deployStage.addAction(new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'ImportedRoleAction', role: importedRole, changeSetName: 'magicSet', stackName: 'magicStack', })); - stack.deployStage.addAction(new PipelineExecuteChangeSetAction({ + stack.deployStage.addAction(new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'FreshRoleAction', role: freshRole, changeSetName: 'magicSet', @@ -423,20 +422,20 @@ export = { * A test stack with a half-prepared pipeline ready to add CloudFormation actions to */ class TestFixture extends cdk.Stack { - public readonly pipeline: Pipeline; - public readonly sourceStage: cpapi.IStage; - public readonly deployStage: cpapi.IStage; + public readonly pipeline: codepipeline.Pipeline; + public readonly sourceStage: codepipeline.IStage; + public readonly deployStage: codepipeline.IStage; public readonly repo: Repository; - public readonly source: PipelineSourceAction; + public readonly source: cpactions.CodeCommitSourceAction; constructor() { super(); - this.pipeline = new Pipeline(this, 'Pipeline'); + this.pipeline = new codepipeline.Pipeline(this, 'Pipeline'); this.sourceStage = this.pipeline.addStage({ name: 'Source' }); this.deployStage = this.pipeline.addStage({ name: 'Deploy' }); this.repo = new Repository(this, 'MyVeryImportantRepo', { repositoryName: 'my-very-important-repo' }); - this.source = new PipelineSourceAction({ + this.source = new cpactions.CodeCommitSourceAction({ actionName: 'Source', outputArtifactName: 'SourceArtifact', repository: this.repo, diff --git a/packages/@aws-cdk/aws-cloudformation/test/test.pipeline-actions.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts similarity index 90% rename from packages/@aws-cdk/aws-cloudformation/test/test.pipeline-actions.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts index 35f07ac053b2a..c74e043620791 100644 --- a/packages/@aws-cdk/aws-cloudformation/test/test.pipeline-actions.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/cloudformation/test.pipeline-actions.ts @@ -1,18 +1,18 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); import _ = require('lodash'); import nodeunit = require('nodeunit'); -import cloudformation = require('../lib'); +import cpactions = require('../../lib'); export = nodeunit.testCase({ 'CreateReplaceChangeSet': { 'works'(test: nodeunit.Test) { const stack = new cdk.Stack(); const pipelineRole = new RoleDouble(stack, 'PipelineRole'); - const artifact = new cpapi.Artifact('TestArtifact'); - const action = new cloudformation.PipelineCreateReplaceChangeSetAction({ + const artifact = new codepipeline.Artifact('TestArtifact'); + const action = new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'Action', changeSetName: 'MyChangeSet', stackName: 'MyStack', @@ -34,7 +34,7 @@ export = nodeunit.testCase({ _assertPermissionGranted(test, pipelineRole.statements, 'cloudformation:DeleteChangeSet', stackArn, changeSetCondition); // TODO: revert "as any" once we move all actions into a single package. - test.deepEqual((action as any)._inputArtifacts, [artifact], + test.deepEqual((action as any).actionInputArtifacts, [artifact], 'The inputArtifact was correctly registered'); _assertActionMatches(test, stage.actions, 'AWS', 'CloudFormation', 'Deploy', { @@ -49,18 +49,18 @@ export = nodeunit.testCase({ 'uses a single permission statement if the same ChangeSet name is used'(test: nodeunit.Test) { const stack = new cdk.Stack(); const pipelineRole = new RoleDouble(stack, 'PipelineRole'); - const artifact = new cpapi.Artifact('TestArtifact'); + const artifact = new codepipeline.Artifact('TestArtifact'); new StageDouble({ pipeline: new PipelineDouble(stack, 'Pipeline', { role: pipelineRole }), actions: [ - new cloudformation.PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'ActionA', changeSetName: 'MyChangeSet', stackName: 'StackA', adminPermissions: false, templatePath: artifact.atPath('path/to/file') }), - new cloudformation.PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'ActionB', changeSetName: 'MyChangeSet', stackName: 'StackB', @@ -111,7 +111,7 @@ export = nodeunit.testCase({ const stage = new StageDouble({ pipeline: new PipelineDouble(stack, 'Pipeline', { role: pipelineRole }), actions: [ - new cloudformation.PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'Action', changeSetName: 'MyChangeSet', stackName: 'MyStack', @@ -138,12 +138,12 @@ export = nodeunit.testCase({ new StageDouble({ pipeline: new PipelineDouble(stack, 'Pipeline', { role: pipelineRole }), actions: [ - new cloudformation.PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'ActionA', changeSetName: 'MyChangeSet', stackName: 'StackA', }), - new cloudformation.PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'ActionB', changeSetName: 'MyChangeSet', stackName: 'StackB', @@ -175,9 +175,9 @@ export = nodeunit.testCase({ 'the CreateUpdateStack Action sets the DescribeStack*, Create/Update/DeleteStack & PassRole permissions'(test: nodeunit.Test) { const stack = new cdk.Stack(); const pipelineRole = new RoleDouble(stack, 'PipelineRole'); - const action = new cloudformation.PipelineCreateUpdateStackAction({ + const action = new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'Action', - templatePath: new cpapi.Artifact('TestArtifact').atPath('some/file'), + templatePath: new codepipeline.Artifact('TestArtifact').atPath('some/file'), stackName: 'MyStack', adminPermissions: false, replaceOnFailure: true, @@ -201,7 +201,7 @@ export = nodeunit.testCase({ 'the DeleteStack Action sets the DescribeStack*, DeleteStack & PassRole permissions'(test: nodeunit.Test) { const stack = new cdk.Stack(); const pipelineRole = new RoleDouble(stack, 'PipelineRole'); - const action = new cloudformation.PipelineDeleteStackAction({ + const action = new cpactions.CloudFormationDeleteStackAction({ actionName: 'Action', adminPermissions: false, stackName: 'MyStack', @@ -229,7 +229,7 @@ interface PolicyStatementJson { } function _assertActionMatches(test: nodeunit.Test, - actions: cpapi.Action[], + actions: codepipeline.Action[], owner: string, provider: string, category: string, @@ -244,7 +244,7 @@ function _assertActionMatches(test: nodeunit.Test, `Expected to find an action with owner ${owner}, provider ${provider}, category ${category}${configurationStr}, but found ${actionsStr}`); } -function _hasAction(actions: cpapi.Action[], owner: string, provider: string, category: string, configuration?: { [key: string]: any}) { +function _hasAction(actions: codepipeline.Action[], owner: string, provider: string, category: string, configuration?: { [key: string]: any}) { for (const action of actions) { if (action.owner !== owner) { continue; } if (action.provider !== provider) { continue; } @@ -301,7 +301,7 @@ function _stackArn(stackName: string, scope: cdk.IConstruct): string { }); } -class PipelineDouble extends cdk.Construct implements cpapi.IPipeline { +class PipelineDouble extends cdk.Construct implements codepipeline.IPipeline { public readonly pipelineName: string; public readonly pipelineArn: string; public readonly role: iam.Role; @@ -326,16 +326,16 @@ class PipelineDouble extends cdk.Construct implements cpapi.IPipeline { } } -class StageDouble implements cpapi.IStage { +class StageDouble implements codepipeline.IStage { public readonly stageName: string; - public readonly pipeline: cpapi.IPipeline; - public readonly actions: cpapi.Action[]; + public readonly pipeline: codepipeline.IPipeline; + public readonly actions: codepipeline.Action[]; public get node(): cdk.ConstructNode { throw new Error('StageDouble is not a real construct'); } - constructor({ name, pipeline, actions }: { name?: string, pipeline: PipelineDouble, actions: cpapi.Action[] }) { + constructor({ name, pipeline, actions }: { name?: string, pipeline: PipelineDouble, actions: codepipeline.Action[] }) { this.stageName = name || 'TestStage'; this.pipeline = pipeline; @@ -352,7 +352,7 @@ class StageDouble implements cpapi.IStage { this.actions = actions; } - public addAction(_action: cpapi.Action): void { + public addAction(_action: codepipeline.Action): void { throw new Error('addAction() is not supported on StageDouble'); } diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.cfn-template-from-repo.lit.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.cfn-template-from-repo.lit.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.cfn-template-from-repo.lit.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.ts similarity index 79% rename from packages/@aws-cdk/aws-codepipeline/test/integ.cfn-template-from-repo.lit.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.ts index 0b408ecea9fcd..14f6a8efe5061 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.cfn-template-from-repo.lit.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.ts @@ -1,7 +1,7 @@ -import cfn = require('@aws-cdk/aws-cloudformation'); import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-cloudformation'); @@ -11,7 +11,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-cloudformation'); const repo = new codecommit.Repository(stack, 'TemplateRepo', { repositoryName: 'template-repo' }); -const source = new codecommit.PipelineSourceAction({ +const source = new cpactions.CodeCommitSourceAction({ actionName: 'Source', repository: repo, outputArtifactName: 'SourceArtifact', @@ -29,7 +29,7 @@ const changeSetName = 'StagedChangeSet'; const prodStage = { name: 'Deploy', actions: [ - new cfn.PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'PrepareChanges', stackName, changeSetName, @@ -37,11 +37,11 @@ const prodStage = { templatePath: source.outputArtifact.atPath('template.yaml'), runOrder: 1, }), - new codepipeline.ManualApprovalAction({ + new cpactions.ManualApprovalAction({ actionName: 'ApproveChanges', runOrder: 2, }), - new cfn.PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChanges', stackName, changeSetName, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.lambda-pipeline.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.lambda-pipeline.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.lambda-pipeline.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.ts similarity index 82% rename from packages/@aws-cdk/aws-codepipeline/test/integ.lambda-pipeline.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.ts index 8c88017d0238c..35c5c99e1fc42 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.lambda-pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.ts @@ -1,8 +1,9 @@ import cloudtrail = require('@aws-cdk/aws-cloudtrail'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import lambda = require('@aws-cdk/aws-lambda'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -18,7 +19,7 @@ const bucket = new s3.Bucket(stack, 'PipelineBucket', { const key = 'key'; const trail = new cloudtrail.CloudTrail(stack, 'CloudTrail'); trail.addS3EventSelector([bucket.arnForObjects(key)], { readWriteType: cloudtrail.ReadWriteType.WriteOnly, includeManagementEvents: false }); -sourceStage.addAction(new s3.PipelineSourceAction({ +sourceStage.addAction(new cpactions.S3SourceAction({ actionName: 'Source', outputArtifactName: 'SourceArtifact', bucket, @@ -36,6 +37,9 @@ const lambdaFun = new lambda.Function(stack, 'LambdaFun', { runtime: lambda.Runtime.NodeJS610, }); const lambdaStage = pipeline.addStage({ name: 'Lambda' }); -lambdaStage.addAction(lambdaFun.toCodePipelineInvokeAction({ actionName: 'Lambda' })); +lambdaStage.addAction(new cpactions.LambdaInvokeAction({ + actionName: 'Lambda' , + lambda: lambdaFun, +})); app.run(); diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-alexa-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-alexa-deploy.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-alexa-deploy.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-alexa-deploy.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-alexa-deploy.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-alexa-deploy.ts similarity index 83% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-alexa-deploy.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-alexa-deploy.ts index 654d4d2325f97..ab596f151f9c6 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-alexa-deploy.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-alexa-deploy.ts @@ -1,7 +1,7 @@ -import alexa = require('@aws-cdk/alexa-ask'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -11,7 +11,7 @@ const bucket = new s3.Bucket(stack, 'PipelineBucket', { versioned: true, removalPolicy: cdk.RemovalPolicy.Destroy, }); -const sourceAction = new s3.PipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'Source', outputArtifactName: 'SourceArtifact', bucket, @@ -25,7 +25,7 @@ const sourceStage = { const deployStage = { name: 'Deploy', actions: [ - new alexa.AlexaSkillDeployAction({ + new cpactions.AlexaSkillDeployAction({ actionName: 'DeploySkill', runOrder: 1, inputArtifact: sourceAction.outputArtifact, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-cross-region.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-cross-region.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-cross-region.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-cross-region.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-cross-region.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-cross-region.ts similarity index 80% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-cross-region.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-cross-region.ts index f1820a8a596e5..96a0dd69dcfd3 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-cross-region.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-cross-region.ts @@ -1,7 +1,7 @@ -import cloudformation = require('@aws-cdk/aws-cloudformation'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -17,9 +17,10 @@ const bucket = new s3.Bucket(stack, 'MyBucket', { removalPolicy: cdk.RemovalPolicy.Destroy, }); -const sourceAction = bucket.toCodePipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'S3', bucketKey: 'some/path', + bucket, }); new codepipeline.Pipeline(stack, 'MyPipeline', { @@ -32,7 +33,7 @@ new codepipeline.Pipeline(stack, 'MyPipeline', { { name: 'CFN', actions: [ - new cloudformation.PipelineCreateUpdateStackAction({ + new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CFN_Deploy', stackName: 'aws-cdk-codepipeline-cross-region-deploy-stack', templatePath: sourceAction.outputArtifact.atPath('template.yml'), diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-wtih-action-role.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-wtih-action-role.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-wtih-action-role.ts similarity index 85% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-wtih-action-role.ts index 8f33499041846..9a7a67f9d3a7d 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn-wtih-action-role.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn-wtih-action-role.ts @@ -1,8 +1,8 @@ -import cloudformation = require('@aws-cdk/aws-cloudformation'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import iam = require('@aws-cdk/aws-iam'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -13,9 +13,10 @@ const bucket = new s3.Bucket(stack, 'MyBucket', { removalPolicy: cdk.RemovalPolicy.Destroy, }); -const sourceAction = bucket.toCodePipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'S3', bucketKey: 'some/path', + bucket, }); const sourceStage = { name: 'Source', @@ -32,7 +33,7 @@ role.addToPolicy(new iam.PolicyStatement() const cfnStage = { name: 'CFN', actions: [ - new cloudformation.PipelineCreateUpdateStackAction({ + new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'CFN_Deploy', stackName: 'aws-cdk-codepipeline-cross-region-deploy-stack', templatePath: sourceAction.outputArtifact.atPath('template.yml'), diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn.ts similarity index 82% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn.ts index 44589acaff0bf..c3e05cbdb005a 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-cfn.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-cfn.ts @@ -1,10 +1,9 @@ -import cfn = require('@aws-cdk/aws-cloudformation'); -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import { Role } from '@aws-cdk/aws-iam'; import { ServicePrincipal } from '@aws-cdk/aws-iam'; import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -17,7 +16,7 @@ const bucket = new s3.Bucket(stack, 'PipelineBucket', { removalPolicy: cdk.RemovalPolicy.Destroy, }); -const source = new s3.PipelineSourceAction({ +const source = new cpactions.S3SourceAction({ actionName: 'Source', outputArtifactName: 'SourceArtifact', bucket, @@ -35,13 +34,13 @@ const role = new Role(stack, 'CfnChangeSetRole', { }); // fake Artifact, just for testing -const additionalArtifact = new cpapi.Artifact('AdditionalArtifact'); +const additionalArtifact = new codepipeline.Artifact('AdditionalArtifact'); pipeline.addStage(sourceStage); pipeline.addStage({ name: 'CFN', actions: [ - new cfn.PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'DeployCFN', changeSetName, stackName, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-build-multiple-inputs-outputs.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-build-multiple-inputs-outputs.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-build-multiple-inputs-outputs.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-build-multiple-inputs-outputs.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-build-multiple-inputs-outputs.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-build-multiple-inputs-outputs.ts similarity index 84% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-build-multiple-inputs-outputs.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-build-multiple-inputs-outputs.ts index 611d573635e88..10fad9f249cef 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-build-multiple-inputs-outputs.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-build-multiple-inputs-outputs.ts @@ -1,8 +1,9 @@ import codebuild = require('@aws-cdk/aws-codebuild'); import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -20,10 +21,14 @@ const pipeline = new codepipeline.Pipeline(stack, 'Pipeline', { artifactBucket: bucket, }); -const sourceAction1 = repository.toCodePipelineSourceAction({ actionName: 'Source1' }); -const sourceAction2 = bucket.toCodePipelineSourceAction({ +const sourceAction1 = new cpactions.CodeCommitSourceAction({ + actionName: 'Source1', + repository, +}); +const sourceAction2 = new cpactions.S3SourceAction({ actionName: 'Source2', bucketKey: 'some/path', + bucket, }); pipeline.addStage({ name: 'Source', @@ -34,8 +39,9 @@ pipeline.addStage({ }); const project = new codebuild.PipelineProject(stack, 'MyBuildProject'); -const buildAction = project.toCodePipelineBuildAction({ +const buildAction = new cpactions.CodeBuildBuildAction({ actionName: 'Build1', + project, inputArtifact: sourceAction1.outputArtifact, additionalInputArtifacts: [ sourceAction2.outputArtifact, @@ -44,8 +50,9 @@ const buildAction = project.toCodePipelineBuildAction({ 'CustomOutput1', ], }); -const testAction = project.toCodePipelineTestAction({ +const testAction = new cpactions.CodeBuildTestAction({ actionName: 'Build2', + project, inputArtifact: sourceAction2.outputArtifact, additionalInputArtifacts: [ sourceAction1.outputArtifact, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit-build.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit-build.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit-build.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit-build.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit-build.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit-build.ts similarity index 78% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit-build.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit-build.ts index 617c624d735e6..40a60e95714ee 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit-build.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit-build.ts @@ -1,7 +1,8 @@ import codebuild = require('@aws-cdk/aws-codebuild'); import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -10,7 +11,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-codecommit-codebuild'); const repository = new codecommit.Repository(stack, 'MyRepo', { repositoryName: 'my-repo', }); -const sourceAction = new codecommit.PipelineSourceAction({ +const sourceAction = new cpactions.CodeCommitSourceAction({ actionName: 'source', outputArtifactName: 'SourceArtifact', repository, @@ -20,12 +21,12 @@ const sourceAction = new codecommit.PipelineSourceAction({ const project = new codebuild.Project(stack, 'MyBuildProject', { source: new codebuild.CodePipelineSource(), }); -const buildAction = new codebuild.PipelineBuildAction({ +const buildAction = new cpactions.CodeBuildBuildAction({ actionName: 'build', project, inputArtifact: sourceAction.outputArtifact, }); -const testAction = new codebuild.PipelineTestAction({ +const testAction = new cpactions.CodeBuildTestAction({ actionName: 'test', project, inputArtifact: sourceAction.outputArtifact, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit.ts similarity index 70% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit.ts index 0ee53d78b74b2..77dfca10e20c9 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-commit.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-commit.ts @@ -1,6 +1,7 @@ import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -13,8 +14,9 @@ new codepipeline.Pipeline(stack, 'Pipeline', { { name: 'source', actions: [ - repo.toCodePipelineSourceAction({ + new cpactions.CodeCommitSourceAction({ actionName: 'source', + repository: repo, outputArtifactName: 'SourceArtifact', }), ], @@ -22,7 +24,7 @@ new codepipeline.Pipeline(stack, 'Pipeline', { { name: 'build', actions: [ - new codepipeline.ManualApprovalAction({ actionName: 'manual' }), + new cpactions.ManualApprovalAction({ actionName: 'manual' }), ], }, ], diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-deploy.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-deploy.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-deploy.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-deploy.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-deploy.ts similarity index 83% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-deploy.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-deploy.ts index 990cc5f4168fa..bd1c190939061 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-code-deploy.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-code-deploy.ts @@ -1,7 +1,8 @@ import codedeploy = require('@aws-cdk/aws-codedeploy'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -31,16 +32,18 @@ const pipeline = new codepipeline.Pipeline(stack, 'Pipeline', { }); const sourceStage = pipeline.addStage({ name: 'Source' }); -const sourceAction = bucket.toCodePipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'S3Source', bucketKey: 'application.zip', outputArtifactName: 'SourceOutput', + bucket, }); sourceStage.addAction(sourceAction); const deployStage = pipeline.addStage({ name: 'Deploy' }); -deployStage.addAction(deploymentGroup.toCodePipelineDeployAction({ +deployStage.addAction(new cpactions.CodeDeployServerDeployAction({ actionName: 'CodeDeploy', + deploymentGroup, inputArtifact: sourceAction.outputArtifact, })); diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-ecr-source.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-ecr-source.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-ecr-source.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.ts similarity index 67% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-ecr-source.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.ts index 4a2278608482a..baac957018dcf 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-ecr-source.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.ts @@ -1,7 +1,8 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); import ecr = require('@aws-cdk/aws-ecr'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -16,9 +17,12 @@ const pipeline = new codepipeline.Pipeline(stack, 'MyPipeline', { const repository = new ecr.Repository(stack, 'MyEcrRepo'); const sourceStage = pipeline.addStage({ name: 'Source' }); -sourceStage.addAction(repository.toCodePipelineSourceAction({ actionName: 'ECR_Source' })); +sourceStage.addAction(new cpactions.EcrSourceAction({ + actionName: 'ECR_Source', + repository, +})); const approveStage = pipeline.addStage({ name: 'Approve' }); -approveStage.addAction(new codepipeline.ManualApprovalAction({ actionName: 'ManualApproval' })); +approveStage.addAction(new cpactions.ManualApprovalAction({ actionName: 'ManualApproval' })); app.run(); diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-events.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-events.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-events.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.ts similarity index 87% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-events.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.ts index 50a3207e69265..6a1d34e49f24f 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-events.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-events.ts @@ -2,9 +2,10 @@ import codebuild = require('@aws-cdk/aws-codebuild'); import codecommit = require('@aws-cdk/aws-codecommit'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -17,7 +18,7 @@ const repository = new codecommit.Repository(stack, 'CodeCommitRepo', { }); const project = new codebuild.PipelineProject(stack, 'BuildProject'); -const sourceAction = new codecommit.PipelineSourceAction({ +const sourceAction = new cpactions.CodeCommitSourceAction({ actionName: 'CodeCommitSource', outputArtifactName: 'Source', repository, @@ -31,7 +32,7 @@ const sourceStage = pipeline.addStage({ pipeline.addStage({ name: 'Build', actions: [ - new codebuild.PipelineBuildAction({ + new cpactions.CodeBuildBuildAction({ actionName: 'CodeBuildAction', inputArtifact: sourceAction.outputArtifact, project, diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-jenkins.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-jenkins.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-jenkins.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-jenkins.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-jenkins.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-jenkins.ts similarity index 70% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-jenkins.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-jenkins.ts index 9dd6fbadbb058..fcbe83aa2f331 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-jenkins.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-jenkins.ts @@ -1,6 +1,7 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -14,16 +15,17 @@ const pipeline = new codepipeline.Pipeline(stack, 'Pipeline', { artifactBucket: bucket, }); -const sourceAction = bucket.toCodePipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'S3', bucketKey: 'some/path', + bucket, }); pipeline.addStage({ name: 'Source', actions: [sourceAction], }); -const jenkinsProvider = new codepipeline.JenkinsProvider(stack, 'JenkinsProvider', { +const jenkinsProvider = new cpactions.JenkinsProvider(stack, 'JenkinsProvider', { providerName: 'JenkinsProvider', serverUrl: 'http://myjenkins.com:8080', version: '2', @@ -32,18 +34,21 @@ const jenkinsProvider = new codepipeline.JenkinsProvider(stack, 'JenkinsProvider pipeline.addStage({ name: 'Build', actions: [ - jenkinsProvider.toCodePipelineBuildAction({ + new cpactions.JenkinsBuildAction({ actionName: 'JenkinsBuild', + jenkinsProvider, projectName: 'JenkinsProject1', inputArtifact: sourceAction.outputArtifact, }), - jenkinsProvider.toCodePipelineTestAction({ + new cpactions.JenkinsTestAction({ actionName: 'JenkinsTest', + jenkinsProvider, projectName: 'JenkinsProject2', inputArtifact: sourceAction.outputArtifact, }), - jenkinsProvider.toCodePipelineTestAction({ + new cpactions.JenkinsTestAction({ actionName: 'JenkinsTest2', + jenkinsProvider, projectName: 'JenkinsProject3', inputArtifact: sourceAction.outputArtifact, }), diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-manual-approval.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-manual-approval.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-manual-approval.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-manual-approval.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-manual-approval.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-manual-approval.ts similarity index 78% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-manual-approval.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-manual-approval.ts index e7e6628bf1578..46d4052807a5f 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-manual-approval.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-manual-approval.ts @@ -1,6 +1,7 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -14,7 +15,7 @@ new codepipeline.Pipeline(stack, 'Pipeline', { { name: 'Source', actions: [ - new s3.PipelineSourceAction({ + new cpactions.S3SourceAction({ actionName: 'S3', bucket, bucketKey: 'file.zip', @@ -24,7 +25,7 @@ new codepipeline.Pipeline(stack, 'Pipeline', { { name: 'Approve', actions: [ - new codepipeline.ManualApprovalAction({ + new cpactions.ManualApprovalAction({ actionName: 'ManualApproval', notifyEmails: ['adamruka85@gmail.com'], }), diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-s3-deploy.expected.json b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json similarity index 100% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-s3-deploy.expected.json rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.expected.json diff --git a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-s3-deploy.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts similarity index 76% rename from packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-s3-deploy.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts index a13b1b47d0630..fb272be5422db 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/integ.pipeline-s3-deploy.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-s3-deploy.ts @@ -1,6 +1,7 @@ +import codepipeline = require('@aws-cdk/aws-codepipeline'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); -import codepipeline = require('../lib'); +import cpactions = require('../lib'); const app = new cdk.App(); @@ -10,7 +11,7 @@ const bucket = new s3.Bucket(stack, 'PipelineBucket', { versioned: true, removalPolicy: cdk.RemovalPolicy.Destroy, }); -const sourceAction = new s3.PipelineSourceAction({ +const sourceAction = new cpactions.S3SourceAction({ actionName: 'Source', outputArtifactName: 'SourceArtifact', bucket, @@ -28,10 +29,11 @@ new codepipeline.Pipeline(stack, 'Pipeline', { { name: 'Deploy', actions: [ - deployBucket.toCodePipelineDeployAction({ + new cpactions.S3DeployAction({ actionName: 'DeployAction', inputArtifact: sourceAction.outputArtifact, - }), + bucket: deployBucket, + }) ], }, ], diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.action.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/test.action.ts similarity index 73% rename from packages/@aws-cdk/aws-codepipeline/test/test.action.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/test.action.ts index 53f4577713ecd..46ce54e094f52 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.action.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/test.action.ts @@ -1,10 +1,10 @@ import { expect, haveResourceLike } from '@aws-cdk/assert'; import codebuild = require('@aws-cdk/aws-codebuild'); import codecommit = require('@aws-cdk/aws-codecommit'); -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import cdk = require('@aws-cdk/cdk'); import { Test } from 'nodeunit'; -import codepipeline = require('../lib'); +import cpactions = require('../lib'); // tslint:disable:object-literal-key-quotes @@ -35,27 +35,27 @@ export = { 'action type validation': { 'must be source and is source'(test: Test) { - const result = cpapi.validateSourceAction(true, cpapi.ActionCategory.Source, 'test action', 'test stage'); + const result = codepipeline.validateSourceAction(true, codepipeline.ActionCategory.Source, 'test action', 'test stage'); test.deepEqual(result.length, 0); test.done(); }, 'must be source and is not source'(test: Test) { - const result = cpapi.validateSourceAction(true, cpapi.ActionCategory.Deploy, 'test action', 'test stage'); + const result = codepipeline.validateSourceAction(true, codepipeline.ActionCategory.Deploy, 'test action', 'test stage'); test.deepEqual(result.length, 1); test.ok(result[0].match(/may only contain Source actions/), 'the validation should have failed'); test.done(); }, 'cannot be source and is source'(test: Test) { - const result = cpapi.validateSourceAction(false, cpapi.ActionCategory.Source, 'test action', 'test stage'); + const result = codepipeline.validateSourceAction(false, codepipeline.ActionCategory.Source, 'test action', 'test stage'); test.deepEqual(result.length, 1); test.ok(result[0].match(/may only occur in first stage/), 'the validation should have failed'); test.done(); }, 'cannot be source and is not source'(test: Test) { - const result = cpapi.validateSourceAction(false, cpapi.ActionCategory.Deploy, 'test action', 'test stage'); + const result = codepipeline.validateSourceAction(false, codepipeline.ActionCategory.Deploy, 'test action', 'test stage'); test.deepEqual(result.length, 0); test.done(); }, @@ -68,7 +68,10 @@ export = { const repo = new codecommit.Repository(stack, 'Repo', { repositoryName: 'Repo', }); - const sourceAction = repo.toCodePipelineSourceAction({ actionName: 'CodeCommit' }); + const sourceAction = new cpactions.CodeCommitSourceAction({ + actionName: 'CodeCommit', + repository: repo, + }); pipeline.addStage({ name: 'Source', actions: [sourceAction], @@ -78,8 +81,9 @@ export = { pipeline.addStage({ name: 'Build', actions: [ - project.toCodePipelineBuildAction({ + new cpactions.CodeBuildBuildAction({ actionName: 'CodeBuild', + project, inputArtifact: sourceAction.outputArtifact, }), ], @@ -152,31 +156,33 @@ export = { 'input Artifacts': { 'can be added multiple times to an Action safely'(test: Test) { - const artifact = new cpapi.Artifact('SomeArtifact'); + const artifact = new codepipeline.Artifact('SomeArtifact'); const stack = new cdk.Stack(); const project = new codebuild.PipelineProject(stack, 'Project'); - const action = project.toCodePipelineBuildAction({ + const action = new cpactions.CodeBuildBuildAction({ actionName: 'CodeBuild', + project, inputArtifact: artifact, additionalInputArtifacts: [artifact], }); - // TODO: remove "as any" - test.equal((action as any)._inputArtifacts.length, 1); + test.equal((action as any).actionInputArtifacts.length, 1); + test.done(); }, 'cannot have duplicate names'(test: Test) { - const artifact1 = new cpapi.Artifact('SomeArtifact'); - const artifact2 = new cpapi.Artifact('SomeArtifact'); + const artifact1 = new codepipeline.Artifact('SomeArtifact'); + const artifact2 = new codepipeline.Artifact('SomeArtifact'); const stack = new cdk.Stack(); const project = new codebuild.PipelineProject(stack, 'Project'); test.throws(() => - project.toCodePipelineBuildAction({ + new cpactions.CodeBuildBuildAction({ actionName: 'CodeBuild', + project, inputArtifact: artifact1, additionalInputArtifacts: [artifact2], }) @@ -188,12 +194,13 @@ export = { 'output Artifact names': { 'accept the same name multiple times safely'(test: Test) { - const artifact = new cpapi.Artifact('SomeArtifact'); + const artifact = new codepipeline.Artifact('SomeArtifact'); const stack = new cdk.Stack(); const project = new codebuild.PipelineProject(stack, 'Project'); - const action = project.toCodePipelineBuildAction({ + const action = new cpactions.CodeBuildBuildAction({ actionName: 'CodeBuild', + project, inputArtifact: artifact, outputArtifactName: 'Artifact1', additionalOutputArtifactNames: [ @@ -202,32 +209,32 @@ export = { ], }); - // TODO: remove "as any" - test.equal((action as any)._outputArtifacts.length, 1); + test.equal((action as any).actionOutputArtifacts.length, 1); + test.done(); }, }, }; function boundsValidationResult(numberOfArtifacts: number, min: number, max: number): string[] { - const artifacts: cpapi.Artifact[] = []; + const artifacts: codepipeline.Artifact[] = []; for (let i = 0; i < numberOfArtifacts; i++) { - artifacts.push(new cpapi.Artifact(`TestArtifact${i}`)); + artifacts.push(new codepipeline.Artifact(`TestArtifact${i}`)); } - return cpapi.validateArtifactBounds('output', artifacts, min, max, 'testCategory', 'testProvider'); + return codepipeline.validateArtifactBounds('output', artifacts, min, max, 'testCategory', 'testProvider'); } -class FakeAction extends cpapi.Action { +class FakeAction extends codepipeline.Action { constructor(actionName: string) { super({ actionName, - category: cpapi.ActionCategory.Source, + category: codepipeline.ActionCategory.Source, provider: 'SomeService', - artifactBounds: cpapi.defaultBounds(), + artifactBounds: codepipeline.defaultBounds(), }); } - protected bind(_info: cpapi.ActionBind): void { + protected bind(_info: codepipeline.ActionBind): void { // do nothing } } diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.pipeline.ts b/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts similarity index 92% rename from packages/@aws-cdk/aws-codepipeline/test/test.pipeline.ts rename to packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts index f91fa3bdffbb4..470299866ed7e 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline-actions/test/test.pipeline.ts @@ -1,14 +1,13 @@ import { expect, haveResource, haveResourceLike, SynthUtils } from '@aws-cdk/assert'; -import cloudformation = require('@aws-cdk/aws-cloudformation'); import codebuild = require('@aws-cdk/aws-codebuild'); import codecommit = require('@aws-cdk/aws-codecommit'); -import cpapi = require('@aws-cdk/aws-codepipeline-api'); +import codepipeline = require('@aws-cdk/aws-codepipeline'); import lambda = require('@aws-cdk/aws-lambda'); import s3 = require('@aws-cdk/aws-s3'); import sns = require('@aws-cdk/aws-sns'); import cdk = require('@aws-cdk/cdk'); import { Test } from 'nodeunit'; -import codepipeline = require('../lib'); +import cpactions = require('../lib'); // tslint:disable:object-literal-key-quotes @@ -21,7 +20,7 @@ export = { }); const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); - const source = new codecommit.PipelineSourceAction({ + const source = new cpactions.CodeCommitSourceAction({ actionName: 'source', outputArtifactName: 'SourceArtifact', repository, @@ -37,7 +36,7 @@ export = { pipeline.addStage({ name: 'build', actions: [ - new codebuild.PipelineBuildAction({ + new cpactions.CodeBuildBuildAction({ actionName: 'build', inputArtifact: source.outputArtifact, project, @@ -76,7 +75,7 @@ export = { p.addStage({ name: 'Source', actions: [ - new codepipeline.GitHubSourceAction({ + new cpactions.GitHubSourceAction({ actionName: 'GH', runOrder: 8, outputArtifactName: 'A', @@ -91,7 +90,7 @@ export = { p.addStage({ name: 'Two', actions: [ - new codepipeline.ManualApprovalAction({ actionName: 'Boo' }), + new cpactions.ManualApprovalAction({ actionName: 'Boo' }), ], }); @@ -173,7 +172,7 @@ export = { pipeline.addStage({ name: 'S1', actions: [ - new s3.PipelineSourceAction({ + new cpactions.S3SourceAction({ actionName: 'A1', outputArtifactName: 'Artifact', bucket: new s3.Bucket(stack, 'Bucket'), @@ -185,7 +184,7 @@ export = { pipeline.addStage({ name: 'S2', actions: [ - new codepipeline.ManualApprovalAction({ actionName: 'A2' }), + new cpactions.ManualApprovalAction({ actionName: 'A2' }), ], }); @@ -259,7 +258,7 @@ export = { 'allows passing an SNS Topic when constructing it'(test: Test) { const stack = new cdk.Stack(); const topic = new sns.Topic(stack, 'Topic'); - const manualApprovalAction = new codepipeline.ManualApprovalAction({ + const manualApprovalAction = new cpactions.ManualApprovalAction({ actionName: 'Approve', notificationTopic: topic, }); @@ -319,15 +318,17 @@ export = { const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); const bucket = new s3.Bucket(stack, 'Bucket'); - const source1 = bucket.toCodePipelineSourceAction({ + const source1 = new cpactions.S3SourceAction({ actionName: 'SourceAction1', bucketKey: 'some/key', outputArtifactName: 'sourceArtifact1', + bucket, }); - const source2 = bucket.toCodePipelineSourceAction({ + const source2 = new cpactions.S3SourceAction({ actionName: 'SourceAction2', bucketKey: 'another/key', outputArtifactName: 'sourceArtifact2', + bucket, }); pipeline.addStage({ name: 'Source', @@ -337,7 +338,7 @@ export = { ], }); - const lambdaAction = new lambda.PipelineInvokeAction({ + const lambdaAction = new cpactions.LambdaInvokeAction({ actionName: 'InvokeAction', lambda: lambdaFun, userParameters: 'foo-bar/42', @@ -437,7 +438,7 @@ export = { 'CodeCommit Action': { 'does not poll for changes by default'(test: Test) { const stack = new cdk.Stack(); - const sourceAction = new codecommit.PipelineSourceAction({ + const sourceAction = new cpactions.CodeCommitSourceAction({ actionName: 'stage', outputArtifactName: 'SomeArtifact', repository: repositoryForTesting(stack), @@ -450,7 +451,7 @@ export = { 'does not poll for source changes when explicitly set to false'(test: Test) { const stack = new cdk.Stack(); - const sourceAction = new codecommit.PipelineSourceAction({ + const sourceAction = new cpactions.CodeCommitSourceAction({ actionName: 'stage', outputArtifactName: 'SomeArtifact', repository: repositoryForTesting(stack), @@ -483,9 +484,10 @@ export = { }, }); - const sourceAction = bucket.toCodePipelineSourceAction({ + const sourceAction = new cpactions.S3SourceAction({ actionName: 'BucketSource', bucketKey: '/some/key', + bucket, }); pipeline.addStage({ name: 'Stage1', @@ -495,7 +497,7 @@ export = { pipeline.addStage({ name: 'Stage2', actions: [ - new cloudformation.PipelineCreateReplaceChangeSetAction({ + new cpactions.CloudFormationCreateReplaceChangeSetAction({ actionName: 'Action1', changeSetName: 'ChangeSet', templatePath: sourceAction.outputArtifact.atPath('template.yaml'), @@ -503,14 +505,14 @@ export = { region: pipelineRegion, adminPermissions: false, }), - new cloudformation.PipelineCreateUpdateStackAction({ + new cpactions.CloudFormationCreateUpdateStackAction({ actionName: 'Action2', templatePath: sourceAction.outputArtifact.atPath('template.yaml'), stackName: 'OtherStack', region: 'us-east-1', adminPermissions: false, }), - new cloudformation.PipelineExecuteChangeSetAction({ + new cpactions.CloudFormationExecuteChangeSetAction({ actionName: 'Action3', changeSetName: 'ChangeSet', stackName: 'SomeStack', @@ -580,7 +582,7 @@ export = { }, }; -function stageForTesting(stack: cdk.Stack): cpapi.IStage { +function stageForTesting(stack: cdk.Stack): codepipeline.IStage { const pipeline = new codepipeline.Pipeline(stack, 'pipeline'); return pipeline.addStage({ name: 'stage' }); } diff --git a/packages/@aws-cdk/aws-codepipeline-api/README.md b/packages/@aws-cdk/aws-codepipeline-api/README.md index bd7b88fd43aa9..16176e56a75f3 100644 --- a/packages/@aws-cdk/aws-codepipeline-api/README.md +++ b/packages/@aws-cdk/aws-codepipeline-api/README.md @@ -1,10 +1,3 @@ ## AWS CodePipeline Actions API -This package contains the abstract API of Pipeline Actions. -It's used by the `aws-codepipeline` module, -and the AWS service modules that integrate with AWS CodePipeline. - -You should never need to depend on it directly - -instead, depend on `aws-codepipeline`, -and the module you need the concrete Actions from -(like `aws-codecommit`, `aws-codebuild`, etc.). +This package is no longer used, and will be removed in a future version of the CDK. diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/index.ts b/packages/@aws-cdk/aws-codepipeline-api/lib/index.ts index 96229c6f95a9f..e69de29bb2d1d 100644 --- a/packages/@aws-cdk/aws-codepipeline-api/lib/index.ts +++ b/packages/@aws-cdk/aws-codepipeline-api/lib/index.ts @@ -1,7 +0,0 @@ -export * from './artifact'; -export * from './action'; -export * from './build-action'; -export * from './deploy-action'; -export * from './source-action'; -export * from './test-action'; -export * from './validation'; diff --git a/packages/@aws-cdk/aws-codepipeline-api/package.json b/packages/@aws-cdk/aws-codepipeline-api/package.json index 16a62b64673bc..1fac4256e7aeb 100644 --- a/packages/@aws-cdk/aws-codepipeline-api/package.json +++ b/packages/@aws-cdk/aws-codepipeline-api/package.json @@ -62,24 +62,8 @@ "cdk-integ-tools": "^0.27.0", "pkglint": "^0.27.0" }, - "dependencies": { - "@aws-cdk/aws-events": "^0.27.0", - "@aws-cdk/aws-iam": "^0.27.0", - "@aws-cdk/cdk": "^0.27.0" - }, "homepage": "https://github.com/awslabs/aws-cdk", - "peerDependencies": { - "@aws-cdk/aws-events": "^0.27.0", - "@aws-cdk/aws-iam": "^0.27.0", - "@aws-cdk/cdk": "^0.27.0" - }, "engines": { "node": ">= 8.10.0" - }, - "awslint": { - "exclude": [ - "construct-ctor:@aws-cdk/aws-codepipeline-api.Artifact..params[0]", - "construct-ctor:@aws-cdk/aws-codepipeline-api.Artifact..params[1]" - ] } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-codepipeline/README.md b/packages/@aws-cdk/aws-codepipeline/README.md index f34f41cdb6815..b6571a4205c1e 100644 --- a/packages/@aws-cdk/aws-codepipeline/README.md +++ b/packages/@aws-cdk/aws-codepipeline/README.md @@ -49,7 +49,7 @@ const sourceStage = pipeline.addStage({ You can insert the new Stage at an arbitrary point in the Pipeline: ```ts -pipeline.addStage({ +const someStage = pipeline.addStage({ name: 'SomeStage', placement: { // note: you can only specify one of the below properties @@ -63,98 +63,14 @@ pipeline.addStage({ ### Actions -To add an Action to a Stage: +Actions live in a separate package, `@aws-cdk/aws-codepipeline-actions`. -```ts -const sourceAction = new codepipeline.GitHubSourceAction({ - actionName: 'GitHub_Source', - owner: 'awslabs', - repo: 'aws-cdk', - branch: 'develop', // default: 'master' - oauthToken: ..., - outputArtifactName: 'SourceOutput', // this will be the name of the output artifact in the Pipeline -}); -sourceStage.addAction(sourceAction); -``` - -#### Manual approval Action - -This package contains an Action that stops the Pipeline until someone manually clicks the approve button: - -```typescript -const manualApprovalAction = new codepipeline.ManualApprovalAction({ - actionName: 'Approve', - notificationTopic: new sns.Topic(this, 'Topic'), // optional - notifyEmails: [ - 'some_email@example.com', - ], // optional - additionalInformation: 'additional info', // optional -}); -approveStage.addAction(manualApprovalAction); -// `manualApprovalAction.notificationTopic` can be used to access the Topic -// after the Action has been added to a Pipeline -``` - -If the `notificationTopic` has not been provided, -but `notifyEmails` were, -a new SNS Topic will be created -(and accessible through the `notificationTopic` property of the Action). - -#### Jenkins Actions - -In order to use Jenkins Actions in the Pipeline, -you first need to create a `JenkinsProvider`: +To add an Action to a Stage, you can provide it when creating the Stage, +in the `actions` property, +or you can use the `IStage.addAction()` method to mutate an existing Stage: ```ts -const jenkinsProvider = new codepipeline.JenkinsProvider(this, 'JenkinsProvider', { - providerName: 'MyJenkinsProvider', - serverUrl: 'http://my-jenkins.com:8080', - version: '2', // optional, default: '1' -}); -``` - -If you've registered a Jenkins provider in a different CDK app, -or outside the CDK (in the CodePipeline AWS Console, for example), -you can import it: - -```ts -const jenkinsProvider = codepipeline.JenkinsProvider.import(this, 'JenkinsProvider', { - providerName: 'MyJenkinsProvider', - serverUrl: 'http://my-jenkins.com:8080', - version: '2', // optional, default: '1' -}); -``` - -Note that a Jenkins provider -(identified by the provider name-category(build/test)-version tuple) -must always be registered in the given account, in the given AWS region, -before it can be used in CodePipeline. - -With a `JenkinsProvider`, -we can create a Jenkins Action: - -```ts -const buildAction = new codepipeline.JenkinsBuildAction({ - actionName: 'JenkinsBuild', - jenkinsProvider: jenkinsProvider, - projectName: 'MyProject', -}); -// there's also a JenkinsTestAction that works identically -``` - -You can also add the Action to the Pipeline directly: - -```ts -// equivalent to the code above: -const buildAction = jenkinsProvider.toCodePipelineBuildAction({ - actionName: 'JenkinsBuild', - projectName: 'MyProject', -}); - -const testAction = jenkinsProvider.toCodePipelineTestAction({ - actionName: 'JenkinsTest', - projectName: 'MyProject', -}); +sourceStage.addAction(someAction); ``` ### Cross-region CodePipelines @@ -174,7 +90,7 @@ const pipeline = new codepipeline.Pipeline(this, 'MyFirstPipeline', { }); // later in the code... -new cloudformation.PipelineCreateUpdateStackAction({ +new codepipeline_actions.CloudFormationCreateUpdateStackAction({ actionName: 'CFN_US_West_1', // ... region: 'us-west-1', diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/action.ts b/packages/@aws-cdk/aws-codepipeline/lib/action.ts similarity index 98% rename from packages/@aws-cdk/aws-codepipeline-api/lib/action.ts rename to packages/@aws-cdk/aws-codepipeline/lib/action.ts index 122489dfd831b..44f93970196ec 100644 --- a/packages/@aws-cdk/aws-codepipeline-api/lib/action.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/action.ts @@ -252,17 +252,11 @@ export abstract class Action { return rule; } - /** - * @internal - */ - public get _inputArtifacts(): Artifact[] { + protected get actionInputArtifacts(): Artifact[] { return this._actionInputArtifacts.slice(); } - /** - * @internal - */ - public get _outputArtifacts(): Artifact[] { + protected get actionOutputArtifacts(): Artifact[] { return this._actionOutputArtifacts.slice(); } @@ -277,7 +271,7 @@ export abstract class Action { protected addOutputArtifact(name: string): Artifact { // adding the same name multiple times doesn't do anything - // addOutputArtifact is idempotent - const ret = this._outputArtifacts.find(output => output.artifactName === name); + const ret = this.actionOutputArtifacts.find(output => output.artifactName === name); if (ret) { return ret; } diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/artifact.ts b/packages/@aws-cdk/aws-codepipeline/lib/artifact.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/artifact.ts rename to packages/@aws-cdk/aws-codepipeline/lib/artifact.ts diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/build-action.ts b/packages/@aws-cdk/aws-codepipeline/lib/build-action.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/build-action.ts rename to packages/@aws-cdk/aws-codepipeline/lib/build-action.ts diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/deploy-action.ts b/packages/@aws-cdk/aws-codepipeline/lib/deploy-action.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/deploy-action.ts rename to packages/@aws-cdk/aws-codepipeline/lib/deploy-action.ts diff --git a/packages/@aws-cdk/aws-codepipeline/lib/index.ts b/packages/@aws-cdk/aws-codepipeline/lib/index.ts index 2a1bec4de1230..d2ff046e9bdba 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/index.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/index.ts @@ -1,9 +1,12 @@ +export * from './action'; +export * from './artifact'; +export * from './build-action'; export * from './cross-region-scaffold-stack'; -export * from './github-source-action'; -export * from './jenkins-actions'; -export * from './jenkins-provider'; -export * from './manual-approval-action'; +export * from './deploy-action'; export * from './pipeline'; +export * from './source-action'; +export * from './test-action'; +export * from './validation'; // AWS::CodePipeline CloudFormation Resources: export * from './codepipeline.generated'; diff --git a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts index d74b6af47b670..b0faadbafc8f2 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts @@ -1,11 +1,12 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); +import { Action, IPipeline, IStage } from "./action"; import { CfnPipeline } from './codepipeline.generated'; import { CrossRegionScaffoldStack } from './cross-region-scaffold-stack'; import { Stage } from './stage'; +import { validateName, validateSourceAction } from "./validation"; /** * Allows you to control where to place a new Stage when it's added to the Pipeline. @@ -21,13 +22,13 @@ export interface StagePlacement { * Inserts the new Stage as a parent of the given Stage * (changing its current parent Stage, if it had one). */ - readonly rightBefore?: cpapi.IStage; + readonly rightBefore?: IStage; /** * Inserts the new Stage as a child of the given Stage * (changing its current child Stage, if it had one). */ - readonly justAfter?: cpapi.IStage; + readonly justAfter?: IStage; /** * Inserts the new Stage at the given index in the Pipeline, @@ -53,7 +54,7 @@ export interface StageProps { * The list of Actions to create this Stage with. * You can always add more Actions later by calling {@link IStage#addAction}. */ - readonly actions?: cpapi.Action[]; + readonly actions?: Action[]; } export interface StageAddToPipelineProps extends StageProps { @@ -107,7 +108,7 @@ export interface PipelineProps { * const sourceStage = pipeline.addStage({ name: 'Source' }); * * // add a source action to the stage - * sourceStage.addAction(new codecommit.PipelineSourceAction({ + * sourceStage.addAction(new codepipeline_actions.CodeCommitSourceAction({ * actionName: 'Source', * outputArtifactName: 'SourceArtifact', * repository: repo, @@ -115,7 +116,7 @@ export interface PipelineProps { * * // ... add more stages */ -export class Pipeline extends cdk.Construct implements cpapi.IPipeline { +export class Pipeline extends cdk.Construct implements IPipeline { /** * The IAM role AWS CodePipeline will use to perform actions or assume roles for actions with * a more specific IAM role. @@ -153,7 +154,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { super(scope, id); props = props || {}; - cpapi.validateName('Pipeline', props.pipelineName); + validateName('Pipeline', props.pipelineName); // If a bucket has been provided, use it - otherwise, create a bucket. let propsBucket = props.artifactBucket; @@ -204,7 +205,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { * @param props the creation properties of the new Stage * @returns the newly created Stage */ - public addStage(props: StageAddToPipelineProps): cpapi.IStage { + public addStage(props: StageAddToPipelineProps): IStage { // check for duplicate Stages and names if (this.stages.find(s => s.stageName === props.name)) { throw new Error(`Stage with duplicate name '${props.name}' added to the Pipeline`); @@ -329,7 +330,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { // ignore unused private method (it's actually used in Stage) // @ts-ignore - private _attachActionToPipeline(stage: Stage, action: cpapi.Action, actionScope: cdk.Construct): void { + private _attachActionToPipeline(stage: Stage, action: Action, actionScope: cdk.Construct): void { if (action.region) { // handle cross-region Actions here this.ensureReplicationBucketExistsFor(action.region); @@ -420,7 +421,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { return this.stageCount; } - private findStageIndex(targetStage: cpapi.IStage) { + private findStageIndex(targetStage: IStage) { return this.stages.findIndex(stage => stage === targetStage); } @@ -430,7 +431,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline { for (const stage of this.stages) { const onlySourceActionsPermitted = firstStage; for (const action of stage.actions) { - errors.push(...cpapi.validateSourceAction(onlySourceActionsPermitted, action.category, action.actionName, stage.stageName)); + errors.push(...validateSourceAction(onlySourceActionsPermitted, action.category, action.actionName, stage.stageName)); } firstStage = false; } diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/source-action.ts b/packages/@aws-cdk/aws-codepipeline/lib/source-action.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/source-action.ts rename to packages/@aws-cdk/aws-codepipeline/lib/source-action.ts diff --git a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts index 79425f11a7786..b8d8f725be02d 100644 --- a/packages/@aws-cdk/aws-codepipeline/lib/stage.ts +++ b/packages/@aws-cdk/aws-codepipeline/lib/stage.ts @@ -1,31 +1,32 @@ -import cpapi = require('@aws-cdk/aws-codepipeline-api'); import events = require('@aws-cdk/aws-events'); import cdk = require('@aws-cdk/cdk'); +import { Action, IPipeline, IStage } from "./action"; import { CfnPipeline } from './codepipeline.generated'; import { Pipeline, StageProps } from './pipeline'; +import { validateName } from "./validation"; /** * A Stage in a Pipeline. * * Stages are added to a Pipeline by calling {@link Pipeline#addStage}, - * which returns an instance of {@link cpapi.IStage}. + * which returns an instance of {@link codepipeline.IStage}. * * This class is private to the CodePipeline module. */ -export class Stage implements cpapi.IStage { +export class Stage implements IStage { /** * The Pipeline this Stage is a part of. */ - public readonly pipeline: cpapi.IPipeline; + public readonly pipeline: IPipeline; public readonly stageName: string; private readonly scope: cdk.Construct; - private readonly _actions = new Array(); + private readonly _actions = new Array(); /** * Create a new Stage. */ constructor(props: StageProps, pipeline: Pipeline) { - cpapi.validateName('Stage', props.name); + validateName('Stage', props.name); this.stageName = props.name; this.pipeline = pipeline; @@ -39,7 +40,7 @@ export class Stage implements cpapi.IStage { /** * Get a duplicate of this stage's list of actions. */ - public get actions(): cpapi.Action[] { + public get actions(): Action[] { return this._actions.slice(); } @@ -50,7 +51,7 @@ export class Stage implements cpapi.IStage { }; } - public addAction(action: cpapi.Action): void { + public addAction(action: Action): void { // check for duplicate Actions and names if (this._actions.find(a => a.actionName === action.actionName)) { throw new Error(`Stage ${this.stageName} already contains an action with name '${action.actionName}'`); @@ -78,17 +79,17 @@ export class Stage implements cpapi.IStage { return this.validateHasActions(); } - private attachActionToPipeline(action: cpapi.Action) { + private attachActionToPipeline(action: Action) { // notify the Pipeline of the new Action const actionScope = new cdk.Construct(this.scope, action.actionName); (this.pipeline as any)._attachActionToPipeline(this, action, actionScope); } - private renderAction(action: cpapi.Action): CfnPipeline.ActionDeclarationProperty { + private renderAction(action: Action): CfnPipeline.ActionDeclarationProperty { return { name: action.actionName, // TODO: remove "as any" - inputArtifacts: (action as any)._inputArtifacts.map((a: any) => ({ name: a.artifactName })), + inputArtifacts: (action as any).actionInputArtifacts.map((a: any) => ({ name: a.artifactName })), actionTypeId: { category: action.category.toString(), version: action.version, @@ -97,7 +98,7 @@ export class Stage implements cpapi.IStage { }, configuration: action.configuration, // TODO: remove "as any" - outputArtifacts: (action as any)._outputArtifacts.map((a: any) => ({ name: a.artifactName })), + outputArtifacts: (action as any).actionOutputArtifacts.map((a: any) => ({ name: a.artifactName })), runOrder: action.runOrder, roleArn: action.role ? action.role.roleArn : undefined }; diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/test-action.ts b/packages/@aws-cdk/aws-codepipeline/lib/test-action.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/test-action.ts rename to packages/@aws-cdk/aws-codepipeline/lib/test-action.ts diff --git a/packages/@aws-cdk/aws-codepipeline-api/lib/validation.ts b/packages/@aws-cdk/aws-codepipeline/lib/validation.ts similarity index 100% rename from packages/@aws-cdk/aws-codepipeline-api/lib/validation.ts rename to packages/@aws-cdk/aws-codepipeline/lib/validation.ts diff --git a/packages/@aws-cdk/aws-codepipeline/package.json b/packages/@aws-cdk/aws-codepipeline/package.json index c30093f1eda09..2bce47d4eaf2f 100644 --- a/packages/@aws-cdk/aws-codepipeline/package.json +++ b/packages/@aws-cdk/aws-codepipeline/package.json @@ -46,8 +46,8 @@ "cloudformation": "AWS::CodePipeline" }, "nyc": { - "statements": 66, - "lines": 66 + "statements": 50, + "lines": 50 }, "keywords": [ "aws", @@ -65,22 +65,13 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/alexa-ask": "^0.27.0", "@aws-cdk/assert": "^0.27.0", - "@aws-cdk/aws-cloudformation": "^0.27.0", - "@aws-cdk/aws-cloudtrail": "^0.27.0", - "@aws-cdk/aws-codebuild": "^0.27.0", - "@aws-cdk/aws-codecommit": "^0.27.0", - "@aws-cdk/aws-codedeploy": "^0.27.0", - "@aws-cdk/aws-ecr": "^0.27.0", - "@aws-cdk/aws-lambda": "^0.27.0", "cdk-build-tools": "^0.27.0", "cdk-integ-tools": "^0.27.0", "cfn2ts": "^0.27.0", "pkglint": "^0.27.0" }, "dependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-s3": "^0.27.0", @@ -89,7 +80,6 @@ }, "homepage": "https://github.com/awslabs/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-s3": "^0.27.0", @@ -102,7 +92,9 @@ "awslint": { "exclude": [ "construct-ctor:@aws-cdk/aws-codepipeline.CrossRegionScaffoldStack..params[0]", - "construct-ctor:@aws-cdk/aws-codepipeline.CrossRegionScaffoldStack..params[1]" + "construct-ctor:@aws-cdk/aws-codepipeline.CrossRegionScaffoldStack..params[1]", + "export:@aws-cdk/aws-codepipeline.IPipeline", + "import-props-interface:@aws-cdk/aws-codepipeline.PipelineImportProps" ] } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-codepipeline/test/test.general-validation.ts b/packages/@aws-cdk/aws-codepipeline/test/test.general-validation.ts index 92b400299a67d..efc26db32809b 100644 --- a/packages/@aws-cdk/aws-codepipeline/test/test.general-validation.ts +++ b/packages/@aws-cdk/aws-codepipeline/test/test.general-validation.ts @@ -1,8 +1,9 @@ -import actions = require('@aws-cdk/aws-codepipeline-api'); -import s3 = require('@aws-cdk/aws-s3'); import cdk = require('@aws-cdk/cdk'); import { Test } from 'nodeunit'; +import { ActionBind, IStage } from "../lib/action"; import { Pipeline } from '../lib/pipeline'; +import { SourceAction, SourceActionProps } from "../lib/source-action"; +import { validateName } from "../lib/validation"; interface NameValidationTestCase { name: string; @@ -21,7 +22,7 @@ export = { cases.forEach(testCase => { const name = testCase.name; - const validationBlock = () => { actions.validateName('test thing', name); }; + const validationBlock = () => { validateName('test thing', name); }; if (testCase.shouldPassValidation) { test.doesNotThrow(validationBlock, Error, `${name} failed validation but ${testCase.explanation}`); } else { @@ -56,16 +57,14 @@ export = { const stack = new cdk.Stack(); const pipeline = new Pipeline(stack, 'Pipeline'); - const bucket = new s3.Bucket(stack, 'PipelineBucket'); pipeline.addStage({ name: 'FirstStage', actions: [ - new s3.PipelineSourceAction({ - actionName: 'FirstAction', - outputArtifactName: 'FirstArtifact', - bucket, - bucketKey: 'key', - }) + new FakeSourceAction({ + actionName: 'FakeSource', + provider: 'Fake', + outputArtifactName: 'SourceOutput', + }), ], }); @@ -76,7 +75,17 @@ export = { } }; -function stageForTesting(): actions.IStage { +class FakeSourceAction extends SourceAction { + constructor(props: SourceActionProps) { + super(props); + } + + protected bind(_info: ActionBind): void { + // do nothing + } +} + +function stageForTesting(): IStage { const stack = new cdk.Stack(); const pipeline = new Pipeline(stack, 'Pipeline'); return pipeline.addStage({ name: 'stage' }); diff --git a/packages/@aws-cdk/aws-ecr/README.md b/packages/@aws-cdk/aws-ecr/README.md index bdcafd84698f5..93a7e841a25bf 100644 --- a/packages/@aws-cdk/aws-ecr/README.md +++ b/packages/@aws-cdk/aws-ecr/README.md @@ -23,31 +23,3 @@ is important here): repository.addLifecycleRule({ tagPrefixList: ['prod'], maxImageCount: 9999 }); repository.addLifecycleRule({ maxImageAgeDays: 30 }); ``` - -### Using with CodePipeline - -This package also contains a source Action that allows you to use an ECR Repository as a source for CodePipeline. -Example: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); -const sourceAction = new ecr.PipelineSourceAction({ - actionName: 'ECR', - repository: ecrRepository, - imageTag: 'some-tag', // optional, default: 'latest' - outputArtifactName: 'SomeName', // optional -}); -pipeline.addStage({ - actionName: 'Source', - actions: [sourceAction], -}); -``` - -You can also create the action from the Repository directly: - -```ts -// equivalent to the code above: -const sourceAction = ecrRepository.toCodePipelineSourceAction({ actionName: 'ECR' }); -``` diff --git a/packages/@aws-cdk/aws-ecr/lib/index.ts b/packages/@aws-cdk/aws-ecr/lib/index.ts index 39da13ce26a30..21b453e140916 100644 --- a/packages/@aws-cdk/aws-ecr/lib/index.ts +++ b/packages/@aws-cdk/aws-ecr/lib/index.ts @@ -1,7 +1,6 @@ // AWS::ECR CloudFormation Resources: export * from './ecr.generated'; -export * from './pipeline-action'; export * from './repository'; export * from './repository-ref'; export * from './lifecycle'; diff --git a/packages/@aws-cdk/aws-ecr/lib/repository-ref.ts b/packages/@aws-cdk/aws-ecr/lib/repository-ref.ts index e7cd21dd3b74e..c719ff0a6bd36 100644 --- a/packages/@aws-cdk/aws-ecr/lib/repository-ref.ts +++ b/packages/@aws-cdk/aws-ecr/lib/repository-ref.ts @@ -1,7 +1,6 @@ import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import cdk = require('@aws-cdk/cdk'); -import { CommonPipelineSourceActionProps, PipelineSourceAction } from './pipeline-action'; /** * Represents an ECR repository. @@ -39,15 +38,6 @@ export interface IRepository extends cdk.IConstruct { */ addToResourcePolicy(statement: iam.PolicyStatement): void; - /** - * Convenience method for creating a new {@link PipelineSourceAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineSourceAction} - */ - toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): - PipelineSourceAction; - /** * Grant the given principal identity permissions to perform the actions on this repository */ @@ -169,13 +159,6 @@ export abstract class RepositoryBase extends cdk.Construct implements IRepositor */ public abstract export(): RepositoryImportProps; - public toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): PipelineSourceAction { - return new PipelineSourceAction({ - ...props, - repository: this, - }); - } - /** * Defines an AWS CloudWatch event rule that can trigger a target when an image is pushed to this * repository. diff --git a/packages/@aws-cdk/aws-ecr/package.json b/packages/@aws-cdk/aws-ecr/package.json index 20b4a979c31db..9c42ce4021819 100644 --- a/packages/@aws-cdk/aws-ecr/package.json +++ b/packages/@aws-cdk/aws-ecr/package.json @@ -69,14 +69,12 @@ "pkglint": "^0.27.0" }, "dependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/cdk": "^0.27.0" }, "homepage": "https://github.com/awslabs/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/cdk": "^0.27.0" @@ -89,4 +87,4 @@ "import:@aws-cdk/aws-ecr.Repository" ] } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-lambda/README.md b/packages/@aws-cdk/aws-lambda/README.md index 2bf3c4a7bef4e..f81166476bc88 100644 --- a/packages/@aws-cdk/aws-lambda/README.md +++ b/packages/@aws-cdk/aws-lambda/README.md @@ -72,54 +72,6 @@ fn.addEventSource(new S3EventSource(bucket, { See the documentation for the __@aws-cdk/aws-lambda-event-sources__ module for more details. -### Lambda in CodePipeline - -This module also contains an Action that allows you to invoke a Lambda function from CodePipeline: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); -const lambdaAction = new lambda.PipelineInvokeAction({ - actionName: 'Lambda', - lambda: fn, -}); -pipeline.addStage({ - actionName: 'Lambda', - actions: [lambdaAction], -}); -``` - -You can also create the action from the Lambda directly: - -```ts -// equivalent to the code above: -const lambdaAction = fn.toCodePipelineInvokeAction({ actionName: 'Lambda' }); -``` - -The Lambda Action can have up to 5 inputs, -and up to 5 outputs: - -```typescript -const lambdaAction = fn.toCodePipelineInvokeAction({ - actionName: 'Lambda', - inputArtifacts: [ - sourceAction.outputArtifact, - buildAction.outputArtifact, - ], - outputArtifactNames: [ - 'Out1', - 'Out2', - ], -}); - -lambdaAction.outputArtifacts(); // returns the list of output Artifacts -lambdaAction.outputArtifact('Out2'); // returns the named output Artifact, or throws an exception if not found -``` - -See [the AWS documentation](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html) -on how to write a Lambda function invoked from CodePipeline. - ### Lambda with DLQ ```ts diff --git a/packages/@aws-cdk/aws-lambda/lib/function-base.ts b/packages/@aws-cdk/aws-lambda/lib/function-base.ts index dae6addfab995..b1a2be0de15c3 100644 --- a/packages/@aws-cdk/aws-lambda/lib/function-base.ts +++ b/packages/@aws-cdk/aws-lambda/lib/function-base.ts @@ -9,7 +9,6 @@ import cdk = require('@aws-cdk/cdk'); import { IEventSource } from './event-source'; import { CfnPermission } from './lambda.generated'; import { Permission } from './permission'; -import { CommonPipelineInvokeActionProps, PipelineInvokeAction } from './pipeline-action'; export interface IFunction extends cdk.IConstruct, events.IEventRuleTarget, logs.ILogSubscriptionDestination, s3n.IBucketNotificationDestination, ec2.IConnectable, stepfunctions.IStepFunctionsTaskResource { @@ -47,14 +46,6 @@ export interface IFunction extends cdk.IConstruct, events.IEventRuleTarget, logs */ addPermission(id: string, permission: Permission): void; - /** - * Convenience method for creating a new {@link PipelineInvokeAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineInvokeAction} - */ - toCodePipelineInvokeAction(props: CommonPipelineInvokeActionProps): PipelineInvokeAction; - addToRolePolicy(statement: iam.PolicyStatement): void; /** @@ -187,13 +178,6 @@ export abstract class FunctionBase extends cdk.Construct implements IFunction { return this.node.id; } - public toCodePipelineInvokeAction(props: CommonPipelineInvokeActionProps): PipelineInvokeAction { - return new PipelineInvokeAction({ - ...props, - lambda: this, - }); - } - public addToRolePolicy(statement: iam.PolicyStatement) { if (!this.role) { return; diff --git a/packages/@aws-cdk/aws-lambda/lib/index.ts b/packages/@aws-cdk/aws-lambda/lib/index.ts index 003ee3af81430..8def6e736af0e 100644 --- a/packages/@aws-cdk/aws-lambda/lib/index.ts +++ b/packages/@aws-cdk/aws-lambda/lib/index.ts @@ -3,7 +3,6 @@ export * from './function-base'; export * from './function'; export * from './layers'; export * from './permission'; -export * from './pipeline-action'; export * from './runtime'; export * from './code'; export * from './lambda-version'; diff --git a/packages/@aws-cdk/aws-lambda/package.json b/packages/@aws-cdk/aws-lambda/package.json index 870359f59c477..52b75d1ed17c7 100644 --- a/packages/@aws-cdk/aws-lambda/package.json +++ b/packages/@aws-cdk/aws-lambda/package.json @@ -78,7 +78,6 @@ "dependencies": { "@aws-cdk/assets": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-ec2": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", @@ -94,7 +93,6 @@ "peerDependencies": { "@aws-cdk/assets": "^0.27.0", "@aws-cdk/aws-cloudwatch": "^0.27.0", - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-ec2": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", @@ -108,4 +106,4 @@ "engines": { "node": ">= 8.10.0" } -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/aws-s3/README.md b/packages/@aws-cdk/aws-s3/README.md index b89b3b32971a0..06a02424dd7d9 100644 --- a/packages/@aws-cdk/aws-s3/README.md +++ b/packages/@aws-cdk/aws-s3/README.md @@ -82,98 +82,6 @@ bucket.grantReadWrite(lambda.role); Will give the Lambda's execution role permissions to read and write from the bucket. -### Buckets as sources in CodePipeline - -This package also defines an Action that allows you to use a -Bucket as a source in CodePipeline: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); -import s3 = require('@aws-cdk/aws-s3'); - -const sourceBucket = new s3.Bucket(this, 'MyBucket', { - versioned: true, // a Bucket used as a source in CodePipeline must be versioned -}); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); -const sourceAction = new s3.PipelineSourceAction({ - actionName: 'S3Source', - bucket: sourceBucket, - bucketKey: 'path/to/file.zip', -}); -pipeline.addStage({ - name: 'Source', - actions: [sourceAction], -}); -``` - -You can also create the action from the Bucket directly: - -```ts -// equivalent to the code above: -const sourceAction = sourceBucket.toCodePipelineSourceAction({ - actionName: 'S3Source', - bucketKey: 'path/to/file.zip', -}); -``` - -By default, the Pipeline will poll the Bucket to detect changes. -You can change that behavior to use CloudWatch Events by setting the `pollForSourceChanges` -property to `false` (it's `true` by default). -If you do that, make sure the source Bucket is part of an AWS CloudTrail Trail - -otherwise, the CloudWatch Events will not be emitted, -and your Pipeline will not react to changes in the Bucket. -You can do it through the CDK: - -```typescript -import cloudtrail = require('@aws-cdk/aws-cloudtrail'); - -const key = 'some/key.zip'; -const trail = new cloudtrail.CloudTrail(this, 'CloudTrail'); -trail.addS3EventSelector([sourceBucket.arnForObjects(key)], cloudtrail.ReadWriteType.WriteOnly); -const sourceAction = sourceBucket.toCodePipelineSourceAction({ - actionName: 'S3Source', - bucketKey: key, - pollForSourceChanges: false, // default: true -}); -``` - -### Buckets as deploy targets in CodePipeline - -This package also defines an Action that allows you to use a -Bucket as a deployment target in CodePipeline: - -```ts -import codepipeline = require('@aws-cdk/aws-codepipeline'); -import s3 = require('@aws-cdk/aws-s3'); - -const targetBucket = new s3.Bucket(this, 'MyBucket', {}); - -const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); -const deployAction = new s3.PipelineDeployAction({ - actionName: 'S3Deploy', - stage: deployStage, - bucket: targetBucket, - inputArtifact: sourceAction.outputArtifact, -}); -const deployStage = pipeline.addStage({ - name: 'Deploy', - actions: [deployAction], -}); -``` - -You can also create the action from the Bucket directly: - -```ts -// equivalent to the code above: -const deployAction = targetBucket.toCodePipelineDeployAction({ - actionName: 'S3Deploy', - extract: false, // default: true - objectKey: 'path/in/bucket', // required if extract is false - inputArtifact: sourceAction.outputArtifact, -}); -``` - ### Sharing buckets between stacks To use a bucket in a different stack in the same CDK application, pass the object to the other stack: diff --git a/packages/@aws-cdk/aws-s3/lib/bucket.ts b/packages/@aws-cdk/aws-s3/lib/bucket.ts index b155b767feb4f..32b44413009c7 100644 --- a/packages/@aws-cdk/aws-s3/lib/bucket.ts +++ b/packages/@aws-cdk/aws-s3/lib/bucket.ts @@ -6,10 +6,6 @@ import cdk = require('@aws-cdk/cdk'); import { BucketPolicy } from './bucket-policy'; import { BucketNotifications } from './notifications-resource'; import perms = require('./perms'); -import { - CommonPipelineDeployActionProps, CommonPipelineSourceActionProps, - PipelineDeployAction, PipelineSourceAction -} from './pipeline-actions'; import { LifecycleRule } from './rule'; import { CfnBucket } from './s3.generated'; import { parseBucketArn, parseBucketName } from './util'; @@ -55,22 +51,6 @@ export interface IBucket extends cdk.IConstruct { */ export(): BucketImportProps; - /** - * Convenience method for creating a new {@link PipelineSourceAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineSourceAction} - */ - toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): PipelineSourceAction; - - /** - * Convenience method for creating a new {@link PipelineDeployAction}. - * - * @param props the construction properties of the new Action - * @returns the newly created {@link PipelineDeployAction} - */ - toCodePipelineDeployAction(props: CommonPipelineDeployActionProps): PipelineDeployAction; - /** * Adds a statement to the resource policy for a principal (i.e. * account/role/service) to perform actions on this bucket and/or it's @@ -296,20 +276,6 @@ export abstract class BucketBase extends cdk.Construct implements IBucket { */ public abstract export(): BucketImportProps; - public toCodePipelineSourceAction(props: CommonPipelineSourceActionProps): PipelineSourceAction { - return new PipelineSourceAction({ - ...props, - bucket: this, - }); - } - - public toCodePipelineDeployAction(props: CommonPipelineDeployActionProps): PipelineDeployAction { - return new PipelineDeployAction({ - ...props, - bucket: this, - }); - } - public onPutObject(name: string, target?: events.IEventRuleTarget, path?: string): events.EventRule { const eventRule = new events.EventRule(this, name, { eventPattern: { diff --git a/packages/@aws-cdk/aws-s3/lib/index.ts b/packages/@aws-cdk/aws-s3/lib/index.ts index f7d6f0d21696e..593c797757b3f 100644 --- a/packages/@aws-cdk/aws-s3/lib/index.ts +++ b/packages/@aws-cdk/aws-s3/lib/index.ts @@ -1,6 +1,5 @@ export * from './bucket'; export * from './bucket-policy'; -export * from './pipeline-actions'; export * from './rule'; // AWS::S3 CloudFormation Resources: diff --git a/packages/@aws-cdk/aws-s3/lib/pipeline-actions.ts b/packages/@aws-cdk/aws-s3/lib/pipeline-actions.ts deleted file mode 100644 index b851e1b88221e..0000000000000 --- a/packages/@aws-cdk/aws-s3/lib/pipeline-actions.ts +++ /dev/null @@ -1,143 +0,0 @@ -import codepipeline = require('@aws-cdk/aws-codepipeline-api'); -import { IBucket } from './bucket'; - -/** - * Common properties for creating {@link PipelineSourceAction} - - * either directly, through its constructor, - * or through {@link IBucket#toCodePipelineSourceAction}. - */ -export interface CommonPipelineSourceActionProps extends codepipeline.CommonActionProps { - /** - * The name of the source's output artifact. CfnOutput artifacts are used by CodePipeline as - * inputs into other actions. - * - * @default a name will be auto-generated - */ - readonly outputArtifactName?: string; - - /** - * The key within the S3 bucket that stores the source code. - * - * @example 'path/to/file.zip' - */ - readonly bucketKey: string; - - /** - * Whether AWS CodePipeline should poll for source changes. - * If this is `false`, the Pipeline will use CloudWatch Events to detect source changes instead. - * Note that if this is `false`, you need to make sure to include the source Bucket in a CloudTrail Trail, - * as otherwise the CloudWatch Events will not be emitted. - * - * @default true - * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/log-s3-data-events.html - */ - readonly pollForSourceChanges?: boolean; -} - -/** - * Construction properties of the {@link PipelineSourceAction S3 source Action}. - */ -export interface PipelineSourceActionProps extends CommonPipelineSourceActionProps { - /** - * The Amazon S3 bucket that stores the source code - */ - readonly bucket: IBucket; -} - -/** - * Source that is provided by a specific Amazon S3 object. - */ -export class PipelineSourceAction extends codepipeline.SourceAction { - private readonly props: PipelineSourceActionProps; - - constructor(props: PipelineSourceActionProps) { - super({ - ...props, - provider: 'S3', - outputArtifactName: props.outputArtifactName || `Artifact_${props.actionName}_${props.bucket.node.uniqueId}`, - configuration: { - S3Bucket: props.bucket.bucketName, - S3ObjectKey: props.bucketKey, - PollForSourceChanges: props.pollForSourceChanges, - }, - }); - - this.props = props; - } - - protected bind(info: codepipeline.ActionBind): void { - if (this.props.pollForSourceChanges === false) { - this.props.bucket.onPutObject(info.pipeline.node.uniqueId + 'SourceEventRule', - info.pipeline, this.props.bucketKey); - } - - // pipeline needs permissions to read from the S3 bucket - this.props.bucket.grantRead(info.role); - } -} - -/** - * Common properties for creating {@link PipelineDeployAction} - - * either directly, through its constructor, - * or through {@link IBucket#toCodePipelineDeployAction}. - */ -export interface CommonPipelineDeployActionProps extends codepipeline.CommonActionProps { - /** - * Should the deploy action extract the artifact before deploying to Amazon S3. - * - * @default true - */ - readonly extract?: boolean; - - /** - * The key of the target object. This is required if extract is false. - */ - readonly objectKey?: string; - - /** - * The inputArtifact to deploy to Amazon S3. - */ - readonly inputArtifact: codepipeline.Artifact; -} - -/** - * Construction properties of the {@link PipelineDeployAction S3 deploy Action}. - */ -export interface PipelineDeployActionProps extends CommonPipelineDeployActionProps { - /** - * The Amazon S3 bucket that is the deploy target. - */ - readonly bucket: IBucket; -} - -/** - * Deploys the sourceArtifact to Amazon S3. - */ -export class PipelineDeployAction extends codepipeline.DeployAction { - private readonly bucket: IBucket; - - constructor(props: PipelineDeployActionProps) { - super({ - ...props, - provider: 'S3', - artifactBounds: { - minInputs: 1, - maxInputs: 1, - minOutputs: 0, - maxOutputs: 0, - }, - configuration: { - BucketName: props.bucket.bucketName, - Extract: (props.extract === false) ? 'false' : 'true', - ObjectKey: props.objectKey, - }, - }); - - this.bucket = props.bucket; - } - - protected bind(info: codepipeline.ActionBind): void { - // pipeline needs permissions to write to the S3 bucket - this.bucket.grantWrite(info.role); - } -} diff --git a/packages/@aws-cdk/aws-s3/package.json b/packages/@aws-cdk/aws-s3/package.json index e23cfe7afd9b6..45ab3f6043320 100644 --- a/packages/@aws-cdk/aws-s3/package.json +++ b/packages/@aws-cdk/aws-s3/package.json @@ -65,7 +65,6 @@ "pkglint": "^0.27.0" }, "dependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-kms": "^0.27.0", @@ -74,7 +73,6 @@ }, "homepage": "https://github.com/awslabs/aws-cdk", "peerDependencies": { - "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-events": "^0.27.0", "@aws-cdk/aws-iam": "^0.27.0", "@aws-cdk/aws-kms": "^0.27.0", @@ -93,4 +91,4 @@ "resource-interface:@aws-cdk/aws-s3.IBucketPolicy" ] } -} \ No newline at end of file +} diff --git a/packages/decdk/examples/pipeline.json b/packages/decdk/examples/pipeline.json index 02c348df3a56e..2d7dfce94d0c6 100644 --- a/packages/decdk/examples/pipeline.json +++ b/packages/decdk/examples/pipeline.json @@ -24,7 +24,7 @@ "name": "Source", "actions": [ { - "@aws-cdk/aws-codecommit.PipelineSourceAction": { + "@aws-cdk/aws-codepipeline-actions.CodeCommitSourceAction": { "repository": { "Ref": "Repo" }, "actionName": "Source" } @@ -35,11 +35,11 @@ "name": "Build", "actions": [ { - "@aws-cdk/aws-codebuild.PipelineBuildAction": { + "@aws-cdk/aws-codepipeline-actions.CodeBuildBuildAction": { "actionName": "Build", "project": { "Ref": "BuildProject" }, "inputArtifact": { - "@aws-cdk/aws-codepipeline-api.Artifact": { + "@aws-cdk/aws-codepipeline.Artifact": { "artifactName": "Source" } } @@ -51,4 +51,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/decdk/package.json b/packages/decdk/package.json index 579b65b588360..c3fbf21c7cfbb 100644 --- a/packages/decdk/package.json +++ b/packages/decdk/package.json @@ -52,6 +52,7 @@ "@aws-cdk/aws-codedeploy": "^0.27.0", "@aws-cdk/aws-codedeploy-api": "^0.27.0", "@aws-cdk/aws-codepipeline": "^0.27.0", + "@aws-cdk/aws-codepipeline-actions": "^0.27.0", "@aws-cdk/aws-codepipeline-api": "^0.27.0", "@aws-cdk/aws-cognito": "^0.27.0", "@aws-cdk/aws-config": "^0.27.0", @@ -145,4 +146,4 @@ "engines": { "node": ">= 8.10.0" } -} \ No newline at end of file +}