javascript
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
WebS3Location:
Type: String
Default: 's3://api-ksastaging-reference.zaam.zensiontec.com/middleware/api-middleware-dev-api-dev-oas30.json'
Resources:
#### Existing S3-based API Definition
MiddlewareApis:
Type: AWS::Serverless::Api
Properties:
Name: !Sub "${AWS::StackName}-api-new"
Description: !Sub "For Middleware ${Stage} Web APIs"
StageName: !Sub '${Stage}'
DefinitionBody:
Fn::Transform:
Name: AWS::Include
Parameters:
Location: !Ref WebS3Location
TracingEnabled: true
MethodSettings:
- MetricsEnabled: true
HttpMethod: '*'
ResourcePath: '/*'
LoggingLevel: INFO
Cors:
AllowMethods: "'GET,POST,PUT,DELETE,OPTIONS'"
AllowHeaders: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
AllowOrigin: "'*'"
AllowCredentials: "'true'"
BinaryMediaTypes:
- "multipart/form-data"
- "image/*"
#### New Lambda Function for Login
LoginFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${AWS::StackName}-login-lambda"
Handler: dist/login.handler # Path to your compiled TS code
Runtime: nodejs18.x
CodeUri: ./ # Update this path as needed
Events:
LoginApiEvent:
Type: Api
Properties:
RestApiId: !Ref MiddlewareApis
Path: /login
Method: POST