AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 ########################################################################## # Parameters # ########################################################################## Parameters: StageName: Description: The name of the stage is the first path segment in the Uniform Resource Identifier (URI) of a call to API Gateway Type: String Default: dev ########################################################################## # Global values that are applied to all resources # ########################################################################## Globals: Function: MemorySize: 1024 Architectures: ["arm64"] Handler: bootstrap Runtime: provided.al2 Timeout: 29 Layers: - !Sub arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension-Arm64:1 Environment: Variables: RUST_BACKTRACE: 1 RUST_LOG: info Resources: ########################################################################## # API Gateway HTTP API # # ########################################################################## AccessLogs: Type: AWS::Logs::LogGroup Properties: RetentionInDays: 1 LogGroupName: !Sub "/api-gateway/${AWS::StackName}/APIAccessLogs-rust" HttpApi: Type: AWS::Serverless::HttpApi Properties: AccessLogSettings: DestinationArn: !GetAtt AccessLogs.Arn Format: '{ "requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod","routeKey":"$context.routeKey", "status":"$context.status","protocol":"$context.protocol", "responseLength":"$context.responseLength" }' CorsConfiguration: AllowOrigins: - '*' AllowMethods: - GET - HEAD - OPTIONS - POST Tags: name: !Ref AWS::StackName ########################################################################## # Lambda Function # ########################################################################## LambdaFunction: Type: AWS::Serverless::Function Properties: CodeUri: ./build/handler Policies: - AWSLambdaBasicExecutionRole Events: api: Type: HttpApi Properties: ApiId: !Ref HttpApi Path: /api Method: GET proxy: Type: HttpApi Properties: ApiId: !Ref HttpApi Path: /api/{proxy+} Method: GET Tags: name: !Ref AWS::StackName env: !Ref StageName Outputs: HttpApiEndpoint: Description: The api endpoint. Value: !GetAtt HttpApi.ApiEndpoint