Skip to content

Commit 27b7201

Browse files
chore: remove DEFAULT_CR_NODE_VERSION regional map (#26665)
Removes the map of regions -> available lambda nodejs runtime versions that previously was used for all custom resources vended in the aws-cdk. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6087424 commit 27b7201

File tree

10 files changed

+26
-81
lines changed

10 files changed

+26
-81
lines changed

allowed-breaking-changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ removed:aws-cdk-lib.aws_ecs.CfnTaskSet.LoadBalancerProperty.loadBalancerName
174174
# Previously only BlueGreenUpdatePolicy could be set, now BlueGreenUpdatePolicy or new RollingUpdatePolicy can be provided
175175
weakened:aws-cdk-lib.aws_sagemaker.CfnEndpoint.DeploymentConfigProperty
176176

177+
# Removed for being unused
178+
removed:@aws-cdk/region-info.FactName.DEFAULT_CR_NODE_VERSION
179+
removed:aws-cdk-lib.region_info.FactName.DEFAULT_CR_NODE_VERSION
180+
177181
# These should have been marked external
178182
weakened:aws-cdk-lib.aws_events.CfnRule.RedshiftDataParametersProperty
179183
weakened:aws-cdk-lib.aws_ivs.CfnRecordingConfiguration.DestinationConfigurationProperty

packages/aws-cdk-lib/aws-logs/lib/log-retention.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as iam from '../../aws-iam';
55
import * as s3_assets from '../../aws-s3-assets';
66
import * as cdk from '../../core';
77
import { ArnFormat } from '../../core';
8-
import { FactName } from '../../region-info';
98

109
/**
1110
* Construction properties for a LogRetention.
@@ -171,7 +170,7 @@ class LogRetentionFunction extends Construct implements cdk.ITaggable {
171170
type: 'AWS::Lambda::Function',
172171
properties: {
173172
Handler: 'index.handler',
174-
Runtime: cdk.Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x'), // Equivalent to Runtime.NODEJS_18_X
173+
Runtime: 'nodejs18.x',
175174
Code: {
176175
S3Bucket: asset.s3BucketName,
177176
S3Key: asset.s3ObjectKey,

packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as path from 'path';
22
import { Construct } from 'constructs';
33
import * as fs from 'fs-extra';
44
import * as cxapi from '../../../cx-api';
5-
import { FactName } from '../../../region-info';
65
import { AssetStaging } from '../asset-staging';
76
import { FileAssetPackaging } from '../assets';
87
import { CfnResource } from '../cfn-resource';
@@ -18,15 +17,6 @@ const ENTRYPOINT_FILENAME = '__entrypoint__';
1817
const ENTRYPOINT_NODEJS_SOURCE = path.join(__dirname, 'nodejs-entrypoint.js');
1918
export const INLINE_CUSTOM_RESOURCE_CONTEXT = '@aws-cdk/core:inlineCustomResourceIfPossible';
2019

21-
/**
22-
* The lambda runtime used by default for aws-cdk vended custom resources. Can change
23-
* based on region.
24-
*/
25-
export function builtInCustomResourceProviderNodeRuntime(scope: Construct): CustomResourceProviderRuntime {
26-
const runtimeName = Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x');
27-
return Object.values(CustomResourceProviderRuntime).find(value => value === runtimeName) ?? CustomResourceProviderRuntime.NODEJS_18_X;
28-
}
29-
3020
/**
3121
* Initialization properties for `CustomResourceProvider`.
3222
*

packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
33
import * as cxapi from '../../../cx-api';
4-
import { builtInCustomResourceProviderNodeRuntime, App, AssetStaging, CustomResourceProvider, CustomResourceProviderRuntime, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource } from '../../lib';
4+
import { App, AssetStaging, CustomResourceProvider, CustomResourceProviderRuntime, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource } from '../../lib';
55
import { CUSTOMIZE_ROLES_CONTEXT_KEY } from '../../lib/helpers-internal';
66
import { toCloudFormation } from '../util';
77

@@ -457,22 +457,5 @@ describe('custom resource provider', () => {
457457
});
458458

459459
});
460-
describe('builtInCustomResourceProviderNodeRuntime', () => {
461-
test('returns node18 for commercial region', () => {
462-
const app = new App();
463-
const stack = new Stack(app, 'MyStack', { env: { region: 'us-east-1' } });
464-
465-
const rt = builtInCustomResourceProviderNodeRuntime(stack);
466-
expect(rt).toEqual(CustomResourceProviderRuntime.NODEJS_18_X);
467-
});
468-
469-
test('returns node18 for iso region', () => {
470-
const app = new App();
471-
const stack = new Stack(app, 'MyStack', { env: { region: 'us-iso-east-1' } });
472-
473-
const rt = builtInCustomResourceProviderNodeRuntime(stack);
474-
expect(rt).toEqual(CustomResourceProviderRuntime.NODEJS_18_X);
475-
});
476-
});
477460
});
478461

packages/aws-cdk-lib/custom-resources/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,3 +648,22 @@ const getParameter = new cr.AwsCustomResource(this, 'AssociateVPCWithHostedZone'
648648
}),
649649
});
650650
```
651+
652+
#### Using AWS SDK for JavaScript v3
653+
654+
`AwsCustomResource` uses Node 18 and aws sdk v3 by default. You can specify the service as either the name of the sdk module, or just the service name, IE `@aws-sdk/client-ssm` or `SSM`, and the action as either the client method name or the sdk v3 command, `getParameter` or `GetParameterCommand`. It is recommended to use the v3 format for new AwsCustomResources going forward.
655+
656+
```ts
657+
new cr.AwsCustomResource(this, 'GetParameter', {
658+
resourceType: 'Custom::SSMParameter',
659+
onUpdate: {
660+
service: '@aws-sdk/client-ssm', // 'SSM' in v2
661+
action: 'GetParameterCommand', // 'getParameter' in v2
662+
parameters: {
663+
Name: 'foo',
664+
WithDecryption: true,
665+
},
666+
physicalResourceId: cr.PhysicalResourceId.fromResponse('Parameter.ARN'),
667+
},
668+
});
669+
```

packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@ import * as logs from '../../../aws-logs';
99
import * as cdk from '../../../core';
1010
import { Annotations } from '../../../core';
1111
import * as cxapi from '../../../cx-api';
12-
import { FactName } from '../../../region-info';
13-
14-
/**
15-
* The lambda runtime used by default for aws-cdk vended custom resources. Can change
16-
* based on region.
17-
*/
18-
export function builtInCustomResourceNodeRuntime(scope: Construct): lambda.Runtime {
19-
// Runtime regional fact should always return a known runtime string that lambda.Runtime
20-
// can index off, but for type safety we also default it here.
21-
const runtimeName = cdk.Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x');
22-
return runtimeName
23-
? new lambda.Runtime(runtimeName, lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true })
24-
: lambda.Runtime.NODEJS_18_X;
25-
}
2612

