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

1

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 :)

已提問 2 年前檢視次數 158 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南