1
votes

I am looking to develop a work flow as follows

  1. The developers commit their code to github
  2. As soon as the Master branch changes (merge), through web hooks, it triggers a AWS CodePipeline where Build happens as a second stage using CodeBuild
  3. Ideally the work flow exists already for CodeDeploy or ECS where the built artifact replaces the task definition in ECS and updates the service. But I am looking for a lambda deployment.

It means, the built artifact or the zip file that gets uploaded to S3 bucket by CodeBuild should trigger a lambda function and also the lambda function code should be updated from the artifacts of CodeBuild.

Now I know one of the triggers for Lambda is S3 but it only triggers a already defined lambda function to execute but not update the function and execute it.

From the console, I do not think there is a way to do this directly. As complicated as it sounds, I am hoping there is a way.

Any pointers in that direction would be great.

1

1 Answers

2
votes

I am using AWS CloudFormation to do my AWS Lambda deployment. In this case my AWS CodePipeline got 3 Stages (for simplicity):

  1. Stage "Source": GitHub
  2. Stage "Build": AWS CodeBuild
  3. Stage "Deploy": AWS CloudFormation

Inside the Build Stage i am doing the typical building procedure npm install, npm test, etc.

Important here: in the end of my build i am using aws cloudformation package which puts my code together, uploads it automatically to S3 and generates a final AWS CloudFormation template which i am then use in the 3. Stage "Deploy".