Last active
March 1, 2018 05:30
-
-
Save chathurawidanage/cce959620dc276b5c1376c71b02fd4d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "This template creates the stack for project PJ-1-0-0. Generated by Sigma", | |
"Outputs": { | |
"apigcontactuscontactPOST": { | |
"Description": "POST endpoint for resource /contact on API contact_us", | |
"Value": { | |
"Fn::Join": [ | |
"", | |
[ | |
"https://", | |
{ | |
"Ref": "apigcontactus" | |
}, | |
".execute-api.", | |
"us-east-1", | |
".amazonaws.com/", | |
"Prod", | |
"/", | |
"contact" | |
] | |
] | |
} | |
}, | |
"apigcontactusviewGET": { | |
"Description": "GET endpoint for resource /view on API contact_us", | |
"Value": { | |
"Fn::Join": [ | |
"", | |
[ | |
"https://", | |
{ | |
"Ref": "apigcontactus" | |
}, | |
".execute-api.", | |
"us-east-1", | |
".amazonaws.com/", | |
"Prod", | |
"/", | |
"view" | |
] | |
] | |
} | |
} | |
}, | |
"Resources": { | |
"apigcontactus": { | |
"Type": "AWS::ApiGateway::RestApi", | |
"Properties": { | |
"Description": "An API generated by Sigma", | |
"Name": "contact_us", | |
"EndpointConfiguration": { | |
"Types": [ | |
"EDGE" | |
] | |
} | |
} | |
}, | |
"apigcontactuscontact": { | |
"Type": "AWS::ApiGateway::Resource", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ParentId": { | |
"Fn::GetAtt": [ | |
"apigcontactus", | |
"RootResourceId" | |
] | |
}, | |
"PathPart": "contact" | |
} | |
}, | |
"apigcontactuscontactPOST": { | |
"Type": "AWS::ApiGateway::Method", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ResourceId": { | |
"Ref": "apigcontactuscontact" | |
}, | |
"HttpMethod": "POST", | |
"AuthorizationType": "NONE", | |
"MethodResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": true, | |
"method.response.header.Access-Control-Allow-Methods": true, | |
"method.response.header.Access-Control-Allow-Origin": true | |
} | |
} | |
], | |
"Integration": { | |
"Type": "AWS", | |
"IntegrationHttpMethod": "POST", | |
"Uri": { | |
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PJhandler.Arn}/invocations" | |
}, | |
"IntegrationResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'", | |
"method.response.header.Access-Control-Allow-Methods": "'*'", | |
"method.response.header.Access-Control-Allow-Origin": "'*'" | |
} | |
} | |
] | |
} | |
} | |
}, | |
"apigcontactuscontactCors": { | |
"Type": "AWS::ApiGateway::Method", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ResourceId": { | |
"Ref": "apigcontactuscontact" | |
}, | |
"HttpMethod": "OPTIONS", | |
"AuthorizationType": "NONE", | |
"Integration": { | |
"Type": "MOCK", | |
"IntegrationResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'", | |
"method.response.header.Access-Control-Allow-Methods": "'*'", | |
"method.response.header.Access-Control-Allow-Origin": "'*'" | |
} | |
} | |
], | |
"PassthroughBehavior": "NEVER", | |
"RequestTemplates": { | |
"application/json": "{\"statusCode\": 200}" | |
} | |
}, | |
"MethodResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": true, | |
"method.response.header.Access-Control-Allow-Methods": true, | |
"method.response.header.Access-Control-Allow-Origin": true | |
} | |
} | |
] | |
} | |
}, | |
"ddbcontactus": { | |
"Type": "AWS::DynamoDB::Table", | |
"Properties": { | |
"TableName": "contact_us", | |
"AttributeDefinitions": [ | |
{ | |
"AttributeName": "email", | |
"AttributeType": "S" | |
} | |
], | |
"KeySchema": [ | |
{ | |
"AttributeName": "email", | |
"KeyType": "HASH" | |
} | |
], | |
"ProvisionedThroughput": { | |
"ReadCapacityUnits": 1, | |
"WriteCapacityUnits": 1 | |
} | |
} | |
}, | |
"apigcontactusview": { | |
"Type": "AWS::ApiGateway::Resource", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ParentId": { | |
"Fn::GetAtt": [ | |
"apigcontactus", | |
"RootResourceId" | |
] | |
}, | |
"PathPart": "view" | |
} | |
}, | |
"apigcontactusviewGET": { | |
"Type": "AWS::ApiGateway::Method", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ResourceId": { | |
"Ref": "apigcontactusview" | |
}, | |
"HttpMethod": "GET", | |
"AuthorizationType": "NONE", | |
"MethodResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": true, | |
"method.response.header.Access-Control-Allow-Methods": true, | |
"method.response.header.Access-Control-Allow-Origin": true | |
} | |
} | |
], | |
"Integration": { | |
"Type": "AWS_PROXY", | |
"IntegrationHttpMethod": "POST", | |
"Uri": { | |
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PJviewer.Arn}/invocations" | |
}, | |
"IntegrationResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'", | |
"method.response.header.Access-Control-Allow-Methods": "'*'", | |
"method.response.header.Access-Control-Allow-Origin": "'*'" | |
} | |
} | |
] | |
} | |
} | |
}, | |
"apigcontactusviewCors": { | |
"Type": "AWS::ApiGateway::Method", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"ResourceId": { | |
"Ref": "apigcontactusview" | |
}, | |
"HttpMethod": "OPTIONS", | |
"AuthorizationType": "NONE", | |
"Integration": { | |
"Type": "MOCK", | |
"IntegrationResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'", | |
"method.response.header.Access-Control-Allow-Methods": "'*'", | |
"method.response.header.Access-Control-Allow-Origin": "'*'" | |
} | |
} | |
], | |
"PassthroughBehavior": "NEVER", | |
"RequestTemplates": { | |
"application/json": "{\"statusCode\": 200}" | |
} | |
}, | |
"MethodResponses": [ | |
{ | |
"StatusCode": "200", | |
"ResponseParameters": { | |
"method.response.header.Access-Control-Allow-Headers": true, | |
"method.response.header.Access-Control-Allow-Methods": true, | |
"method.response.header.Access-Control-Allow-Origin": true | |
} | |
} | |
] | |
} | |
}, | |
"PJhandler": { | |
"Type": "AWS::Lambda::Function", | |
"Properties": { | |
"FunctionName": "PJhandler", | |
"Description": "Invokes functions defined in PJ/handler.js in project PJ-1-0-0. Generated by Sigma.", | |
"Code": { | |
"S3Bucket": "sigma-slappforge-480964559519-us-east-1-build-artifacts", | |
"S3Key": "PJ100-sigma-artifacts/6d8b4037-4eec-47ce-ad2f-df378451015c/PJ100.zip" | |
}, | |
"Handler": "PJ/handler.handler", | |
"Timeout": 60, | |
"Runtime": "nodejs6.10", | |
"Role": { | |
"Fn::GetAtt": [ | |
"PJhandlerExecutionRole", | |
"Arn" | |
] | |
} | |
} | |
}, | |
"PJhandlerExecutionRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | |
], | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"sts:AssumeRole" | |
], | |
"Effect": "Allow", | |
"Principal": { | |
"Service": [ | |
"lambda.amazonaws.com" | |
] | |
} | |
} | |
] | |
}, | |
"Policies": [ | |
{ | |
"PolicyName": "PJhandlerPolicy", | |
"PolicyDocument": { | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:PutItem" | |
], | |
"Resource": { | |
"Fn::GetAtt": [ | |
"ddbcontactus", | |
"Arn" | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"apigcontactuscontactPOSTPermission": { | |
"Type": "AWS::Lambda::Permission", | |
"Properties": { | |
"Action": "lambda:InvokeFunction", | |
"FunctionName": { | |
"Ref": "PJhandler" | |
}, | |
"SourceArn": { | |
"Fn::Sub": [ | |
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/*/${__Method__}${__Path__}", | |
{ | |
"__Method__": "POST", | |
"__Path__": "/contact", | |
"__ApiId__": { | |
"Ref": "apigcontactus" | |
} | |
} | |
] | |
}, | |
"Principal": "apigateway.amazonaws.com" | |
} | |
}, | |
"PJviewer": { | |
"Type": "AWS::Lambda::Function", | |
"Properties": { | |
"FunctionName": "PJviewer", | |
"Description": "Invokes functions defined in PJ/viewer.js in project PJ-1-0-0. Generated by Sigma.", | |
"Code": { | |
"S3Bucket": "sigma-slappforge-480964559519-us-east-1-build-artifacts", | |
"S3Key": "PJ100-sigma-artifacts/6d8b4037-4eec-47ce-ad2f-df378451015c/PJ100.zip" | |
}, | |
"Handler": "PJ/viewer.handler", | |
"Timeout": 60, | |
"Runtime": "nodejs6.10", | |
"Role": { | |
"Fn::GetAtt": [ | |
"PJviewerExecutionRole", | |
"Arn" | |
] | |
} | |
} | |
}, | |
"PJviewerExecutionRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | |
], | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": [ | |
"sts:AssumeRole" | |
], | |
"Effect": "Allow", | |
"Principal": { | |
"Service": [ | |
"lambda.amazonaws.com" | |
] | |
} | |
} | |
] | |
}, | |
"Policies": [ | |
{ | |
"PolicyName": "PJviewerPolicy", | |
"PolicyDocument": { | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:Scan" | |
], | |
"Resource": { | |
"Fn::GetAtt": [ | |
"ddbcontactus", | |
"Arn" | |
] | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"apigcontactusviewGETPermission": { | |
"Type": "AWS::Lambda::Permission", | |
"Properties": { | |
"Action": "lambda:InvokeFunction", | |
"FunctionName": { | |
"Ref": "PJviewer" | |
}, | |
"SourceArn": { | |
"Fn::Sub": [ | |
"arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${__ApiId__}/*/${__Method__}${__Path__}", | |
{ | |
"__Method__": "GET", | |
"__Path__": "/view", | |
"__ApiId__": { | |
"Ref": "apigcontactus" | |
} | |
} | |
] | |
}, | |
"Principal": "apigateway.amazonaws.com" | |
} | |
}, | |
"apigcontactusDeployment1519880834865": { | |
"Type": "AWS::ApiGateway::Deployment", | |
"Properties": { | |
"RestApiId": { | |
"Ref": "apigcontactus" | |
}, | |
"Description": "An API deployment generated by Sigma for API contact_us", | |
"StageName": "Prod" | |
}, | |
"DependsOn": [ | |
"apigcontactuscontactPOST", | |
"apigcontactuscontactCors", | |
"apigcontactusviewGET", | |
"apigcontactusviewCors" | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment