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

Lambda Deployment - Do you have to set the TargetVersion?


So I have a CodeBuild project that uploads my latest code to the $latest Lambda version, then publishes a new Lambda version and then does a string replacement on the CodeDeploys appspec file to set the CurrentVersion and the TargetVersion. This works for basic stuff but if say there are 2 people working on the Lambda code and 2 CodeBuilds get kicked off, you will end up with 2 sets of appspec files e.g.

Appspec1: CurrentVersion: 1 TargetVersion: 2

Appspec2: CurrentVersion: 1 TargetVersion: 3

So when Appspec1 is deployed all goes well and the CurrentVersion becomes 2. But then when Appspec2 gets deployed, it will fail because the CurrentVersion is set to 1 instead of the now new version 2.

So how do people get around this? Do you have to set the versions or can CodeDeploy figure it out for itself somehow?