UNPKG

@kalarrs/serverless-shared-api-gateway

Version:

Share a single AWS Api Gatewy between multiple serverless projects

311 lines 8.42 kB
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "The AWS CloudFormation template for this Serverless application", "Resources": { "ServerlessDeploymentBucket": { "Type": "AWS::S3::Bucket" }, "CreateLogGroup": { "Type": "AWS::Logs::LogGroup", "Properties": { "LogGroupName": "/aws/lambda/panda-dev-create" } }, "IamRoleLambdaExecution": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "lambda.amazonaws.com" ] }, "Action": [ "sts:AssumeRole" ] } ] }, "Policies": [ { "PolicyName": { "Fn::Join": [ "-", [ "dev", "panda", "lambda" ] ] }, "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogStream" ], "Resource": [ { "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/panda-dev-create:*" } ] }, { "Effect": "Allow", "Action": [ "logs:PutLogEvents" ], "Resource": [ { "Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/panda-dev-create:*:*" } ] } ] } } ], "Path": "/", "RoleName": { "Fn::Join": [ "-", [ "panda", "dev", "us-east-1", "lambdaRole" ] ] } } }, "CreateLambdaFunction": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, "S3Key": "serverless/panda/dev/1544117610766-2018-12-06T17:33:30.766Z/panda.zip" }, "FunctionName": "panda-dev-create", "Handler": "src/handler.create", "MemorySize": 1024, "Role": { "Fn::GetAtt": [ "IamRoleLambdaExecution", "Arn" ] }, "Runtime": "nodejs8.10", "Timeout": 6, "Environment": { "Variables": { "NODE_ENV": "test", "SERVICE_NAME": "panda" } } }, "DependsOn": [ "CreateLogGroup", "IamRoleLambdaExecution" ] }, "CreateLambdaVersionnT19tKLrQ9agg63HItePiL0qHSJC6ckA3YDP8YCeJU": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "CreateLambdaFunction" }, "CodeSha256": "cvOcCEpf0i9CXmEaKdkxXEMymqtI7ZrAcxfONPWGDN4=" } }, "ApiGatewayResourcePandas": { "Type": "AWS::ApiGateway::Resource", "Properties": { "ParentId": "abcde1fghi", "PathPart": "pandas", "RestApiId": "ijklmn12op" } }, "ApiGatewayMethodPandasOptions": { "Type": "AWS::ApiGateway::Method", "Properties": { "AuthorizationType": "NONE", "HttpMethod": "OPTIONS", "MethodResponses": [ { "StatusCode": "200", "ResponseParameters": { "method.response.header.Access-Control-Allow-Origin": true, "method.response.header.Access-Control-Allow-Headers": true, "method.response.header.Access-Control-Allow-Methods": true, "method.response.header.Access-Control-Allow-Credentials": true }, "ResponseModels": {} } ], "RequestParameters": {}, "Integration": { "Type": "MOCK", "RequestTemplates": { "application/json": "{statusCode:200}" }, "ContentHandling": "CONVERT_TO_TEXT", "IntegrationResponses": [ { "StatusCode": "200", "ResponseParameters": { "method.response.header.Access-Control-Allow-Origin": "'*'", "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'", "method.response.header.Access-Control-Allow-Methods": "'OPTIONS,POST'", "method.response.header.Access-Control-Allow-Credentials": "'false'" }, "ResponseTemplates": { "application/json": "" } } ] }, "ResourceId": { "Ref": "ApiGatewayResourcePandas" }, "RestApiId": "ijklmn12op" } }, "ApiGatewayMethodPandasPost": { "Type": "AWS::ApiGateway::Method", "Properties": { "HttpMethod": "POST", "RequestParameters": {}, "ResourceId": { "Ref": "ApiGatewayResourcePandas" }, "RestApiId": "ijklmn12op", "ApiKeyRequired": false, "AuthorizationType": "NONE", "Integration": { "IntegrationHttpMethod": "POST", "Type": "AWS_PROXY", "Uri": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":apigateway:", { "Ref": "AWS::Region" }, ":lambda:path/2015-03-31/functions/", { "Fn::GetAtt": [ "CreateLambdaFunction", "Arn" ] }, "/invocations" ] ] } }, "MethodResponses": [] } }, "ApiGatewayDeployment1544117610768": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": "ijklmn12op", "StageName": "dev" }, "DependsOn": [ "ApiGatewayMethodPandasOptions", "ApiGatewayMethodPandasPost" ] }, "CreateLambdaPermissionApiGateway": { "Type": "AWS::Lambda::Permission", "Properties": { "FunctionName": { "Fn::GetAtt": [ "CreateLambdaFunction", "Arn" ] }, "Action": "lambda:InvokeFunction", "Principal": { "Fn::Join": [ "", [ "apigateway.", { "Ref": "AWS::URLSuffix" } ] ] }, "SourceArn": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition" }, ":execute-api:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":", "ijklmn12op", "/*/*" ] ] } } } }, "Outputs": { "ServerlessDeploymentBucketName": { "Value": { "Ref": "ServerlessDeploymentBucket" } }, "CreateLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { "Ref": "CreateLambdaVersionnT19tKLrQ9agg63HItePiL0qHSJC6ckA3YDP8YCeJU" } }, "ServiceEndpoint": { "Description": "URL of the service endpoint", "Value": { "Fn::Join": [ "", [ "https://", "ijklmn12op", ".execute-api.us-east-1.", { "Ref": "AWS::URLSuffix" }, "/dev" ] ] } } } }