{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Creates Lambda function API Gateway CustomResource CloudFormation handler", "Parameters": { "APIGatewayCustomResourceZipKey": { "Description": "Zip file for API Gatway custom resource", "Type": "String", "Default": "apigatewaycloudformation-V1.1.4.zip" } }, "Mappings" : { "AWSRegion2Bucket" : { "us-east-1" : {"OpenCode" : "au-com-thinkronicity-opencode-usea1", "ClientCode" : "au-com-thinkronicity-clientcode-apne1"}, "us-west-1" : {"OpenCode" : "au-com-thinkronicity-opencode-uswe1", "ClientCode" : "au-com-thinkronicity-clientcode-apne1"}, "eu-west-1" : {"OpenCode" : "au-com-thinkronicity-opencode-euwe1", "ClientCode" : "au-com-thinkronicity-clientcode-apne1"}, "ap-northeast-1" : {"OpenCode" : "au-com-thinkronicity-opencode-apne1", "ClientCode" : "au-com-thinkronicity-clientcode-apne1"} } }, "Resources": { "LambdaBasePolicy": { "Type": "AWS::IAM::ManagedPolicy", "Properties": { "Description" : "managed Policy for API Gateway Lambda function", "Path" : "/infrastructure/base/lambda/", "PolicyDocument": { "Version" : "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }, { "Effect": "Allow", "Action": [ "apigateway:*" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "iam:PassRole" ], "Resource": "*" } ] } } }, "LambdaFunctionRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }, "ManagedPolicyArns": [{ "Ref": "LambdaBasePolicy" }] } }, "LambdaFunction": { "Type": "AWS::Lambda::Function", "Properties": { "Code" : { "S3Bucket" : { "Fn::FindInMap" : [ "AWSRegion2Bucket", { "Ref" : "AWS::Region" }, "OpenCode" ]}, "S3Key" : {"Ref": "APIGatewayCustomResourceZipKey"} }, "Description": "Api Gateway CloudFormation.", "Handler": "lib/index.handler", "MemorySize": 256, "Role": { "Fn::GetAtt": ["LambdaFunctionRole", "Arn"] }, "Runtime": "nodejs", "Timeout": 30 } } }, "Outputs": { "LambdaFunction": { "Value": { "Fn::GetAtt": ["LambdaFunction", "Arn"] } } } }