AWS CodePipeline, CodeDeploy, SAM and Lambda: how to (inter)connect those?

Question:

I’m a kind of lost in the documentation.
I want to push Python code to a repo and use CodePipeline to deploy Lambdas.
I have CodeCommit repo, CodePipeline – so far this works and I can create/update CF stack to create supplementary resources.

I know AWS SAM can be used to deploy the functions using CF tpl, but how can I connect SAM with CodePipeline/CodeDeploy? The code should be taken from a ‘source’ pipeline action then deployed as lambda function.

If SAM isn’t the best automated solution here then what should I use instead? Pipeline is the key requirement so we don’t have to run something like aws cf update-stack manually, just push the code.

Answer:

CodePipeline doesn’t support deploying Lambda through CodeDeploy, so the approach is to use a CodeBuild Build action to generate an change set from the SAM template and feed it into a CloudFormation Deploy action. You can find a detailed instruction in the following doc.

https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html

Leave a Reply