mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
e58d89148c
- Adjust notice, security reporting, code of conduct, contribution process to the standard AWS documents - Adjust GitHub issue templates to AWS standard ones. - Adjust the license header in all source files --------- Co-authored-by: Sebastien Stormacq <stormacq@amazon.lu>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftAWSLambdaRuntime open source project
|
|
//
|
|
// Copyright SwiftAWSLambdaRuntime project authors
|
|
// Copyright (c) Amazon.com, Inc. or its affiliates.
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import * as cdk from 'aws-cdk-lib';
|
|
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
import * as apigateway from 'aws-cdk-lib/aws-apigatewayv2';
|
|
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
|
|
export class LambdaApiStack extends cdk.Stack {
|
|
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
|
|
super(scope, id, props);
|
|
|
|
// Create the Lambda function
|
|
const lambdaFunction = new lambda.Function(this, 'SwiftLambdaFunction', {
|
|
runtime: lambda.Runtime.PROVIDED_AL2,
|
|
architecture: lambda.Architecture.ARM_64,
|
|
handler: 'bootstrap',
|
|
code: lambda.Code.fromAsset('../.build/plugins/AWSLambdaPackager/outputs/AWSLambdaPackager/APIGatewayLambda/APIGatewayLambda.zip'),
|
|
memorySize: 128,
|
|
timeout: cdk.Duration.seconds(30),
|
|
environment: {
|
|
LOG_LEVEL: 'debug',
|
|
},
|
|
});
|
|
|
|
// Create the integration
|
|
const integration = new HttpLambdaIntegration(
|
|
'LambdaIntegration',
|
|
lambdaFunction
|
|
);
|
|
|
|
// Create HTTP API with the integration
|
|
const httpApi = new apigateway.HttpApi(this, 'HttpApi', {
|
|
defaultIntegration: integration,
|
|
});
|
|
|
|
// Output the API URL
|
|
new cdk.CfnOutput(this, 'ApiUrl', {
|
|
value: httpApi.url ?? 'Something went wrong',
|
|
});
|
|
}
|
|
}
|
|
|