Skip to content

Instantly share code, notes, and snippets.

View asishrs's full-sized avatar
🔥
<Coding>

asish asishrs

🔥
<Coding>
View GitHub Profile
ApiKey:
Type: AWS::ApiGateway::ApiKey
Properties:
Name: !Join ["", [{"Ref": "AWS::StackName"}, "-apikey"]]
Description: !Join ["", [{"Ref": "AWS::StackName"}, "api key"]]
Enabled: true
GenerateDistinctId: false
ApiUsagePlan:
Type: "AWS::ApiGateway::UsagePlan"
DependsOn: ApiGatewayStage
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
Code:
ZipFile: |
exports.handler = async function(event, context) {
return { statusCode: 200, body: 'Hello World!' };
};
Description: API Lambda function
FunctionName: !Ref "lambdaFunctionName"
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS API Gateway with a Lambda Integration
Parameters:
lambdaFunctionName:
Type: "String"
AllowedPattern: "^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$"
Description: Lambda function name. (Recommend to keep default)
Default: "lambda-api"
ProxyResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
RestApiId: !Ref ApiGatewayRestApi
ParentId: !GetAtt ApiGatewayRestApi.RootResourceId
PathPart: !Ref "apiResourcePath"
ProxyResourceANY:
Type: 'AWS::ApiGateway::Method'
Properties:
ApiGatewayRestApi:
Type: AWS::ApiGateway::RestApi
Properties:
ApiKeySourceType: HEADER
Description: An API Gateway for Lambda APIs
EndpointConfiguration:
Types:
- REGIONAL
Name: !Join ["", [{"Ref": "AWS::StackName"}, "-api"]]