Skip to content

Commit

Permalink
fix(lambda): update default runtimes and tests to node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Aug 29, 2023
1 parent 4fd510e commit c8799ed
Show file tree
Hide file tree
Showing 149 changed files with 517 additions and 534 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const app = new App();
const stack = new Stack(app, 'RequestAuthorizerInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.request-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const app = new App();
const stack = new Stack(app, 'TokenAuthorizerIAMRoleInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const app = new App();
const stack = new Stack(app, 'TokenAuthorizerInteg');

const authorizerFn = new lambda.Function(stack, 'MyAuthorizerFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.AssetCode.fromAsset(path.join(__dirname, 'integ.token-authorizer.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TestStack extends Stack {
});

const handler = new lambda.Function(this, 'handler', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'integ.cors.handler')),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LambdaApiIntegrationOptionsNonProxyIntegrationStack extends Stack {

const fn = new Function(this, 'myfn', {
code: Code.fromInline('foo'),
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
handler: 'index.handler',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LateBoundDeploymentStageStack extends Stack {

const fn = new Function(this, 'myfn', {
code: Code.fromInline('foo'),
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
handler: 'index.handler',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new 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_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

const apigw = new RestApi(stack, 'MyRestApi', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ class BookStack extends cdk.Stack {
super(scope, id);

const booksHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BooksHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${echoHandlerCode}`),
}));

const bookHandler = new apigw.LambdaIntegration(new lambda.Function(this, 'BookHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${echoHandlerCode}`),
}));

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${helloCode}`),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FirstStack extends cdk.Stack {
}
}`),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MultiStack extends cdk.Stack {
super(scope, id);

const hello = new apigw.LambdaIntegration(new lambda.Function(this, 'Hello', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${helloCode}`),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
code: lambda.Code.fromInline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Test extends cdk.Stack {
});

const handler = new lambda.Function(this, 'MyHandler', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
code: lambda.Code.fromInline(`exports.handler = ${handlerCode}`),
handler: 'index.handler',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const api = new appsync.GraphqlApi(stack, 'LambdaAPI', {
const func = new lambda.Function(stack, 'func', {
code: lambda.Code.fromAsset(path.join(__dirname, 'verify/lambda-tutorial')),
handler: 'lambda-tutorial.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

const lambdaDS = api.addLambdaDataSource('LambdaDS', func);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ api.grantMutation(lambdaIAM, 'addTest');
new Function(stack, 'testQuery', {
code: Code.fromAsset(join(__dirname, 'verify/iam-query')),
handler: 'iam-query.handler',
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
environment: { APPSYNC_ENDPOINT: api.graphqlUrl },
role: lambdaIAM,
});
new Function(stack, 'testFail', {
code: Code.fromAsset(join(__dirname, 'verify/iam-query')),
handler: 'iam-query.handler',
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
environment: { APPSYNC_ENDPOINT: api.graphqlUrl },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GraphQLApiLambdaAuthStack extends cdk.Stack {
path.join(__dirname, 'verify/lambda-tutorial'),
),
handler: 'lambda-tutorial.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

new appsync.GraphqlApi(this, 'api1', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestStack extends Stack {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestStack extends Stack {
new lambda.Function(this, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
logRetention: RetentionDays.ONE_DAY,
});
const logRetentionFunction = this.node.tryFindChild('LogRetentionaae0aa3c5b4d4f87b02d85b201efdd8a')!;
Expand All @@ -47,12 +47,12 @@ class TestNestedStack extends Stack {
const resource1 = new lambda.Function(stack1, 'Lambda1', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
}).node.defaultChild! as CfnResource;
const resource2 = new lambda.Function(stack2, 'Lambda2', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
}).node.defaultChild! as CfnResource;

// The following two statements should cancel each other out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MyNestedStack extends NestedStack {

if (props.subscriber) {
new lambda.Function(this, 'fn', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
code: lambda.Code.fromInline('console.error("hi")'),
handler: 'index.handler',
environment: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MyNestedStack extends NestedStack {

new lambda.Function(this, 'Handler', {
code: lambda.Code.fromAsset(path.join(__dirname, 'asset-directory-fixture')),
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const sourceBucket = new s3.Bucket(stack, 'Bucket', {
const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

const lambdaVersion = new lambda.Version(stack, 'LambdaVersion', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const stack = new cdk.Stack(app, 'integ-distribution-lambda-cross-region', { env
const lambdaFunction = new cloudfront.experimental.EdgeFunction(stack, 'Lambda', {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

const lambdaFunction2 = new cloudfront.experimental.EdgeFunction(stack, 'Lambda2', {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
stackId: `edge-lambda-stack-${region}-2`,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const stack = new cdk.Stack(app, 'integ-distribution-lambda', { env: { region: '
const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: lambda.Code.fromInline('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

new cloudfront.Distribution(stack, 'Dist', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bucket = new s3.Bucket(stack, 'Bucket', {
autoDeleteObjects: true,
});
const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'hello.handler',
code: lambda.Code.fromInline('exports.handler = {}'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const bucket = new s3.Bucket(stack, 'Bucket', {
});
const topic = new sns.Topic(stack, 'Topic');
const lambdaFunction = new lambda.Function(stack, 'LambdaFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'hello.handler',
code: lambda.Code.fromInline('exports.handler = {}'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-lambda');
const handler = new lambda.Function(stack, 'Handler', {
code: lambda.Code.fromAsset(path.join(__dirname, 'handler')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});
const version = handler.currentVersion;
const blueGreenAlias = new lambda.Alias(stack, 'Alias', {
Expand All @@ -21,12 +21,12 @@ const blueGreenAlias = new lambda.Alias(stack, 'Alias', {
const preHook = new lambda.Function(stack, 'PreHook', {
code: lambda.Code.fromAsset(path.join(__dirname, 'preHook')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});
const postHook = new lambda.Function(stack, 'PostHook', {
code: lambda.Code.fromAsset(path.join(__dirname, 'postHook')),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

new codedeploy.LambdaDeploymentGroup(stack, 'BlueGreenDeployment', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const lambdaCode = lambda.Code.fromCfnParameters();
new lambda.Function(lambdaStack, 'Lambda', {
code: lambdaCode,
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});
// other resources that your Lambda needs, added to the lambdaStack...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const lambdaFun = new lambda.Function(stack, 'LambdaFun', {
};
`),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});
const lambdaStage = pipeline.addStage({ stageName: 'Lambda' });
lambdaStage.addAction(new cpactions.LambdaInvokeAction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const app = new App();
const stack = new Stack(app, 'integ-user-pool-custom-sender');

const customSenderLambda = new lambda.Function(stack, 'emailLambda', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { console.log("Mocked custom email send");return cb(null, "success"); }'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function dummyTrigger(name: string): IFunction {
return new Function(stack, name, {
functionName: name,
handler: 'index.handler',
runtime: Runtime.NODEJS_14_X,
runtime: Runtime.NODEJS_16_X,
code: Code.fromInline('foo'),
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-config-custompolicy');
const fn = new lambda.Function(stack, 'CustomFunction', {
code: lambda.AssetCode.fromInline('exports.handler = (event) => console.log(event);'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

new config.CustomRule(stack, 'Custom', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const stack = new cdk.Stack(app, 'aws-cdk-config-rule-scoped-integ', {});
const fn = new lambda.Function(stack, 'CustomFunction', {
code: lambda.AssetCode.fromInline('exports.handler = (event) => console.log(event);'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
});

new config.CustomRule(stack, 'Custom', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ImportCertificates extends Construct {

const serviceToken = CustomResourceProvider.getOrCreate(this, IMPORT_CERTIFICATES_RESOURCE_TYPE, {
codeDirectory: path.join(__dirname, 'import-certificates-handler'),
runtime: CustomResourceProviderRuntime.NODEJS_14_X,
runtime: CustomResourceProviderRuntime.NODEJS_16_X,
policyStatements: [{
Effect: 'Allow',
Action: ['acm:ImportCertificate', 'acm:DeleteCertificate'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const app = new cdk.App();
const stack = new cdk.Stack(app, 'lambda-events');

const fn = new lambda.Function(stack, 'MyFunc', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = ${handler.toString()}`),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestStack extends Stack {
this.queue = new sqs.Queue(this, 'Queue');

this.fn = new lambda.Function(this, 'SnsSqs', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = async (event) => {
if (event.status === 'OK') return 'success';
Expand All @@ -35,15 +35,15 @@ class TestStack extends Stack {
});

const onSuccessLambda = new lambda.Function(this, 'OnSucces', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = async (event) => {
console.log(event);
};`),
});

new lambda.Function(this, 'EventBusLambda', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = async (event) => {
if (event.status === 'OK') return 'success';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestStack extends Stack {
super(scope, id, props);

const lambdaProps: lambda.FunctionProps = {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline(`exports.handler = async (event) => {
console.log('Event: %j', event);
Expand Down
Loading

0 comments on commit c8799ed

Please sign in to comment.