Skip to content

Commit

Permalink
fix: change Node 10 to 14 everywhere (#22289)
Browse files Browse the repository at this point in the history
This is a backport of #20595.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored Sep 30, 2022
1 parent f09c851 commit 8b0757e
Show file tree
Hide file tree
Showing 70 changed files with 410 additions and 407 deletions.
4 changes: 2 additions & 2 deletions INTEGRATION_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-lambda-1');
const fn = new lambda.Function(stack, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

app.synth();
Expand Down Expand Up @@ -214,7 +214,7 @@ touch any CloudFormation property, but instead change the way that code is bundl
a change to an integration test, you need to make sure that the integration tests and assertions are rerun.

An example of this would be making a change to the way `aws-lambda-nodejs` bundles Lambda code. A couple of things could go wrong that would
only be caught by rerunning the integration tests.
only be caught by rerunning the integration tests.

1. The bundling commands are only running when performing a real synth (not part of unit tests). Running the integration test confirms
that the actual bundling was not broken.
Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-apigateway/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ You can use Amazon API Gateway with AWS Step Functions as the backend integratio

The `StepFunctionsRestApi` only supports integration with Synchronous Express state machine. The `StepFunctionsRestApi` construct makes this easy by setting up input, output and error mapping.

The construct sets up an API endpoint and maps the `ANY` HTTP method and any calls to the API endpoint starts an express workflow execution for the underlying state machine.
The construct sets up an API endpoint and maps the `ANY` HTTP method and any calls to the API endpoint starts an express workflow execution for the underlying state machine.

Invoking the endpoint with any HTTP method (`GET`, `POST`, `PUT`, `DELETE`, ...) in the example below will send the request to the state machine as a new execution. On success, an HTTP code `200` is returned with the execution output as the Response Body.

If the execution fails, an HTTP `500` response is returned with the `error` and `cause` from the execution output as the Response Body. If the request is invalid (ex. bad execution input) HTTP code `400` is returned.

The response from the invocation contains only the `output` field from the
The response from the invocation contains only the `output` field from the
[StartSyncExecution](https://docs.aws.amazon.com/step-functions/latest/apireference/API_StartSyncExecution.html#API_StartSyncExecution_ResponseSyntax) API.
In case of failures, the fields `error` and `cause` are returned as part of the response.
Other metadata such as billing details, AWS account ID and resource ARNs are not returned in the API response.
Expand All @@ -139,7 +139,7 @@ const stateMachine: stepfunctions.IStateMachine = new stepfunctions.StateMachine
definition: stateMachineDefinition,
stateMachineType: stepfunctions.StateMachineType.EXPRESS,
});

new apigateway.StepFunctionsRestApi(this, 'StepFunctionsRestApi', {
deploy: true,
stateMachine: stateMachine,
Expand All @@ -157,7 +157,7 @@ AWS Step Functions will receive the request body in its input as follows:
```json
{
"body": {
"customerId": 1
"customerId": 1
},
"path": "/",
"querystring": {}
Expand Down Expand Up @@ -426,7 +426,7 @@ have to define your models and mappings for the request, response, and integrati

```ts
const hello = new lambda.Function(this, 'hello', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'hello.handler',
code: lambda.Code.fromAsset('lambda')
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('lambda authorizer', () => {
const func = new lambda.Function(stack, 'myfunction', {
handler: 'handler',
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

const auth = new TokenAuthorizer(stack, 'myauthorizer', {
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('lambda authorizer', () => {
const func = new lambda.Function(stack, 'myfunction', {
handler: 'handler',
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

const auth = new TokenAuthorizer(stack, 'myauthorizer', {
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('lambda authorizer', () => {
const func = new lambda.Function(stack, 'myfunction', {
handler: 'handler',
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

const role = new iam.Role(stack, 'authorizerassumerole', {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/cors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ describe('cors', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

// WHEN
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/test/deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ describe('deployment', () => {
const stack2 = new Stack();
const handler1 = new lambda.Function(stack1, 'handler1', {
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
});
const handler2 = new lambda.Function(stack2, 'handler2', {
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda')),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('lambda', () => {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
});
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('lambda', () => {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
});
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('lambda', () => {
// GIVEN
const stack = new cdk.Stack();
const fn = new lambda.Function(stack, 'Handler', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
});
Expand All @@ -162,7 +162,7 @@ describe('lambda', () => {
const api = new apigateway.RestApi(stack, 'test-api');

const handler = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromInline('loo'),
});
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('lambda', () => {
});

const handler = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromInline('loo'),
});
Expand All @@ -249,7 +249,7 @@ describe('lambda', () => {
const method = restapi.root.addMethod('ANY');
const handler = new lambda.Function(stack, 'MyFunc', {
functionName: 'ThisFunction',
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromInline('loo'),
});
Expand All @@ -269,7 +269,7 @@ describe('lambda', () => {
const restapi = new apigateway.RestApi(stack, 'RestApi');
const method = restapi.root.addMethod('ANY');
const handler = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromInline('loo'),
});
Expand Down
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-apigateway/test/lambda-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('lambda api', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

// WHEN
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('lambda api', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});
const alias = new lambda.Alias(stack, 'alias', {
aliasName: 'my-alias',
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('lambda api', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

// WHEN
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('lambda api', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

expect(() => new apigw.LambdaRestApi(stack, 'lambda-rest-api', {
Expand All @@ -196,7 +196,7 @@ describe('lambda api', () => {
const handler = new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

// WHEN
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('lambda api', () => {
handler: new lambda.Function(stack, 'handler', {
handler: 'index.handler',
code: lambda.Code.fromInline('boom'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
}),
restApiName: cdk.PhysicalName.GENERATE_IF_NEEDED,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/test/method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ describe('method', () => {
const func = new lambda.Function(stack, 'myfunction', {
handler: 'handler',
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
});

const auth = new apigw.TokenAuthorizer(stack, 'myauthorizer1', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('given an AutoScalingGroup and no role', () => {
// GIVEN
const fn = new lambda.Function(stack, 'Fn', {
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.index',
});

Expand Down Expand Up @@ -165,7 +165,7 @@ describe('given an AutoScalingGroup and no role', () => {
const key = new kms.Key(stack, 'key');
const fn = new lambda.Function(stack, 'Fn', {
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.index',
});

Expand Down Expand Up @@ -297,7 +297,7 @@ describe('given an AutoScalingGroup and a role', () => {
// GIVEN
const fn = new lambda.Function(stack, 'Fn', {
code: lambda.Code.fromInline('foo'),
runtime: lambda.Runtime.NODEJS_10_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.index',
});
const myrole = new iam.Role(stack, 'MyRole', {
Expand Down
22 changes: 11 additions & 11 deletions packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ your domain name, and provide one (or more) domain names from the certificate fo

The certificate must be present in the AWS Certificate Manager (ACM) service in the US East (N. Virginia) region; the certificate
may either be created by ACM, or created elsewhere and imported into ACM. When a certificate is used, the distribution will support HTTPS connections
from SNI only and a minimum protocol version of TLSv1.2_2021 if the `@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021` feature flag is set, and TLSv1.2_2019 otherwise.
from SNI only and a minimum protocol version of TLSv1.2_2021 if the `@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021` feature flag is set, and TLSv1.2_2019 otherwise.

```ts
// To use your own domain name in a Distribution, you must associate a certificate
Expand Down Expand Up @@ -361,7 +361,7 @@ on every request:
// A Lambda@Edge function added to default behavior of a Distribution
// and triggered on every request
const myFunc = new cloudfront.experimental.EdgeFunction(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand Down Expand Up @@ -392,7 +392,7 @@ If the stack is in `us-east-1`, a "normal" `lambda.Function` can be used instead
```ts
// Using a lambda Function instead of an EdgeFunction for stacks in `us-east-`.
const myFunc = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand All @@ -405,14 +405,14 @@ you can also set a specific stack ID for each Lambda@Edge.
// Setting stackIds for EdgeFunctions that can be referenced from different applications
// on the same account.
const myFunc1 = new cloudfront.experimental.EdgeFunction(this, 'MyFunction1', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler1')),
stackId: 'edge-lambda-stack-id-1',
});

const myFunc2 = new cloudfront.experimental.EdgeFunction(this, 'MyFunction2', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_14_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler2')),
stackId: 'edge-lambda-stack-id-2',
Expand Down Expand Up @@ -558,7 +558,7 @@ configuration properties have been changed:
| `loggingConfig` | `enableLogging`; configure with `logBucket` `logFilePrefix` and `logIncludesCookies` |
| `viewerProtocolPolicy` | removed; set on each behavior instead. default changed from `REDIRECT_TO_HTTPS` to `ALLOW_ALL` |

After switching constructs, you need to maintain the same logical ID for the underlying [CfnDistribution](https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-cloudfront.CfnDistribution.html) if you wish to avoid the deletion and recreation of your distribution.
After switching constructs, you need to maintain the same logical ID for the underlying [CfnDistribution](https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-cloudfront.CfnDistribution.html) if you wish to avoid the deletion and recreation of your distribution.
To do this, use [escape hatches](https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html) to override the logical ID created by the new Distribution construct with the logical ID created by the old construct.

Example:
Expand Down Expand Up @@ -714,7 +714,7 @@ new cloudfront.CloudFrontWebDistribution(this, 'MyCfWebDistribution', {
});
```

Becomes:
Becomes:

```ts
declare const sourceBucket: s3.Bucket;
Expand All @@ -733,8 +733,8 @@ cfnDistribution.addPropertyOverride('ViewerCertificate.SslSupportMethod', 'sni-o

### Other changes

A number of default settings have changed on the new API when creating a new distribution, behavior, and origin.
After making the major changes needed for the migration, run `cdk diff` to see what settings have changed.
A number of default settings have changed on the new API when creating a new distribution, behavior, and origin.
After making the major changes needed for the migration, run `cdk diff` to see what settings have changed.
If no changes are desired during migration, you will at the least be able to use [escape hatches](https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html) to override what the CDK synthesizes, if you can't change the properties directly.

## CloudFrontWebDistribution API
Expand Down Expand Up @@ -940,7 +940,7 @@ The following example command uses OpenSSL to generate an RSA key pair with a le
openssl genrsa -out private_key.pem 2048
```

The resulting file contains both the public and the private key. The following example command extracts the public key from the file named `private_key.pem` and stores it in `public_key.pem`.
The resulting file contains both the public and the private key. The following example command extracts the public key from the file named `private_key.pem` and stores it in `public_key.pem`.

```bash
openssl rsa -pubout -in private_key.pem -out public_key.pem
Expand All @@ -966,4 +966,4 @@ new cloudfront.KeyGroup(this, 'MyKeyGroup', {
See:

* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-trusted-signers.html
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-cloudfront/test/distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ describe('with Lambda@Edge functions', () => {

beforeEach(() => {
lambdaFunction = new lambda.Function(stack, 'Function', {
runtime: lambda.Runtime.NODEJS,
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline('whatever'),
handler: 'index.handler',
});
Expand Down Expand Up @@ -728,7 +728,7 @@ describe('with Lambda@Edge functions', () => {
EventType: 'origin-request',
IncludeBody: true,
LambdaFunctionARN: {
Ref: 'FunctionCurrentVersion4E2B2261477a5ae8059bbaa7813f752292c0f65e',
Ref: 'FunctionCurrentVersion4E2B2261c8c3cb9534b15b1bd7452e3a82ec90e1',
},
},
],
Expand Down Expand Up @@ -798,7 +798,7 @@ describe('with Lambda@Edge functions', () => {
{
EventType: 'viewer-request',
LambdaFunctionARN: {
Ref: 'FunctionCurrentVersion4E2B2261477a5ae8059bbaa7813f752292c0f65e',
Ref: 'FunctionCurrentVersion4E2B2261c8c3cb9534b15b1bd7452e3a82ec90e1',
},
},
],
Expand Down Expand Up @@ -826,7 +826,7 @@ describe('with Lambda@Edge functions', () => {

test('with removable env vars', () => {
const envLambdaFunction = new lambda.Function(stack, 'EnvFunction', {
runtime: lambda.Runtime.NODEJS,
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromInline('whateverwithenv'),
handler: 'index.handler',
});
Expand Down
Loading

0 comments on commit 8b0757e

Please sign in to comment.