By using AWS re:Post, you agree to the Terms of Use

How to Use CodeBuild and CodeDeploy to Deploy Lambda to Different Environments

0

Hi, I have a very simple C# Lambda that I will execute from a schedule. I want to use CodeBuild and CodeDeploy to be able to deploy new versions of this to either my staging or production environments. At the moment, my CodeBuild project build does the following:

  • Builds the Lambda c# project
  • Pushes the code to the Lambda $latest version
  • Creates a new Lambda version
  • Updates (string replacement) my Lambda deployment appspec.yml file to have the correct 'currentversion' and 'targetversion' based on what the current versions are.
  • uploads the appspec to an S3 bucket so that I can use it later in CodeDeploy.

My CodeDeploy just takes the appspec.yml file and executes it which then changes the $latest version of the Lambda to the new version.

Thats all good (I think) except that my CodeBuild doesn't know where I want to deploy the change to (staging or production) so should I be uploading 2 sets of code (one targeting a 'stage' Lambda alias and the other targeting a 'production' Lambda alias)? Or should there be a separate CodeBuild project for each environment? Or should I be having a completely separate Lambda (instead of using aliases) where one is for staging and the other for production? I feel like I am doing something horribly wrong here :)

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions