Skip to content

Commit 8056505

Browse files
vlesierseVincent Lesiersegithub-actions
authored
feat: adding .NET 8 (dotnet8) lambda runtime support (#79)
Fixes # Add support for the .NET 8 Lambda Runtime. --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: Vincent Lesierse <[email protected]> Co-authored-by: github-actions <[email protected]>
1 parent 02e60ab commit 8056505

17 files changed

+1168
-44
lines changed

.projen/deps.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DependencyType } from 'projen';
77
const project = new CdklabsConstructLibrary({
88
author: 'AWS',
99
authorAddress: '[email protected]',
10-
cdkVersion: '2.80.0',
10+
cdkVersion: '2.129.0',
1111
jsiiVersion: '~5.3.0',
1212
typescriptVersion: '~5.3.3',
1313
defaultReleaseBranch: 'main',
@@ -61,7 +61,7 @@ const project = new CdklabsConstructLibrary({
6161
});
6262

6363
project.deps.addDependency(
64-
'@aws-cdk/integ-tests-alpha@2.80.0-alpha.0',
64+
'@aws-cdk/integ-tests-alpha@2.129.0-alpha.0',
6565
DependencyType.TEST,
6666
);
6767

API.md

Lines changed: 172 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/private/bundling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Bundling implements cdk.BundlingOptions {
5151
}
5252

5353
private static runsLocally?: boolean;
54-
private static defaultBuildImage = 'public.ecr.aws/sam/build-dotnet7';
54+
private static defaultBuildImage = 'public.ecr.aws/sam/build-dotnet8';
5555

5656
public readonly image: cdk.DockerImage;
5757
public readonly command: string[];

test/integ.function-dotnet8.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
2+
import { App, CfnOutput, Stack, StackProps } from 'aws-cdk-lib';
3+
import { Runtime } from 'aws-cdk-lib/aws-lambda';
4+
import { Construct } from 'constructs';
5+
import * as lambda from '../src';
6+
7+
/*
8+
* Stack verification steps:
9+
* * aws lambda invoke --function-name <deployed fn name> --invocation-type Event --payload '"OK"' response.json
10+
*/
11+
12+
class TestStack extends Stack {
13+
public readonly functionName: string;
14+
constructor(scope: Construct, id: string, props?: StackProps) {
15+
super(scope, id, props);
16+
17+
const fn = new lambda.DotNetFunction(this, 'lambda-handler', {
18+
projectDir: 'lambda-handler-dotnet8',
19+
handler: 'LambdaHandler::LambdaHandler.Function::FunctionHandler',
20+
runtime: Runtime.DOTNET_8,
21+
});
22+
this.functionName = fn.functionName;
23+
24+
new CfnOutput(this, 'FunctionArn', {
25+
value: fn.functionArn,
26+
});
27+
}
28+
}
29+
30+
const app = new App();
31+
const testCase = new TestStack(app, 'integ-lambda-dotnet-function');
32+
const integ = new IntegTest(app, 'lambda-dotnet-function', {
33+
testCases: [testCase],
34+
stackUpdateWorkflow: false,
35+
});
36+
37+
const invoke = integ.assertions.invokeFunction({
38+
functionName: testCase.functionName,
39+
});
40+
41+
invoke.expect(
42+
ExpectedResult.objectLike({
43+
Payload: '"Ok"',
44+
}),
45+
);
46+
app.synth();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"36.0.0"}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "36.0.0",
3+
"files": {
4+
"bd8c601776f4c6044a0380c89be54819d21f1bc9e16efc82057ae0d973d62728": {
5+
"source": {
6+
"path": "asset.bd8c601776f4c6044a0380c89be54819d21f1bc9e16efc82057ae0d973d62728",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "bd8c601776f4c6044a0380c89be54819d21f1bc9e16efc82057ae0d973d62728.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"adad0d9e5c0084dae0c2a86618677cd602e7eaf8e354a9aa081cd42ed1241755": {
18+
"source": {
19+
"path": "integ-lambda-dotnet-function.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "adad0d9e5c0084dae0c2a86618677cd602e7eaf8e354a9aa081cd42ed1241755.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"Resources": {
3+
"lambdahandlerServiceRoleA08D1FE8": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"lambdahandler909F9205": {
35+
"Type": "AWS::Lambda::Function",
36+
"Properties": {
37+
"Architectures": [
38+
"x86_64"
39+
],
40+
"Code": {
41+
"S3Bucket": {
42+
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
43+
},
44+
"S3Key": "bd8c601776f4c6044a0380c89be54819d21f1bc9e16efc82057ae0d973d62728.zip"
45+
},
46+
"Handler": "LambdaHandler::LambdaHandler.Function::FunctionHandler",
47+
"Role": {
48+
"Fn::GetAtt": [
49+
"lambdahandlerServiceRoleA08D1FE8",
50+
"Arn"
51+
]
52+
},
53+
"Runtime": "dotnet8"
54+
},
55+
"DependsOn": [
56+
"lambdahandlerServiceRoleA08D1FE8"
57+
]
58+
}
59+
},
60+
"Outputs": {
61+
"FunctionArn": {
62+
"Value": {
63+
"Fn::GetAtt": [
64+
"lambdahandler909F9205",
65+
"Arn"
66+
]
67+
}
68+
},
69+
"ExportsOutputReflambdahandler909F920591EA4974": {
70+
"Value": {
71+
"Ref": "lambdahandler909F9205"
72+
},
73+
"Export": {
74+
"Name": "integ-lambda-dotnet-function:ExportsOutputReflambdahandler909F920591EA4974"
75+
}
76+
}
77+
},
78+
"Parameters": {
79+
"BootstrapVersion": {
80+
"Type": "AWS::SSM::Parameter::Value<String>",
81+
"Default": "/cdk-bootstrap/hnb659fds/version",
82+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
83+
}
84+
},
85+
"Rules": {
86+
"CheckBootstrapVersion": {
87+
"Assertions": [
88+
{
89+
"Assert": {
90+
"Fn::Not": [
91+
{
92+
"Fn::Contains": [
93+
[
94+
"1",
95+
"2",
96+
"3",
97+
"4",
98+
"5"
99+
],
100+
{
101+
"Ref": "BootstrapVersion"
102+
}
103+
]
104+
}
105+
]
106+
},
107+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
108+
}
109+
]
110+
}
111+
}
112+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "36.0.0",
3+
"testCases": {
4+
"lambda-dotnet-function/DefaultTest": {
5+
"stacks": [
6+
"integ-lambda-dotnet-function"
7+
],
8+
"stackUpdateWorkflow": false,
9+
"assertionStack": "lambda-dotnet-function/DefaultTest/DeployAssert",
10+
"assertionStackName": "lambdadotnetfunctionDefaultTestDeployAssert02A806B6"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)