-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-stack-stack.ts
39 lines (36 loc) · 1.3 KB
/
test-stack-stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
export class TestStackStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const testFunction = new lambda.Function(this, "TestDotNetFunction", {
runtime: lambda.Runtime.DOTNET_8,
handler: "dotnet::Dotnet.Function::FunctionHandler",
code: lambda.Code.fromAsset(
"../lambda-code/src",
{
bundling: {
image: lambda.Runtime.DOTNET_8.bundlingImage,
user: "root",
outputType: cdk.BundlingOutput.ARCHIVED,
command: [
"/bin/sh",
"-c",
"dotnet tool install -g Amazon.Lambda.Tools && " +
"dotnet build && " +
"dotnet lambda package --output-package /asset-output/function.zip --framework net8.0 --configuration Debug"
]
}
}
),
timeout: cdk.Duration.minutes(60)
});
const restApi = new apigateway.LambdaRestApi(this, "TestLambdaApiGw", {
handler: testFunction,
proxy: true,
});
new cdk.CfnOutput(this, "ApiOutput", { value: restApi.url });
}
}