Skip to content

Commit

Permalink
Merge branch 'master' into corymhall/add-author
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 10, 2022
2 parents a3ab199 + 83bab5c commit 59368ad
Show file tree
Hide file tree
Showing 11 changed files with 452 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-label-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
env:
OSDS_DEVS: >
{
"assignees":["NGL321","peterwoodworth","ryparker"]
"assignees":["NGL321","peterwoodworth"]
}
AREA_AFFIXES: >
Expand Down
36 changes: 18 additions & 18 deletions packages/@aws-cdk/aws-lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This construct library allows you to define AWS Lambda Functions.

```ts
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand Down Expand Up @@ -91,7 +91,7 @@ function. To reference the autogenerated Role:

```ts
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand All @@ -109,7 +109,7 @@ const myRole = new iam.Role(this, 'My Role', {
});

const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
role: myRole, // user-provided role
Expand All @@ -131,7 +131,7 @@ import * as cdk from '@aws-cdk/core';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';

const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
timeout: cdk.Duration.minutes(5),
Expand Down Expand Up @@ -243,7 +243,7 @@ latest code. For instance -
```ts
const codeVersion = "stringOrMethodToGetCodeVersion";
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
environment: {
Expand Down Expand Up @@ -331,7 +331,7 @@ const fn = new lambda.Function(this, 'MyFunction', {
removalPolicy: RemovalPolicy.RETAIN, // retain old versions
retryAttempts: 1, // async retry attempts
},
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand Down Expand Up @@ -435,7 +435,7 @@ A lambda function can be configured to be run on one of these platforms:

```ts
new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
architecture: lambda.Architecture.ARM_64,
Expand All @@ -459,7 +459,7 @@ which provides low-level runtime metrics for a Lambda functions.

```ts
new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
insightsVersion: lambda.LambdaInsightsVersion.VERSION_1_0_98_0,
Expand All @@ -471,7 +471,7 @@ If the version of insights is not yet available in the CDK, you can also provide
```ts
const layerArn = 'arn:aws:lambda:us-east-1:580247275435:layer:LambdaInsightsExtension:14';
new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
insightsVersion: lambda.LambdaInsightsVersion.fromInsightVersionArn(layerArn),
Expand All @@ -483,7 +483,7 @@ Lambda Insights Version >= `1_0_119_0`.

```ts
new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
architecture: lambda.Architecture.ARM_64,
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
Expand Down Expand Up @@ -592,7 +592,7 @@ a `sqs.Queue` as `deadLetterQueue`.

```ts
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
deadLetterQueueEnabled: true,
Expand All @@ -606,7 +606,7 @@ import * as sqs from '@aws-cdk/aws-sqs';

const dlq = new sqs.Queue(this, 'DLQ');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
deadLetterQueue: dlq,
Expand All @@ -620,7 +620,7 @@ import * as sns from '@aws-cdk/aws-sns';

const dlt = new sns.Topic(this, 'DLQ');
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('// your code here'),
deadLetterTopic: dlt,
Expand All @@ -634,7 +634,7 @@ to learn more about AWS Lambdas and DLQs.

```ts
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
tracing: lambda.Tracing.ACTIVE,
Expand Down Expand Up @@ -669,7 +669,7 @@ to learn more about AWS Lambda's Profiling support.

```ts
const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromInline('exports.handler = function(event, ctx, cb) { return cb(null, "hi"); }'),
reservedConcurrentExecutions: 100,
Expand Down Expand Up @@ -767,7 +767,7 @@ const accessPoint = fileSystem.addAccessPoint('AccessPoint', {
const fn = new lambda.Function(this, 'MyLambda', {
// mount the access point to /mnt/msg in the lambda runtime environment
filesystem: lambda.FileSystem.fromEfsAccessPoint(accessPoint, '/mnt/msg'),
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
vpc,
Expand All @@ -784,7 +784,7 @@ The ephemeral storage will be accessible in the functions' `/tmp` directory.
import { Size } from '@aws-cdk/core';

const fn = new lambda.Function(this, 'MyFunction', {
runtime: lambda.Runtime.NODEJS_14_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
ephemeralStorageSize: Size.mebibytes(1024),
Expand Down Expand Up @@ -881,7 +881,7 @@ const codeSigningConfig = new lambda.CodeSigningConfig(this, 'CodeSigningConfig'

new lambda.Function(this, 'Function', {
codeSigningConfig,
runtime: lambda.Runtime.NODEJS_12_X,
runtime: lambda.Runtime.NODEJS_16_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export class Runtime {
*/
public static readonly NODEJS_14_X = new Runtime('nodejs14.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });

/**
* The NodeJS 16.x runtime (nodejs16.x)
*/
public static readonly NODEJS_16_X = new Runtime('nodejs16.x', RuntimeFamily.NODEJS, { supportsInlineCode: true });

/**
* The Python 2.7 runtime (python2.7)
* @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-lambda/test/integ.runtime.inlinecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,11 @@ const node14xfn = new Function(stack, 'NODEJS_14_X', {
});
new CfnOutput(stack, 'NODEJS_14_X-functionName', { value: node14xfn.functionName });

const node16xfn = new Function(stack, 'NODEJS_16_X', {
code: new InlineCode('exports.handler = async function(event) { return "success" }'),
handler: 'index.handler',
runtime: Runtime.NODEJS_16_X,
});
new CfnOutput(stack, 'NODEJS_16_X-functionName', { value: node16xfn.functionName });

app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,56 @@
"DependsOn": [
"NODEJS14XServiceRole4523ECDB"
]
},
"NODEJS16XServiceRoleB9DAFDFD": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"NODEJS16XDE5DD82D": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = async function(event) { return \"success\" }"
},
"Role": {
"Fn::GetAtt": [
"NODEJS16XServiceRoleB9DAFDFD",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": "nodejs16.x"
},
"DependsOn": [
"NODEJS16XServiceRoleB9DAFDFD"
]
}
},
"Outputs": {
Expand Down Expand Up @@ -331,6 +381,11 @@
"Value": {
"Ref": "NODEJS14X930214A3"
}
},
"NODEJS16XfunctionName": {
"Value": {
"Ref": "NODEJS16XDE5DD82D"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"17.0.0"}
{"version":"18.0.0"}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "18.0.0",
"testCases": {
"aws-lambda/test/integ.runtime.inlinecode": {
"integ.runtime.inlinecode": {
"stacks": [
"aws-cdk-lambda-runtime-inlinecode"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "17.0.0",
"version": "18.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
Expand Down Expand Up @@ -122,6 +122,24 @@
"type": "aws:cdk:logicalId",
"data": "NODEJS14XfunctionName"
}
],
"/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/ServiceRole/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "NODEJS16XServiceRoleB9DAFDFD"
}
],
"/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "NODEJS16XDE5DD82D"
}
],
"/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X-functionName": [
{
"type": "aws:cdk:logicalId",
"data": "NODEJS16XfunctionName"
}
]
},
"displayName": "aws-cdk-lambda-runtime-inlinecode"
Expand Down
Loading

0 comments on commit 59368ad

Please sign in to comment.