2

Could you please help me understand how to specify the nodejs runtime version of the lambda function that gets automatically created by aws when a new data bucket with parameter autoDeleteObjects: true is created?

I am using the following piece of code:

const autoDeleteBucketProps = { autoDeleteObjects: true, removalPolicy: >cdk.RemovalPolicy.DESTROY };

new Bucket(this, 'store', { ...bucketProps, ...autoDeleteBucketProps });

This code automatically creates a lambda function with runtime version Node.js 12.x for autodeleting objects. However due to the fact that Amazon requires that we upgrade our lambda runtimes (ending support of v12 as described in Lambda runtime support policy), I am trying to a find a way to upgrade the runtime of this automatically created lambda to version 14.

I am using aws-cdk v1.152.0 which supports '@aws-cdk/aws-lambda' Runtime version v14. So why this lambda gets created with runtime v12? And how can it can be changed to v14, programmatically?

Thank you in advance.

2 Answers2

3

I just updated one of our stacks from CDK 2.23.0 to 2.46.0 and the auto deletion lambda automatically updated to Node 14 runtime.

You said you were using CDK 1.152.0 and if for some reason you want to stick with V1, it should also update to the new runtime in 1.176.0, but I have not tested this myself. I was just reading the changelog notes of CDK.

Updating to CDK v2 was quite easy for us at least and I think v1 is nearing end-of-life so I suggest you move to v2 now or soon.

wldchld
  • 146
  • 3
  • thank you for the feedback. What you suggest makes sense. We were unsure whether upgrading the cdk would introduce compatibility issues with other libraries. – TechQuestion Nov 10 '22 at 15:11
1

I think you should be able to update the runtime in the console or remake the function when v12 is no longer used.

You can find more details on the lambda runtimes here

Faruk Ada
  • 79
  • 3
  • Dear Faruk, thank you for the prompt answer. Yes it can be done through the console, but is there a way to specify it programmatically using aws-cdk in javascript? Because it has to be changed everytime the lambda gets redeployed. Thank you. – TechQuestion Sep 07 '22 at 17:12
  • Hello Faruk, is there any official statement of AWS about updating the runtime of the s3 auto deletion functions or do you just assume, that this will be done? We are currently facing the same issue in our project, and as AWS is already sending warning notifications, prompting you to remove affected functions 14th of Nov we dont see any alternative then to remove this feature altogether as we would run into the same issue on every redeploy. If there would be an official statement functions will use the new runtime in the future, we could instead consider to leave everything as it is – Demli95 Sep 19 '22 at 10:54
  • @TechQuestion you can write a script using the SDK to do this programmatically and change the functions based on arn or something like that. – Faruk Ada Sep 20 '22 at 13:13
  • @Demli95 the link in the answer will take you to the offical AWS docu and it states that even though the runtime will not be supported, your function will still work indefenitly, BUT you get no security updates – Faruk Ada Sep 20 '22 at 13:13
  • @FarukAda, & Demli95, thank you for sharing your viewpoints, very insightful and you are both right, I did not know! We could either use the SDK in a script, or contact AWS Support to clarify whether it is their responsibility to upgrade the runtimes for autogenerated lambdas. If anyone has purchased a support plan and can contact AWS Support, please share your findings, it will help a lot. Many thanks again! – TechQuestion Sep 21 '22 at 07:47