How do I manage Lambda versions with CDK?

0

I have an infrastructure with multiple accounts (prod, dev, staging) using CDK. Recently, one of my functions underwent a major change. Therefore, I need to publish the new version without deleting the old one, but I couldn't find a reliable resource on how to do this. My requests should look like this:

  • example.com/v1/users
  • example.com/v2/users

The points where I'm confused are as follows:

Let's say I created a new version in my dev account (v2). Later, I created another version (v3) without deploying it to my prod account. In this case, v2 and v3 would be the same. Since I haven't deployed to my prod account yet, it will take the latest code for the v2 version. Is duplicating the code a good idea to manage this situation? For example:

  • lambda/users/v1
  • lambda/users/v2
  • lambda/users/v3

Should I have different versions of the code like this?

1개 답변
0

I don't think you need to duplicate the Lambda source code; just create a second CDK resource referencing the same code.

You can also use the version construct to explicitly define function versions and then deploy those, using your own environment management logic as appropriate: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Version.html

profile pictureAWS
답변함 6달 전
profile pictureAWS
전문가
검토됨 6달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