diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index ea94f395165c9..2f4d77b2757bd 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -174,6 +174,10 @@ removed:aws-cdk-lib.aws_ecs.CfnTaskSet.LoadBalancerProperty.loadBalancerName # Previously only BlueGreenUpdatePolicy could be set, now BlueGreenUpdatePolicy or new RollingUpdatePolicy can be provided weakened:aws-cdk-lib.aws_sagemaker.CfnEndpoint.DeploymentConfigProperty +# Removed for being unused +removed:@aws-cdk/region-info.FactName.DEFAULT_CR_NODE_VERSION +removed:aws-cdk-lib.region_info.FactName.DEFAULT_CR_NODE_VERSION + # These should have been marked external weakened:aws-cdk-lib.aws_events.CfnRule.RedshiftDataParametersProperty weakened:aws-cdk-lib.aws_ivs.CfnRecordingConfiguration.DestinationConfigurationProperty diff --git a/packages/aws-cdk-lib/aws-logs/lib/log-retention.ts b/packages/aws-cdk-lib/aws-logs/lib/log-retention.ts index 1d591aa6bbf47..7d41cfa5a2e2a 100644 --- a/packages/aws-cdk-lib/aws-logs/lib/log-retention.ts +++ b/packages/aws-cdk-lib/aws-logs/lib/log-retention.ts @@ -5,7 +5,6 @@ import * as iam from '../../aws-iam'; import * as s3_assets from '../../aws-s3-assets'; import * as cdk from '../../core'; import { ArnFormat } from '../../core'; -import { FactName } from '../../region-info'; /** * Construction properties for a LogRetention. @@ -171,7 +170,7 @@ class LogRetentionFunction extends Construct implements cdk.ITaggable { type: 'AWS::Lambda::Function', properties: { Handler: 'index.handler', - Runtime: cdk.Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x'), // Equivalent to Runtime.NODEJS_18_X + Runtime: 'nodejs18.x', Code: { S3Bucket: asset.s3BucketName, S3Key: asset.s3ObjectKey, diff --git a/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts b/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts index cd1c4a94206a6..8825f49ab38be 100644 --- a/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts +++ b/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts @@ -2,7 +2,6 @@ import * as path from 'path'; import { Construct } from 'constructs'; import * as fs from 'fs-extra'; import * as cxapi from '../../../cx-api'; -import { FactName } from '../../../region-info'; import { AssetStaging } from '../asset-staging'; import { FileAssetPackaging } from '../assets'; import { CfnResource } from '../cfn-resource'; @@ -18,15 +17,6 @@ const ENTRYPOINT_FILENAME = '__entrypoint__'; const ENTRYPOINT_NODEJS_SOURCE = path.join(__dirname, 'nodejs-entrypoint.js'); export const INLINE_CUSTOM_RESOURCE_CONTEXT = '@aws-cdk/core:inlineCustomResourceIfPossible'; -/** - * The lambda runtime used by default for aws-cdk vended custom resources. Can change - * based on region. - */ -export function builtInCustomResourceProviderNodeRuntime(scope: Construct): CustomResourceProviderRuntime { - const runtimeName = Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x'); - return Object.values(CustomResourceProviderRuntime).find(value => value === runtimeName) ?? CustomResourceProviderRuntime.NODEJS_18_X; -} - /** * Initialization properties for `CustomResourceProvider`. * diff --git a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts index b5a3b16e4c6b4..803404a776154 100644 --- a/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts +++ b/packages/aws-cdk-lib/core/test/custom-resource-provider/custom-resource-provider.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as cxapi from '../../../cx-api'; -import { builtInCustomResourceProviderNodeRuntime, App, AssetStaging, CustomResourceProvider, CustomResourceProviderRuntime, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource } from '../../lib'; +import { App, AssetStaging, CustomResourceProvider, CustomResourceProviderRuntime, DockerImageAssetLocation, DockerImageAssetSource, Duration, FileAssetLocation, FileAssetSource, ISynthesisSession, Size, Stack, CfnResource } from '../../lib'; import { CUSTOMIZE_ROLES_CONTEXT_KEY } from '../../lib/helpers-internal'; import { toCloudFormation } from '../util'; @@ -457,22 +457,5 @@ describe('custom resource provider', () => { }); }); - describe('builtInCustomResourceProviderNodeRuntime', () => { - test('returns node18 for commercial region', () => { - const app = new App(); - const stack = new Stack(app, 'MyStack', { env: { region: 'us-east-1' } }); - - const rt = builtInCustomResourceProviderNodeRuntime(stack); - expect(rt).toEqual(CustomResourceProviderRuntime.NODEJS_18_X); - }); - - test('returns node18 for iso region', () => { - const app = new App(); - const stack = new Stack(app, 'MyStack', { env: { region: 'us-iso-east-1' } }); - - const rt = builtInCustomResourceProviderNodeRuntime(stack); - expect(rt).toEqual(CustomResourceProviderRuntime.NODEJS_18_X); - }); - }); }); diff --git a/packages/aws-cdk-lib/custom-resources/README.md b/packages/aws-cdk-lib/custom-resources/README.md index 7f6db76c67f1a..3322fc3e5cfbd 100644 --- a/packages/aws-cdk-lib/custom-resources/README.md +++ b/packages/aws-cdk-lib/custom-resources/README.md @@ -648,3 +648,22 @@ const getParameter = new cr.AwsCustomResource(this, 'AssociateVPCWithHostedZone' }), }); ``` + +#### Using AWS SDK for JavaScript v3 + +`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. + +```ts +new cr.AwsCustomResource(this, 'GetParameter', { + resourceType: 'Custom::SSMParameter', + onUpdate: { + service: '@aws-sdk/client-ssm', // 'SSM' in v2 + action: 'GetParameterCommand', // 'getParameter' in v2 + parameters: { + Name: 'foo', + WithDecryption: true, + }, + physicalResourceId: cr.PhysicalResourceId.fromResponse('Parameter.ARN'), + }, +}); +``` diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts index 7a50026fde4f7..e85f12b59d81e 100644 --- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts +++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts @@ -9,20 +9,6 @@ import * as logs from '../../../aws-logs'; import * as cdk from '../../../core'; import { Annotations } from '../../../core'; import * as cxapi from '../../../cx-api'; -import { FactName } from '../../../region-info'; - -/** - * The lambda runtime used by default for aws-cdk vended custom resources. Can change - * based on region. - */ -export function builtInCustomResourceNodeRuntime(scope: Construct): lambda.Runtime { - // Runtime regional fact should always return a known runtime string that lambda.Runtime - // can index off, but for type safety we also default it here. - const runtimeName = cdk.Stack.of(scope).regionalFact(FactName.DEFAULT_CR_NODE_VERSION, 'nodejs18.x'); - return runtimeName - ? new lambda.Runtime(runtimeName, lambda.RuntimeFamily.NODEJS, { supportsInlineCode: true }) - : lambda.Runtime.NODEJS_18_X; -} /** * Reference to the physical resource id that can be passed to the AWS operation as a parameter. diff --git a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts index 1b2ba2fe3e9b9..d81086f182b29 100644 --- a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts +++ b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts @@ -1,11 +1,10 @@ import { Template } from '../../../assertions'; import * as ec2 from '../../../aws-ec2'; import * as iam from '../../../aws-iam'; -import * as lambda from '../../../aws-lambda'; import * as logs from '../../../aws-logs'; import * as cdk from '../../../core'; import { App, Stack } from '../../../core'; -import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, PhysicalResourceIdReference, builtInCustomResourceNodeRuntime } from '../../lib'; +import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, PhysicalResourceIdReference } from '../../lib'; /* eslint-disable quote-props */ @@ -1280,22 +1279,3 @@ test('can specify removal policy', () => { DeletionPolicy: 'Retain', }); }); - -describe('builtInCustomResourceNodeRuntime', () => { - test('returns node18 for commercial region', () => { - const app = new App(); - const stack = new Stack(app, 'MyStack', { env: { region: 'us-east-1' } }); - - const rt = builtInCustomResourceNodeRuntime(stack); - expect(rt).toEqual(lambda.Runtime.NODEJS_18_X); - }); - - test('returns node18 for iso region', () => { - const app = new App(); - const stack = new Stack(app, 'MyStack', { env: { region: 'us-iso-east-1' } }); - - const rt = builtInCustomResourceNodeRuntime(stack); - expect(rt).toEqual(lambda.Runtime.NODEJS_18_X); - }); -}); - diff --git a/packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts b/packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts index df50bf86d7202..cd4d9f5ba0a99 100644 --- a/packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts +++ b/packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts @@ -122,14 +122,6 @@ export const PARTITION_MAP: { [region: string]: Region } = { 'us-isob-': { partition: Partition.UsIsoB, domainSuffix: 'sc2s.sgov.gov' }, }; -export const CR_DEFAULT_RUNTIME_MAP: Record = { - [Partition.Default]: 'nodejs18.x', - [Partition.Cn]: 'nodejs18.x', - [Partition.UsGov]: 'nodejs18.x', - [Partition.UsIso]: 'nodejs18.x', - [Partition.UsIsoB]: 'nodejs18.x', -}; - // https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions // https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-access-logs.html#attach-bucket-policy // Any not listed regions use the service principal "logdelivery.elasticloadbalancing.amazonaws.com" diff --git a/packages/aws-cdk-lib/region-info/build-tools/generate-static-data.ts b/packages/aws-cdk-lib/region-info/build-tools/generate-static-data.ts index 0313246c43a15..badafeb57b204 100644 --- a/packages/aws-cdk-lib/region-info/build-tools/generate-static-data.ts +++ b/packages/aws-cdk-lib/region-info/build-tools/generate-static-data.ts @@ -11,7 +11,6 @@ import { ROUTE_53_BUCKET_WEBSITE_ZONE_IDS, EBS_ENV_ENDPOINT_HOSTED_ZONE_IDS, ADOT_LAMBDA_LAYER_ARNS, - CR_DEFAULT_RUNTIME_MAP, PARAMS_AND_SECRETS_LAMBDA_LAYER_ARNS, } from './fact-tables'; import { @@ -83,8 +82,6 @@ export async function main(): Promise { registerFact(region, 'APPMESH_ECR_ACCOUNT', APPMESH_ECR_ACCOUNTS[region]); - registerFact(region, 'DEFAULT_CR_NODE_VERSION', CR_DEFAULT_RUNTIME_MAP[partition]); - const firehoseCidrBlock = FIREHOSE_CIDR_BLOCKS[region]; if (firehoseCidrBlock) { registerFact(region, 'FIREHOSE_CIDR_BLOCK', `${FIREHOSE_CIDR_BLOCKS[region]}/27`); diff --git a/packages/aws-cdk-lib/region-info/lib/fact.ts b/packages/aws-cdk-lib/region-info/lib/fact.ts index 7ccc6df1c84b5..728d66d345475 100644 --- a/packages/aws-cdk-lib/region-info/lib/fact.ts +++ b/packages/aws-cdk-lib/region-info/lib/fact.ts @@ -171,11 +171,6 @@ export class FactName { */ public static readonly FIREHOSE_CIDR_BLOCK = 'firehoseCidrBlock'; - /** - * The default NodeJS version used for custom resource function runtimes - */ - public static readonly DEFAULT_CR_NODE_VERSION = 'defaultCrNodeVersion'; - /** * The ARN of CloudWatch Lambda Insights for a version (e.g. 1.0.98.0) */