Skip to content

Commit

Permalink
feat: allow inclusion of image copy to pipeline
Browse files Browse the repository at this point in the history
Support both codepipeline and pipelines
  • Loading branch information
Hi-Fi committed Nov 9, 2024
1 parent 6a81327 commit d7c109e
Show file tree
Hide file tree
Showing 11 changed files with 4,286 additions and 1,334 deletions.
1 change: 1 addition & 0 deletions .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const project = new CdklabsConstructLibrary({
repositoryUrl: 'https://github.com/cdklabs/cdk-ecr-deployment', /* The repository is the location where the actual code for your package lives. */
gitignore: [
'cdk.out/',
'lambda/out',
], /* Additional entries to .gitignore. */
npmignore: [
'/cdk.out',
Expand Down
322 changes: 322 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/ecr-deployment-step.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { aws_lambda as lambda } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { addFunctionPermissions, getFunctionProps, LambdaInvokeStep } from './lambda';
import { ECRDeploymentStepProps } from './types';

export class ECRDeploymentStep extends Construct {

private handler: lambda.Function;

constructor(scope: Construct, id: string, props: ECRDeploymentStepProps) {
super(scope, id);

this.handler = new lambda.Function(this, 'ImageCopyHandler', {
...getFunctionProps(props),
environment: {
...props.environment,
INVOKER: 'CODEPIPELINE',
},
});

const handlerRole = this.handler.role;
if (!handlerRole) { throw new Error('lambda.Function should have created a Role'); }

addFunctionPermissions(handlerRole);

const factory = new LambdaInvokeStep(this.handler, props, 'ImageCopy');

props.stage?.addAction(factory.getAction());
props.wave?.addPost(factory);
}
}
Loading

0 comments on commit d7c109e

Please sign in to comment.