aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.92k forks source link

aws-codepipeline-actions: New action to deploy code to an existing Lambda Function #21795

Open owheatley35 opened 2 years ago

owheatley35 commented 2 years ago

Describe the feature

A LambdaCodeDeploymentAction. A new action for a deploy stage of CodePipelines that allows either a .zip file from an S3 bucket or an Artifact from CodeBuild to be deployed to a Lambda function.

Use Case

Its frustrating that my Lambda logic and my CDK have to be in the same repository so that when I update my Lambda it updates the code deployed to the Lambda function. The Infrastructure and the code that runs on the infrastructure should be separate. By doing this, I can use a source action to gather my lambda code from a separate repository to my CDK, build the code to create a .ZIP and then deploy that code to Lambda. All without having to update the CDK repository.

Proposed Solution

As described above, creating a LambdaCodeDeploymentAction Action to fulfil this deployment. A feature that is available through the console using the 'Upload from' button.

Other Information

No response

Acknowledgements

CDK version used

2.35.0

Environment details (OS name and version, etc.)

Mac OS Monterey 12.5.1

gshpychka commented 2 years ago

The Infrastructure and the code that runs on the infrastructure should be separate.

FYI the CDK best practices suggest the opposite:

The AWS CDK not only generates AWS CloudFormation templates for deploying infrastructure, it also bundles runtime assets like Lambda functions and Docker images and deploys them alongside your infrastructure. So it's not only possible to combine the code that defines your infrastructure and the code that implements your runtime logic into a single construct— it's a best practice. These two kinds of code don't need to live in separate repositories or even in separate packages.

A construct that is self-contained, in other words that completely describes a piece of functionality including its infrastructure and logic, makes it easy to evolve the two kinds of code together, test them in isolation, share and reuse the code across projects, and version all the code in sync.