Skip to content

Commit 69c5dde

Browse files
authored
feat: implement node runtime region awareness for cdk vended custom resources (#30108)
### Reason for this change This PR introduces node runtime region awareness into the custom resource provider framework by doing the following: - Adding a `LATEST_NODE_RUNTIME_MAP` fact table used to maintain the latest node runtime available per AWS partition - Introducing `determineLatestNodeRuntime` and `determineLatestNodeRuntimeName` functions which determine the latest Lambda node `Runtime` and the latest Lambda node `Runtime` name, respectively - Updating the custom resource provider framework to utilize these two functions when code generating the runtime property for providers using node runtimes ### Description of changes This PR can be segmented into the following code changes: - A `LATEST_NODE_RUNTIME_MAP` fact table was added which maintains the latest Lambda node runtime available per AWS partition. - Introduced `determineLatestNodeRuntime` and `determineLatestNodeRuntimeName` functions which determine the latest Lambda node `Runtime` and the latest Lambda node `Runtime` name, respectively. - The existing runtime property being code generated via the custom resource provider framework has been altered to now use the appropriate runtime determiner function, i.e., `determineLatestNodeRuntimeName` for `CustomResourceProvider` or `determineLatestNodeRuntime` for `Function` or `SingletonFunction`. Any custom resource provider using a python runtime will not use either of these functions. - To consolidate and manage importing of external modules a `ModuleImporter` class has been created. This class allows external modules to be registered as an import for a target module and prevents duplicate imports for modules that contain multiple framework components. This class also provides the ability to specify different import paths which allows all external modules to be consolidated into a single class rather than having duplicate external modules defined for different import paths. Lastly, this class determines whether or not external modules should be imported selectively or if all targets in the external module should be imported under an alias, i.e., `import { Function } from 'aws-lambda'` vs. `import * as lambda from 'aws-lambda'` - A `CallableExpr` class was created to allow expression proxies to be created from a specified expression name. This allows the new runtime determiner functions and other module specific functions to be called from their specified module and built into a JavaScript object that will mirror the JavaScript operations done to it in an expression tree. ### Description of how you validated changes Manually tested all individual custom resource handlers for create, update, and delete. I verified that the behavior seen was what was expected based off of the handler code. All impacted integ tests were updated. New unit tests were added to the custom resource handler framework to test that generated code correctly included `determineLatestNodeRuntime` for Lambda based handlers and `determineLatestNodeRuntimeName` for `CfnResource` based handlers. Added new unit tests to test the functionality of `determineLatestNodeRuntime` and `determineLatestNodeRuntimeName` for region agnostic stacks, stacks in commercial region, stacks in China regions, stacks in ADC regions, and stacks in GovCloud regions. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 634d67d commit 69c5dde

File tree

1,554 files changed

+506106
-530559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,554 files changed

+506106
-530559
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/apigatewayaccesslogsfirehoseDefaultTestDeployAssert6376A91B.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/asset.2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3/index.js

-1
This file was deleted.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d/index.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/manifest.json

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/test-apigateway-access-logs-firehose.assets.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/test-apigateway-access-logs-firehose.template.json

+119-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"S3Bucket": {
114114
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
115115
},
116-
"S3Key": "2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3.zip"
116+
"S3Key": "96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d.zip"
117117
},
118118
"Timeout": 900,
119119
"MemorySize": 128,
@@ -124,7 +124,15 @@
124124
"Arn"
125125
]
126126
},
127-
"Runtime": "nodejs18.x",
127+
"Runtime": {
128+
"Fn::FindInMap": [
129+
"LatestNodeRuntimeMap",
130+
{
131+
"Ref": "AWS::Region"
132+
},
133+
"value"
134+
]
135+
},
128136
"Description": {
129137
"Fn::Join": [
130138
"",
@@ -290,6 +298,115 @@
290298
}
291299
}
292300
},
301+
"Mappings": {
302+
"LatestNodeRuntimeMap": {
303+
"af-south-1": {
304+
"value": "nodejs20.x"
305+
},
306+
"ap-east-1": {
307+
"value": "nodejs20.x"
308+
},
309+
"ap-northeast-1": {
310+
"value": "nodejs20.x"
311+
},
312+
"ap-northeast-2": {
313+
"value": "nodejs20.x"
314+
},
315+
"ap-northeast-3": {
316+
"value": "nodejs20.x"
317+
},
318+
"ap-south-1": {
319+
"value": "nodejs20.x"
320+
},
321+
"ap-south-2": {
322+
"value": "nodejs20.x"
323+
},
324+
"ap-southeast-1": {
325+
"value": "nodejs20.x"
326+
},
327+
"ap-southeast-2": {
328+
"value": "nodejs20.x"
329+
},
330+
"ap-southeast-3": {
331+
"value": "nodejs20.x"
332+
},
333+
"ap-southeast-4": {
334+
"value": "nodejs20.x"
335+
},
336+
"ca-central-1": {
337+
"value": "nodejs20.x"
338+
},
339+
"cn-north-1": {
340+
"value": "nodejs18.x"
341+
},
342+
"cn-northwest-1": {
343+
"value": "nodejs18.x"
344+
},
345+
"eu-central-1": {
346+
"value": "nodejs20.x"
347+
},
348+
"eu-central-2": {
349+
"value": "nodejs20.x"
350+
},
351+
"eu-north-1": {
352+
"value": "nodejs20.x"
353+
},
354+
"eu-south-1": {
355+
"value": "nodejs20.x"
356+
},
357+
"eu-south-2": {
358+
"value": "nodejs20.x"
359+
},
360+
"eu-west-1": {
361+
"value": "nodejs20.x"
362+
},
363+
"eu-west-2": {
364+
"value": "nodejs20.x"
365+
},
366+
"eu-west-3": {
367+
"value": "nodejs20.x"
368+
},
369+
"il-central-1": {
370+
"value": "nodejs20.x"
371+
},
372+
"me-central-1": {
373+
"value": "nodejs20.x"
374+
},
375+
"me-south-1": {
376+
"value": "nodejs20.x"
377+
},
378+
"sa-east-1": {
379+
"value": "nodejs20.x"
380+
},
381+
"us-east-1": {
382+
"value": "nodejs20.x"
383+
},
384+
"us-east-2": {
385+
"value": "nodejs20.x"
386+
},
387+
"us-gov-east-1": {
388+
"value": "nodejs18.x"
389+
},
390+
"us-gov-west-1": {
391+
"value": "nodejs18.x"
392+
},
393+
"us-iso-east-1": {
394+
"value": "nodejs18.x"
395+
},
396+
"us-iso-west-1": {
397+
"value": "nodejs18.x"
398+
},
399+
"us-isob-east-1": {
400+
"value": "nodejs18.x"
401+
},
402+
"us-west-1": {
403+
"value": "nodejs20.x"
404+
},
405+
"us-west-2": {
406+
"value": "nodejs20.x"
407+
}
408+
}
409+
},
293410
"Outputs": {
294411
"MyApiEndpoint869ABE96": {
295412
"Value": {

packages/@aws-cdk-testing/framework-integ/test/aws-apigateway/test/integ.restapi.access-log-firehose.js.snapshot/tree.json

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-appsync/test/integ.appsync-logmetrics.js.snapshot/AppSyncLogMetrics.assets.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)