Skip to content

Commit

Permalink
fix(core): custom resource provider NODEJS_12 now looks like Lambda's…
Browse files Browse the repository at this point in the history
… NODEJS_12_X, add Node 14 (#13301)

Purpose of this PR is to align `runtime` options for custom resource providers with `aws-lambda` runtime options.

New selections include `NODEJS_12_X` and `NODE_JS_14_X`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
robertd committed Mar 3, 2021
1 parent b965589 commit 3413b2f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestStack extends Stack {

const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: `${__dirname}/core-custom-resource-provider-fixture`,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
description: 'veni vidi vici',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class EdgeFunction extends Resource implements lambda.IVersion {
const resourceType = 'Custom::CrossRegionStringParameterReader';
const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: path.join(__dirname, 'edge-function'),
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [{
Effect: 'Allow',
Resource: parameterArnPrefix,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iam/lib/oidc-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class OpenIdConnectProvider extends Resource implements IOpenIdConnectPro
private getOrCreateProvider() {
return CustomResourceProvider.getOrCreate(this, RESOURCE_TYPE, {
codeDirectory: path.join(__dirname, 'oidc-provider'),
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [
{
Effect: 'Allow',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-route53/lib/record-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export class CrossAccountZoneDelegationRecord extends CoreConstruct {

const serviceToken = CustomResourceProvider.getOrCreate(this, CROSS_ACCOUNT_ZONE_DELEGATION_RESOURCE_TYPE, {
codeDirectory: path.join(__dirname, 'cross-account-zone-delegation-handler'),
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [{ Effect: 'Allow', Action: 'sts:AssumeRole', Resource: props.delegationRole.roleArn }],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestStack extends Stack {
// Put objects in the bucket to ensure auto delete works as expected
const serviceToken = CustomResourceProvider.getOrCreate(this, PUT_OBJECTS_RESOURCE_TYPE, {
codeDirectory: path.join(__dirname, 'put-objects-handler'),
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [{
Effect: 'Allow',
Action: 's3:PutObject',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SecretsManagerStack extends cdk.Stack {
const resourceType = 'Custom::IntegVerificationSecretNameMatches';
const serviceToken = cdk.CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: path.join(__dirname, 'integ.secret-name-parsed.handler'),
runtime: cdk.CustomResourceProviderRuntime.NODEJS_12,
runtime: cdk.CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [{
Effect: 'Allow',
Resource: secrets.map(s => s.secretArn),
Expand Down
6 changes: 3 additions & 3 deletions packages/@aws-cdk/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ stack-unique identifier and returns the service token:
```ts
const serviceToken = CustomResourceProvider.getOrCreate(this, 'Custom::MyCustomResourceType', {
codeDirectory: `${__dirname}/my-handler`,
runtime: CustomResourceProviderRuntime.NODEJS_12, // currently the only supported runtime
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
description: "Lambda function created by the custom resource provider",
});

Expand Down Expand Up @@ -522,7 +522,7 @@ export class Sum extends Construct {
const resourceType = 'Custom::Sum';
const serviceToken = CustomResourceProvider.getOrCreate(this, resourceType, {
codeDirectory: `${__dirname}/sum-handler`,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
});

const resource = new CustomResource(this, 'Resource', {
Expand Down Expand Up @@ -552,7 +552,7 @@ built-in singleton method:
```ts
const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', {
codeDirectory: `${__dirname}/my-handler`,
runtime: CustomResourceProviderRuntime.NODEJS_12, // currently the only supported runtime
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
});

const roleArn = provider.roleArn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,20 @@ export interface CustomResourceProviderProps {
export enum CustomResourceProviderRuntime {
/**
* Node.js 12.x
*
* @deprecated Use {@link NODEJS_12_X}
*/
NODEJS_12 = 'nodejs12.x',

/**
* Node.js 12.x
*/
NODEJS_12_X = 'nodejs12.x',

/**
* Node.js 14.x
*/
NODEJS_12 = 'nodejs12.x'
NODEJS_14_X = 'nodejs14.x',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/lib/private/cfn-utils-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CustomResourceProvider, CustomResourceProviderRuntime } from '../custom
export class CfnUtilsProvider extends Construct {
public static getOrCreate(scope: Construct) {
return CustomResourceProvider.getOrCreate(scope, 'AWSCDKCfnUtilsProvider', {
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
codeDirectory: `${__dirname}/cfn-utils-provider`,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nodeunitShim({
// WHEN
CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
});

// THEN
Expand Down Expand Up @@ -149,7 +149,7 @@ nodeunitShim({
// WHEN
CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
});

// THEN -- no exception
Expand All @@ -167,7 +167,7 @@ nodeunitShim({
// WHEN
CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
policyStatements: [
{ statement1: 123 },
{ statement2: { foo: 111 } },
Expand All @@ -194,7 +194,7 @@ nodeunitShim({
// WHEN
CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
memorySize: Size.gibibytes(2),
timeout: Duration.minutes(5),
description: 'veni vidi vici',
Expand All @@ -216,7 +216,7 @@ nodeunitShim({
// WHEN
CustomResourceProvider.getOrCreate(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
environment: {
B: 'b',
A: 'a',
Expand All @@ -242,7 +242,7 @@ nodeunitShim({
// WHEN
const cr = CustomResourceProvider.getOrCreateProvider(stack, 'Custom:MyResourceType', {
codeDirectory: TEST_HANDLER,
runtime: CustomResourceProviderRuntime.NODEJS_12,
runtime: CustomResourceProviderRuntime.NODEJS_12_X,
});

// THEN
Expand Down

0 comments on commit 3413b2f

Please sign in to comment.