2713
/**
2814
* Reference to the physical resource id that can be passed to the AWS operation as a parameter.

packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Template } from '../../../assertions';
22
import * as ec2 from '../../../aws-ec2';
33
import * as iam from '../../../aws-iam';
4-
import * as lambda from '../../../aws-lambda';
54
import * as logs from '../../../aws-logs';
65
import * as cdk from '../../../core';
76
import { App, Stack } from '../../../core';
8-
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, PhysicalResourceIdReference, builtInCustomResourceNodeRuntime } from '../../lib';
7+
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, PhysicalResourceIdReference } from '../../lib';
98

109
/* eslint-disable quote-props */
1110

@@ -1280,22 +1279,3 @@ test('can specify removal policy', () => {
12801279
DeletionPolicy: 'Retain',
12811280
});
12821281
});
1283-
1284-
describe('builtInCustomResourceNodeRuntime', () => {
1285-
test('returns node18 for commercial region', () => {
1286-
const app = new App();
1287-
const stack = new Stack(app, 'MyStack', { env: { region: 'us-east-1' } });
1288-
1289-
const rt = builtInCustomResourceNodeRuntime(stack);
1290-
expect(rt).toEqual(lambda.Runtime.NODEJS_18_X);
1291-
});
1292-
1293-
test('returns node18 for iso region', () => {
1294-
const app = new App();
1295-
const stack = new Stack(app, 'MyStack', { env: { region: 'us-iso-east-1' } });
1296-
1297-
const rt = builtInCustomResourceNodeRuntime(stack);
1298-
expect(rt).toEqual(lambda.Runtime.NODEJS_18_X);
1299-
});
1300-
});
1301-

packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,6 @@ export const PARTITION_MAP: { [region: string]: Region } = {
122122
'us-isob-': { partition: Partition.UsIsoB, domainSuffix: 'sc2s.sgov.gov' },
123123
};
124124

125-
export const CR_DEFAULT_RUNTIME_MAP: Record<Partition, string> = {
126-
[Partition.Default]: 'nodejs18.x',
127-
[Partition.Cn]: 'nodejs18.x',
128-
[Partition.UsGov]: 'nodejs18.x',
129-
[Partition.UsIso]: 'nodejs18.x',
130-
[Partition.UsIsoB]: 'nodejs18.x',
131-
};
132-
133125
// https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions
134126
// https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy
135127
// Any not listed regions use the service principal "logdelivery.elasticloadbalancing.amazonaws.com"

packages/aws-cdk-lib/region-info/build-tools/generate-static-data.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
ROUTE_53_BUCKET_WEBSITE_ZONE_IDS,
1212
EBS_ENV_ENDPOINT_HOSTED_ZONE_IDS,
1313
ADOT_LAMBDA_LAYER_ARNS,
14-
CR_DEFAULT_RUNTIME_MAP,
1514
PARAMS_AND_SECRETS_LAMBDA_LAYER_ARNS,
1615
} from './fact-tables';
1716
import {
@@ -83,8 +82,6 @@ export async function main(): Promise<void> {
8382

8483
registerFact(region, 'APPMESH_ECR_ACCOUNT', APPMESH_ECR_ACCOUNTS[region]);
8584

86-
registerFact(region, 'DEFAULT_CR_NODE_VERSION', CR_DEFAULT_RUNTIME_MAP[partition]);
87-
8885
const firehoseCidrBlock = FIREHOSE_CIDR_BLOCKS[region];
8986
if (firehoseCidrBlock) {
9087
registerFact(region, 'FIREHOSE_CIDR_BLOCK', `${FIREHOSE_CIDR_BLOCKS[region]}/27`);

packages/aws-cdk-lib/region-info/lib/fact.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ export class FactName {
171171
*/
172172
public static readonly FIREHOSE_CIDR_BLOCK = 'firehoseCidrBlock';
173173

174-
/**
175-
* The default NodeJS version used for custom resource function runtimes
176-
*/
177-
public static readonly DEFAULT_CR_NODE_VERSION = 'defaultCrNodeVersion';
178-
179174
/**
180175
* The ARN of CloudWatch Lambda Insights for a version (e.g. 1.0.98.0)
181176
*/

0 commit comments

Comments
 (0)