diff --git a/CHANGELOG.md b/CHANGELOG.md index 5561f5b1f22c7..9dc5f0a0dc8e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -460,13 +460,13 @@ const sourceStage = new Stage(pipeline, 'source'); const buildStage = new Stage(pipeline, 'build'); // associate the source stage with the code commit repository -const source = new CodeCommitSource(sourceStage, 'source', { +const source = new codecommit.PipelineSource(sourceStage, 'source', { artifactName: 'SourceArtifact', repository: repo, }); // associate the build stage with code build project -new CodeBuildAction(buildStage, 'build', { +new codebuild.PipelineBuildAction(buildStage, 'build', { project: new BuildProject(stack, 'MyBuildProject', { source: new CodePipelineSource() }, source }); diff --git a/packages/@aws-cdk/codebuild/lib/index.ts b/packages/@aws-cdk/codebuild/lib/index.ts index 55df0a8ad66cd..6e18f038bae33 100644 --- a/packages/@aws-cdk/codebuild/lib/index.ts +++ b/packages/@aws-cdk/codebuild/lib/index.ts @@ -1,3 +1,4 @@ +export * from './pipeline-actions'; export * from './project'; export * from './source'; export * from './artifacts'; diff --git a/packages/@aws-cdk/codebuild/lib/pipeline-actions.ts b/packages/@aws-cdk/codebuild/lib/pipeline-actions.ts new file mode 100644 index 0000000000000..947b5901b3d56 --- /dev/null +++ b/packages/@aws-cdk/codebuild/lib/pipeline-actions.ts @@ -0,0 +1,59 @@ +import { Artifact, BuildAction, Stage } from '@aws-cdk/codepipeline'; +import { PolicyStatement } from '@aws-cdk/core'; +import { BuildProjectRef } from './project'; + +/** + * Construction properties of the {@link PipelineBuildAction CodeBuild build CodePipeline Action}. + */ +export interface PipelineBuildActionProps { + /** + * The source to use as input for this build + */ + inputArtifact: Artifact; + + /** + * The name of the build's output artifact + */ + artifactName?: string; + + /** + * The build project + */ + project: BuildProjectRef; +} + +/** + * CodePipeline build Action that uses AWS CodeBuild. + */ +export class PipelineBuildAction extends BuildAction { + constructor(parent: Stage, name: string, props: PipelineBuildActionProps) { + // This happened when ProjectName was accidentally set to the project's ARN: + // https://qiita.com/ikeisuke/items/2fbc0b80b9bbd981b41f + + super(parent, name, { + provider: 'CodeBuild', + inputArtifact: props.inputArtifact, + artifactName: props.artifactName, + configuration: { + ProjectName: props.project.projectName + } + }); + + const actions = [ + 'codebuild:BatchGetBuilds', + 'codebuild:StartBuild', + 'codebuild:StopBuild', + ]; + + parent.pipeline.addToRolePolicy(new PolicyStatement() + .addResource(props.project.projectArn) + .addActions(...actions)); + + // allow codebuild to read and write artifacts to the pipline's artifact bucket. + parent.pipeline.artifactBucket.grantReadWrite(props.project.role); + + // policy must be added as a dependency to the pipeline!! + // TODO: grants - build.addResourcePermission() and also make sure permission + // includes the pipeline role AWS principal. + } +} diff --git a/packages/@aws-cdk/codebuild/package.json b/packages/@aws-cdk/codebuild/package.json index 905141bfbd92b..21ccf7a51ddee 100644 --- a/packages/@aws-cdk/codebuild/package.json +++ b/packages/@aws-cdk/codebuild/package.json @@ -43,6 +43,7 @@ }, "dependencies": { "@aws-cdk/codecommit": "^0.7.3-beta", + "@aws-cdk/codepipeline": "^0.7.3-beta", "@aws-cdk/core": "^0.7.3-beta", "@aws-cdk/events": "^0.7.3-beta", "@aws-cdk/iam": "^0.7.3-beta", diff --git a/packages/@aws-cdk/codepipeline/test/integ.pipeline-code-commit.expected.json b/packages/@aws-cdk/codebuild/test/integ.pipeline-code-commit-build.expected.json similarity index 100% rename from packages/@aws-cdk/codepipeline/test/integ.pipeline-code-commit.expected.json rename to packages/@aws-cdk/codebuild/test/integ.pipeline-code-commit-build.expected.json diff --git a/packages/@aws-cdk/codebuild/test/integ.pipeline-code-commit-build.ts b/packages/@aws-cdk/codebuild/test/integ.pipeline-code-commit-build.ts new file mode 100644 index 0000000000000..393cdc637e3ca --- /dev/null +++ b/packages/@aws-cdk/codebuild/test/integ.pipeline-code-commit-build.ts @@ -0,0 +1,30 @@ +import * as codecommit from '@aws-cdk/codecommit'; +import * as codepipeline from '@aws-cdk/codepipeline'; +import { App, Stack } from '@aws-cdk/core'; +import * as codebuild from '../lib'; + +const app = new App(process.argv); + +const stack = new Stack(app, 'aws-cdk-codepipeline-codecommit-codebuild'); + +const repo = new codecommit.Repository(stack, 'MyRepo', { repositoryName: 'my-repo' }); + +const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); + +const sourceStage = new codepipeline.Stage(pipeline, 'source'); +const source = new codecommit.PipelineSource(sourceStage, 'source', { + artifactName: 'SourceArtifact', + repository: repo, +}); + +const buildStage = new codepipeline.Stage(pipeline, 'build'); +const project = new codebuild.BuildProject(stack, 'MyBuildProject', { + source: new codebuild.CodePipelineSource(), +}); + +new codebuild.PipelineBuildAction(buildStage, 'build', { + project, + inputArtifact: source.artifact +}); + +process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/codepipeline/test/integ.pipeline-events.expected.json b/packages/@aws-cdk/codebuild/test/integ.pipeline-events.expected.json similarity index 100% rename from packages/@aws-cdk/codepipeline/test/integ.pipeline-events.expected.json rename to packages/@aws-cdk/codebuild/test/integ.pipeline-events.expected.json diff --git a/packages/@aws-cdk/codebuild/test/integ.pipeline-events.ts b/packages/@aws-cdk/codebuild/test/integ.pipeline-events.ts new file mode 100644 index 0000000000000..034e5a9344d4e --- /dev/null +++ b/packages/@aws-cdk/codebuild/test/integ.pipeline-events.ts @@ -0,0 +1,40 @@ +// Use pipeline as CloudWAtch event target + +import * as codecommit from '@aws-cdk/codecommit'; +import * as codepipeline from '@aws-cdk/codepipeline'; +import { App, Stack } from '@aws-cdk/core'; +import * as sns from '@aws-cdk/sns'; +import * as codebuild from '../lib'; + +const app = new App(process.argv); + +const stack = new Stack(app, 'aws-cdk-pipeline-event-target'); + +const pipeline = new codepipeline.Pipeline(stack, 'MyPipeline'); +const sourceStage = new codepipeline.Stage(pipeline, 'Source'); +const buildStage = new codepipeline.Stage(pipeline, 'Build'); + +const repository = new codecommit.Repository(stack, 'CodeCommitRepo', { repositoryName: 'foo' }); +const project = new codebuild.BuildProject(stack, 'BuildProject', { source: new codebuild.CodePipelineSource() }); + +const sourceAction = new codecommit.PipelineSource(sourceStage, 'CodeCommitSource', { artifactName: 'Source', repository }); +new codebuild.PipelineBuildAction(buildStage, 'CodeBuildAction', { inputArtifact: sourceAction.artifact, project }); + +const topic = new sns.Topic(stack, 'MyTopic'); +topic.subscribeEmail('benisrae', 'benisrae@amazon.com'); + +pipeline.onStateChange('OnPipelineStateChange').addTarget(topic, { + textTemplate: 'Pipeline changed state to ', + pathsMap: { + pipeline: '$.detail.pipeline', + state: '$.detail.state' + } +}); + +sourceStage.onStateChange('OnSourceStateChange', topic); + +sourceAction.onStateChange('OnActionStateChange', topic).addEventPattern({ + detail: { state: [ 'STARTED' ] } +}); + +process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/codepipeline/test/test.pipeline.ts b/packages/@aws-cdk/codebuild/test/test.pipeline.ts similarity index 93% rename from packages/@aws-cdk/codepipeline/test/test.pipeline.ts rename to packages/@aws-cdk/codebuild/test/test.pipeline.ts index b1b7a63cf8408..08d16f84df5b5 100644 --- a/packages/@aws-cdk/codepipeline/test/test.pipeline.ts +++ b/packages/@aws-cdk/codebuild/test/test.pipeline.ts @@ -1,11 +1,11 @@ import { expect, haveResource } from '@aws-cdk/assert'; -import { BuildProject, CodePipelineSource } from '@aws-cdk/codebuild'; -import { Repository } from '@aws-cdk/codecommit'; +import { PipelineSource, Repository } from '@aws-cdk/codecommit'; +import { AmazonS3Source, ApprovalAction, GitHubSource, Pipeline, Stage } from '@aws-cdk/codepipeline'; import { SecretParameter, Stack } from '@aws-cdk/core'; import { Bucket } from '@aws-cdk/s3'; import { Topic } from '@aws-cdk/sns'; import { Test } from 'nodeunit'; -import { AmazonS3Source, ApprovalAction, CodeBuildAction, CodeCommitSource, GitHubSource, Pipeline, Stage } from '../lib'; +import { BuildProject, CodePipelineSource, PipelineBuildAction } from '../lib'; // tslint:disable:object-literal-key-quotes @@ -18,7 +18,7 @@ export = { const pipeline = new Pipeline(stack, 'Pipeline'); const sourceStage = new Stage(pipeline, 'source'); - const source = new CodeCommitSource(sourceStage, 'source', { + const source = new PipelineSource(sourceStage, 'source', { artifactName: 'SourceArtifact', repository: repo, }); @@ -26,7 +26,7 @@ export = { const buildStage = new Stage(pipeline, 'build'); const project = new BuildProject(stack, 'MyBuildProject', { source: new CodePipelineSource() }); - new CodeBuildAction(buildStage, 'build', { + new PipelineBuildAction(buildStage, 'build', { project, inputArtifact: source.artifact }); diff --git a/packages/@aws-cdk/codecommit/lib/index.ts b/packages/@aws-cdk/codecommit/lib/index.ts index 2328b79377dc4..b4cf7bb2bf4b9 100644 --- a/packages/@aws-cdk/codecommit/lib/index.ts +++ b/packages/@aws-cdk/codecommit/lib/index.ts @@ -1,4 +1,5 @@ -export * from './codecommit'; +export * from './repository'; +export * from './pipeline-action'; // AWS::CodeCommit CloudFormation Resources: export * from './codecommit.generated'; diff --git a/packages/@aws-cdk/codecommit/lib/pipeline-action.ts b/packages/@aws-cdk/codecommit/lib/pipeline-action.ts new file mode 100644 index 0000000000000..7c86575661b6f --- /dev/null +++ b/packages/@aws-cdk/codecommit/lib/pipeline-action.ts @@ -0,0 +1,61 @@ +import { Source, Stage } from '@aws-cdk/codepipeline'; +import { PolicyStatement } from '@aws-cdk/core'; +import { RepositoryRef } from './repository'; + +/** + * Construction properties of the {@link PipelineSource CodeCommit source CodePipeline Action}. + */ +export interface PipelineSourceProps { + /** + * The name of the source's output artifact. Output artifacts are used by CodePipeline as + * inputs into other actions. + */ + artifactName: string; + + /** + * The CodeCommit repository. + */ + repository: RepositoryRef; + + /** + * @default 'master' + */ + branch?: string; + // TODO: use CloudWatch events instead + /** + * Whether or not AWS CodePipeline should poll for source changes + * + * @default true + */ + pollForSourceChanges?: boolean; +} + +/** + * CodePipeline Source that is provided by an AWS CodeCommit repository. + */ +export class PipelineSource extends Source { + constructor(parent: Stage, name: string, props: PipelineSourceProps) { + super(parent, name, { + provider: 'CodeCommit', + configuration: { + RepositoryName: props.repository.repositoryName, + BranchName: props.branch || 'master', + PollForSourceChanges: props.pollForSourceChanges || true + }, + artifactName: props.artifactName + }); + + // https://docs.aws.amazon.com/codecommit/latest/userguide/auth-and-access-control-permissions-reference.html#aa-acp + const actions = [ + 'codecommit:GetBranch', + 'codecommit:GetCommit', + 'codecommit:UploadArchive', + 'codecommit:GetUploadArchiveStatus', + 'codecommit:CancelUploadArchive', + ]; + + parent.pipeline.addToRolePolicy(new PolicyStatement() + .addResource(props.repository.repositoryArn) + .addActions(...actions)); + } +} diff --git a/packages/@aws-cdk/codecommit/lib/codecommit.ts b/packages/@aws-cdk/codecommit/lib/repository.ts similarity index 100% rename from packages/@aws-cdk/codecommit/lib/codecommit.ts rename to packages/@aws-cdk/codecommit/lib/repository.ts diff --git a/packages/@aws-cdk/codecommit/package.json b/packages/@aws-cdk/codecommit/package.json index a848638d8ccd2..e72db57c595b6 100644 --- a/packages/@aws-cdk/codecommit/package.json +++ b/packages/@aws-cdk/codecommit/package.json @@ -42,6 +42,7 @@ "pkglint": "^0.7.3-beta" }, "dependencies": { + "@aws-cdk/codepipeline": "^0.7.3-beta", "@aws-cdk/core": "^0.7.3-beta", "@aws-cdk/events": "^0.7.3-beta", "@aws-cdk/iam": "^0.7.3-beta" diff --git a/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.expected.json b/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.expected.json new file mode 100644 index 0000000000000..3c8affcb60d40 --- /dev/null +++ b/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.expected.json @@ -0,0 +1,169 @@ +{ + "Resources": { + "MyRepoF4F48043": { + "Type": "AWS::CodeCommit::Repository", + "Properties": { + "RepositoryName": "my-repo", + "Triggers": [] + } + }, + "PipelineArtifactsBucket22248F97": { + "Type": "AWS::S3::Bucket", + "DeletionPolicy": "Retain" + }, + "PipelineRoleD68726F7": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "codepipeline.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + } + } + }, + "PipelineRoleDefaultPolicyC7A05455": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:GetObject*", + "s3:GetBucket*", + "s3:List*", + "s3:PutObject*", + "s3:DeleteObject*", + "s3:Abort*" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::GetAtt": [ + "PipelineArtifactsBucket22248F97", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "PipelineArtifactsBucket22248F97", + "Arn" + ] + }, + "/", + "*" + ] + ] + } + ] + }, + { + "Action": [ + "codecommit:GetBranch", + "codecommit:GetCommit", + "codecommit:UploadArchive", + "codecommit:GetUploadArchiveStatus", + "codecommit:CancelUploadArchive" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "MyRepoF4F48043", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "PipelineRoleDefaultPolicyC7A05455", + "Roles": [ + { + "Ref": "PipelineRoleD68726F7" + } + ] + } + }, + "PipelineC660917D": { + "Type": "AWS::CodePipeline::Pipeline", + "Properties": { + "ArtifactStore": { + "Location": { + "Ref": "PipelineArtifactsBucket22248F97" + }, + "Type": "S3" + }, + "RoleArn": { + "Fn::GetAtt": [ + "PipelineRoleD68726F7", + "Arn" + ] + }, + "Stages": [ + { + "Actions": [ + { + "ActionTypeId": { + "Category": "Source", + "Owner": "AWS", + "Provider": "CodeCommit", + "Version": "1" + }, + "Configuration": { + "RepositoryName": { + "Fn::GetAtt": [ + "MyRepoF4F48043", + "Name" + ] + }, + "BranchName": "master", + "PollForSourceChanges": true + }, + "InputArtifacts": [], + "Name": "source", + "OutputArtifacts": [ + { + "Name": "SourceArtifact" + } + ], + "RunOrder": 1 + } + ], + "Name": "source" + }, + { + "Actions": [ + { + "ActionTypeId": { + "Category": "Approval", + "Owner": "AWS", + "Provider": "Manual", + "Version": "1" + }, + "InputArtifacts": [], + "Name": "manual", + "OutputArtifacts": [], + "RunOrder": 1 + } + ], + "Name": "build" + } + ] + }, + "DependsOn": [ + "PipelineRoleD68726F7", + "PipelineRoleDefaultPolicyC7A05455" + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.ts b/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.ts new file mode 100644 index 0000000000000..62ffebddb917e --- /dev/null +++ b/packages/@aws-cdk/codecommit/test/integ.pipeline-code-commit.ts @@ -0,0 +1,22 @@ +import * as codepipeline from '@aws-cdk/codepipeline'; +import { App, Stack } from '@aws-cdk/core'; +import * as codecommit from '../lib'; + +const app = new App(process.argv); + +const stack = new Stack(app, 'aws-cdk-codepipeline-codecommit'); + +const repo = new codecommit.Repository(stack, 'MyRepo', { repositoryName: 'my-repo' }); + +const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); + +const sourceStage = new codepipeline.Stage(pipeline, 'source'); +new codecommit.PipelineSource(sourceStage, 'source', { + artifactName: 'SourceArtifact', + repository: repo, +}); + +const buildStage = new codepipeline.Stage(pipeline, 'build'); +new codepipeline.ApprovalAction(buildStage, 'manual'); + +process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/codepipeline/README.md b/packages/@aws-cdk/codepipeline/README.md index 703f85e722fc0..c89bf4a6f6351 100644 --- a/packages/@aws-cdk/codepipeline/README.md +++ b/packages/@aws-cdk/codepipeline/README.md @@ -17,9 +17,11 @@ const sourceStage = new Stage(pipeline, 'Source'); Add an action to a stage: ```ts -new CodeCommitSource(sourceStage, 'source', { +new codecommit.PipelineSource(sourceStage, 'source', { artifactName: 'MyPackageSourceArtifact', - repository: 'MyPackage' + repository: codecommit.RepositoryRef.import(this, 'MyExistingRepository', { + repositoryName: new codecommit.RepositoryName('MyExistingRepository'), + }), }) ``` diff --git a/packages/@aws-cdk/codepipeline/lib/actions.ts b/packages/@aws-cdk/codepipeline/lib/actions.ts index 3381b4c939ad8..4c8dcff2eb5e7 100644 --- a/packages/@aws-cdk/codepipeline/lib/actions.ts +++ b/packages/@aws-cdk/codepipeline/lib/actions.ts @@ -1,5 +1,3 @@ -import { BuildProjectRef } from '@aws-cdk/codebuild'; -import { RepositoryRef } from '@aws-cdk/codecommit'; import { Construct, PolicyStatement, Secret } from '@aws-cdk/core'; import { EventRule, EventRuleProps, IEventRuleTarget } from '@aws-cdk/events'; import { LambdaRef } from '@aws-cdk/lambda'; @@ -91,8 +89,8 @@ export interface ActionProps { /** * Low level class for generically creating pipeline actions. - * It is recommended that concrete types are used instead, such as {@link CodeCommitSource} or - * {@link CodeBuildAction}. + * It is recommended that concrete types are used instead, such as {@link codecommit.PipelineSource} or + * {@link codebuild.PipelineBuildAction}. */ export abstract class Action extends Construct { /** @@ -247,7 +245,7 @@ export interface SourceProps { /** * Low level class for source actions. * It is recommended that concrete types are used instead, such as {@link AmazonS3Source} or - * {@link CodeCommitSource}. + * {@link codecommit.PipelineSource}. */ export abstract class Source extends Action { public readonly artifact: Artifact; @@ -315,65 +313,6 @@ export class AmazonS3Source extends Source { } } -/** - * Construction properties of the {@link CodeCommitSource CodeCommit source action} - */ -export interface CodeCommitSourceProps { - /** - * The name of the source's output artifact. Output artifacts are used by CodePipeline as - * inputs into other actions. - */ - artifactName: string; - - /** - * The CodeCommit repository. - */ - repository: RepositoryRef; - - /** - * @default 'master' - */ - branch?: string; - - // TODO: use CloudWatch events instead - /** - * Whether or not AWS CodePipeline should poll for source changes - * - * @default true - */ - pollForSourceChanges?: boolean; -} - -/** - * Source that is provided by an AWS CodeCommit repository - */ -export class CodeCommitSource extends Source { - constructor(parent: Stage, name: string, props: CodeCommitSourceProps) { - super(parent, name, { - provider: 'CodeCommit', - configuration: { - RepositoryName: props.repository.repositoryName, - BranchName: props.branch || 'master', - PollForSourceChanges: props.pollForSourceChanges || true - }, - artifactName: props.artifactName - }); - - // https://docs.aws.amazon.com/codecommit/latest/userguide/auth-and-access-control-permissions-reference.html#aa-acp - const actions = [ - 'codecommit:GetBranch', - 'codecommit:GetCommit', - 'codecommit:UploadArchive', - 'codecommit:GetUploadArchiveStatus', - 'codecommit:CancelUploadArchive', - ]; - - parent.pipeline.addToRolePolicy(new PolicyStatement() - .addResource(props.repository.repositoryArn) - .addActions(...actions)); - } -} - /** * Construction properties of the {@link GitHubSource GitHub source action} */ @@ -471,7 +410,7 @@ export interface BuildActionProps { /** * Low level class for build actions. - * It is recommended that concrete types are used instead, such as {@link CodeBuildAction}. + * It is recommended that concrete types are used instead, such as {@link codebuild.PipelineBuildAction}. */ export abstract class BuildAction extends Action { public readonly artifact?: Artifact; @@ -491,62 +430,6 @@ export abstract class BuildAction extends Action { } } -/** - * Construction properties of the {@link CodeBuildAction CodeBuild action} - */ -export interface CodeBuildActionProps { - /** - * The source to use as input for this build - */ - inputArtifact: Artifact; - - /** - * The name of the build's output artifact - */ - artifactName?: string; - - /** - * The build project - */ - project: BuildProjectRef; -} - -/** - * Build action that uses AWS CodeBuild - */ -export class CodeBuildAction extends BuildAction { - constructor(parent: Stage, name: string, props: CodeBuildActionProps) { - // This happened when ProjectName was accidentally set to the project's ARN: - // https://qiita.com/ikeisuke/items/2fbc0b80b9bbd981b41f - - super(parent, name, { - provider: 'CodeBuild', - inputArtifact: props.inputArtifact, - artifactName: props.artifactName, - configuration: { - ProjectName: props.project.projectName - } - }); - - const actions = [ - 'codebuild:BatchGetBuilds', - 'codebuild:StartBuild', - 'codebuild:StopBuild', - ]; - - parent.pipeline.addToRolePolicy(new PolicyStatement() - .addResource(props.project.projectArn) - .addActions(...actions)); - - // allow codebuild to read and write artifacts to the pipline's artifact bucket. - parent.pipeline.artifactBucket.grantReadWrite(props.project.role); - - // policy must be added as a dependency to the pipeline!! - // TODO: grants - build.addResourcePermission() and also make sure permission - // includes the pipeline role AWS principal. - } -} - /** * Manual approval action */ diff --git a/packages/@aws-cdk/codepipeline/lib/pipeline.ts b/packages/@aws-cdk/codepipeline/lib/pipeline.ts index ebea3cc9a2693..b0b75da6ea8e5 100644 --- a/packages/@aws-cdk/codepipeline/lib/pipeline.ts +++ b/packages/@aws-cdk/codepipeline/lib/pipeline.ts @@ -44,9 +44,9 @@ export interface PipelineProps { * const sourceStage = new Stage(pipeline, 'Source'); * * // add a source action to the stage - * new CodeCommitSource(sourceStage, 'Source', { + * new codecommit.PipelineSource(sourceStage, 'Source', { * artifactName: 'SourceArtifact', - * repository: repo + * repository: repo, * }); * * // ... add more stages diff --git a/packages/@aws-cdk/codepipeline/package.json b/packages/@aws-cdk/codepipeline/package.json index e02b79911bcfc..4d431053fcb19 100644 --- a/packages/@aws-cdk/codepipeline/package.json +++ b/packages/@aws-cdk/codepipeline/package.json @@ -42,8 +42,6 @@ "pkglint": "^0.7.3-beta" }, "dependencies": { - "@aws-cdk/codebuild": "^0.7.3-beta", - "@aws-cdk/codecommit": "^0.7.3-beta", "@aws-cdk/core": "^0.7.3-beta", "@aws-cdk/events": "^0.7.3-beta", "@aws-cdk/iam": "^0.7.3-beta", diff --git a/packages/@aws-cdk/codepipeline/test/integ.pipeline-code-commit.ts b/packages/@aws-cdk/codepipeline/test/integ.pipeline-code-commit.ts deleted file mode 100644 index bd6f559e3a0f3..0000000000000 --- a/packages/@aws-cdk/codepipeline/test/integ.pipeline-code-commit.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { BuildProject, CodePipelineSource } from '@aws-cdk/codebuild'; -import { Repository } from '@aws-cdk/codecommit'; -import { App, Stack } from '@aws-cdk/core'; -import { CodeBuildAction, CodeCommitSource, Pipeline, Stage } from '../lib'; -const app = new App(process.argv); - -const stack = new Stack(app, 'aws-cdk-codepipeline-codecommit'); - -const repo = new Repository(stack, 'MyRepo', { repositoryName: 'my-repo' }); - -const pipeline = new Pipeline(stack, 'Pipeline'); - -const sourceStage = new Stage(pipeline, 'source'); -const source = new CodeCommitSource(sourceStage, 'source', { - artifactName: 'SourceArtifact', - repository: repo, -}); - -const buildStage = new Stage(pipeline, 'build'); -const project = new BuildProject(stack, 'MyBuildProject', { - source: new CodePipelineSource(), -}); - -new CodeBuildAction(buildStage, 'build', { - project, - inputArtifact: source.artifact -}); - -process.stdout.write(app.run()); diff --git a/packages/@aws-cdk/codepipeline/test/integ.pipeline-events.ts b/packages/@aws-cdk/codepipeline/test/integ.pipeline-events.ts deleted file mode 100644 index c4256822d7abb..0000000000000 --- a/packages/@aws-cdk/codepipeline/test/integ.pipeline-events.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Use pipeline as CloudWAtch event target - -import { BuildProject, CodePipelineSource } from '@aws-cdk/codebuild'; -import { Repository } from '@aws-cdk/codecommit'; -import { App, Stack } from '@aws-cdk/core'; -import { Topic } from '@aws-cdk/sns'; -import { CodeBuildAction, CodeCommitSource, Pipeline, Stage } from '../lib'; - -const app = new App(process.argv); - -const stack = new Stack(app, 'aws-cdk-pipeline-event-target'); - -const pipeline = new Pipeline(stack, 'MyPipeline'); -const sourceStage = new Stage(pipeline, 'Source'); -const buildStage = new Stage(pipeline, 'Build'); - -const repository = new Repository(stack, 'CodeCommitRepo', { repositoryName: 'foo' }); -const project = new BuildProject(stack, 'BuildProject', { source: new CodePipelineSource() }); - -const sourceAction = new CodeCommitSource(sourceStage, 'CodeCommitSource', { artifactName: 'Source', repository }); -new CodeBuildAction(buildStage, 'CodeBuildAction', { inputArtifact: sourceAction.artifact, project }); - -const topic = new Topic(stack, 'MyTopic'); -topic.subscribeEmail('benisrae', 'benisrae@amazon.com'); - -pipeline.onStateChange('OnPipelineStateChange').addTarget(topic, { - textTemplate: 'Pipeline changed state to ', - pathsMap: { - pipeline: '$.detail.pipeline', - state: '$.detail.state' - } -}); - -sourceStage.onStateChange('OnSourceStateChange', topic); - -sourceAction.onStateChange('OnActionStateChange', topic).addEventPattern({ - detail: { state: [ 'STARTED' ] } -}); - -process.stdout.write(app.run());