Created
June 13, 2017 16:08
-
-
Save vi2co/1b489816399640dc952e1397f00659e9 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", | |
| "Parameters": { | |
| "S3JarBucket": { | |
| "Description": "The name of the S3 bucket that contains the source code of Lambda function.", | |
| "Type": "String" | |
| }, | |
| "Namespace": { | |
| "Description": "The environment name (dev)", | |
| "Type": "String", | |
| "Default": "dev" | |
| }, | |
| "DegreePrecision": { | |
| "Description": "Precision of SPS files", | |
| "Type": "Number", | |
| "Default": 1 | |
| }, | |
| "ReadCapacityUnits": { | |
| "Description": "Default read capacity units for the dynamodb table", | |
| "Type": "Number", | |
| "Default": 100 | |
| }, | |
| "WriteCapacityUnits": { | |
| "Description": "Default write capacity units for the dynamodb table", | |
| "Type": "Number", | |
| "Default": 100 | |
| } | |
| }, | |
| "Resources": { | |
| "DynamoDBTable": { | |
| "Type": "AWS::DynamoDB::Table", | |
| "Properties": { | |
| "TableName": { | |
| "Fn::Sub": "nautical-weather-situation-${Namespace}" | |
| }, | |
| "AttributeDefinitions": [ | |
| { | |
| "AttributeName": "locatedAt", | |
| "AttributeType": "S" | |
| }, | |
| { | |
| "AttributeName": "validAt", | |
| "AttributeType": "S" | |
| } | |
| ], | |
| "KeySchema": [ | |
| { | |
| "AttributeName": "locatedAt", | |
| "KeyType": "HASH" | |
| }, | |
| { | |
| "AttributeName": "validAt", | |
| "KeyType": "RANGE" | |
| } | |
| ], | |
| "ProvisionedThroughput": { | |
| "ReadCapacityUnits": { | |
| "Ref": "ReadCapacityUnits" | |
| }, | |
| "WriteCapacityUnits": { | |
| "Ref": "WriteCapacityUnits" | |
| } | |
| } | |
| } | |
| }, | |
| "ProcessorLambdaLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "LogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${ProcessorLambda}" | |
| }, | |
| "RetentionInDays": 3 | |
| } | |
| }, | |
| "ProjectorLambdaLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "LogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${ProjectorLambda}" | |
| }, | |
| "RetentionInDays": 3 | |
| } | |
| }, | |
| "ApiLambdaLogGroup": { | |
| "Type": "AWS::Logs::LogGroup", | |
| "Properties": { | |
| "LogGroupName": { | |
| "Fn::Sub": "/aws/lambda/${ApiLambda}" | |
| }, | |
| "RetentionInDays": 3 | |
| } | |
| }, | |
| "ProcessorLambdaRole": { | |
| "Type": "AWS::IAM::Role", | |
| "Properties": { | |
| "RoleName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_processor_lambda_role" | |
| }, | |
| "AssumeRolePolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Principal": { | |
| "Service": "lambda.amazonaws.com" | |
| }, | |
| "Action": "sts:AssumeRole" | |
| } | |
| ] | |
| }, | |
| "Policies": [ | |
| { | |
| "PolicyName": "lambda", | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogGroup", | |
| "logs:CreateLogStream", | |
| "logs:PutLogEvents" | |
| ], | |
| "Resource": "arn:aws:logs:*:*:*" | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "s3:GetObject" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:s3:::svc.mg.mg-nautical.${Namespace}.s3.mg/*" | |
| } | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "lambda:InvokeFunction" | |
| ], | |
| "Resource": { | |
| "Fn::GetAtt": [ | |
| "ProjectorLambda", | |
| "Arn" | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "ProjectorLambdaRole": { | |
| "Type": "AWS::IAM::Role", | |
| "Properties": { | |
| "RoleName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_projector_lambda_role" | |
| }, | |
| "AssumeRolePolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Principal": { | |
| "Service": "lambda.amazonaws.com" | |
| }, | |
| "Action": "sts:AssumeRole" | |
| } | |
| ] | |
| }, | |
| "Policies": [ | |
| { | |
| "PolicyName": "lambda", | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogGroup", | |
| "logs:CreateLogStream", | |
| "logs:PutLogEvents" | |
| ], | |
| "Resource": "arn:aws:logs:*:*:*" | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "dynamodb:BatchWriteItem", | |
| "dynamodb:BatchGetItem", | |
| "dynamodb:GetItem", | |
| "dynamodb:PutItem", | |
| "dynamodb:Query", | |
| "dynamodb:UpdateItem" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/nautical-weather-situation-${Namespace}" | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "ApiLambdaRole": { | |
| "Type": "AWS::IAM::Role", | |
| "Properties": { | |
| "RoleName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_api_lambda_role" | |
| }, | |
| "AssumeRolePolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Principal": { | |
| "Service": "lambda.amazonaws.com" | |
| }, | |
| "Action": "sts:AssumeRole" | |
| } | |
| ] | |
| }, | |
| "Policies": [ | |
| { | |
| "PolicyName": "lambda", | |
| "PolicyDocument": { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "logs:CreateLogGroup", | |
| "logs:CreateLogStream", | |
| "logs:PutLogEvents" | |
| ], | |
| "Resource": "arn:aws:logs:*:*:*" | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "dynamodb:BatchGetItem", | |
| "dynamodb:GetItem", | |
| "dynamodb:Query" | |
| ], | |
| "Resource": { | |
| "Fn::Sub": "arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/nautical-weather-situation-${Namespace}" | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "ProcessorLambda": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "FunctionName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_processor" | |
| }, | |
| "Handler": "com.meteogroup.nautical.processor.infrastructure.aws.lambda.ProcessorRequestHandler", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "ProcessorLambdaRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Code": { | |
| "S3Bucket": { | |
| "Ref": "S3JarBucket" | |
| }, | |
| "S3Key": { | |
| "Fn::Sub": "nautical-${Namespace}/processor/nautical-service-processor-1.0-SNAPSHOT.jar" | |
| } | |
| }, | |
| "Environment": { | |
| "Variables": { | |
| "projector_lambda_name": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_projector" | |
| } | |
| } | |
| }, | |
| "Runtime": "java8", | |
| "MemorySize": 512, | |
| "Timeout": 300 | |
| }, | |
| "DependsOn": "ProcessorLambdaRole" | |
| }, | |
| "ProjectorLambda": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "FunctionName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_projector" | |
| }, | |
| "Handler": "com.meteogroup.nautical.projector.infrastructure.aws.lambda.ProjectorRequestHandler", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "ProjectorLambdaRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Code": { | |
| "S3Bucket": { | |
| "Ref": "S3JarBucket" | |
| }, | |
| "S3Key": { | |
| "Fn::Sub": "nautical-${Namespace}/projector/nautical-service-projector-1.0-SNAPSHOT.jar" | |
| } | |
| }, | |
| "Environment": { | |
| "Variables": { | |
| "dynamodb_table_name": { | |
| "Fn::Sub": "nautical-weather-situation-${Namespace}" | |
| } | |
| } | |
| }, | |
| "Runtime": "java8", | |
| "MemorySize": 256, | |
| "Timeout": 300 | |
| }, | |
| "DependsOn": "ProjectorLambdaRole" | |
| }, | |
| "ApiLambda": { | |
| "Type": "AWS::Lambda::Function", | |
| "Properties": { | |
| "FunctionName": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_api" | |
| }, | |
| "Handler": "com.meteogroup.nautical.api.infrastructure.aws.lambda.ApiRequestHandler", | |
| "Role": { | |
| "Fn::GetAtt": [ | |
| "ApiLambdaRole", | |
| "Arn" | |
| ] | |
| }, | |
| "Code": { | |
| "S3Bucket": { | |
| "Ref": "S3JarBucket" | |
| }, | |
| "S3Key": { | |
| "Fn::Sub": "nautical-${Namespace}/api/nautical-service-api-1.0-SNAPSHOT.jar" | |
| } | |
| }, | |
| "Environment": { | |
| "Variables": { | |
| "dynamodb_table_name": { | |
| "Fn::Sub": "nautical-weather-situation-${Namespace}" | |
| }, | |
| "degree_precision": { | |
| "Ref": "DegreePrecision" | |
| } | |
| } | |
| }, | |
| "Runtime": "java8", | |
| "MemorySize": 1536, | |
| "Timeout": 60 | |
| }, | |
| "DependsOn": "ApiLambdaRole" | |
| }, | |
| "RestApi": { | |
| "Type": "AWS::ApiGateway::RestApi", | |
| "Properties": { | |
| "Name": { | |
| "Fn::Sub": "net_meteogroup_mg-nautical-${Namespace}_api" | |
| } | |
| } | |
| }, | |
| "BucketLambdaPermission": { | |
| "Type": "AWS::Lambda::Permission", | |
| "Properties": { | |
| "Action": "lambda:invokeFunction", | |
| "FunctionName": { | |
| "Fn::GetAtt": [ | |
| "ProcessorLambda", | |
| "Arn" | |
| ] | |
| }, | |
| "Principal": "s3.amazonaws.com", | |
| "SourceArn": { | |
| "Fn::Sub": "arn:aws:s3:::svc.mg.mg-nautical.${Namespace}.s3.mg" | |
| } | |
| } | |
| }, | |
| "RestApiLambdaPermission": { | |
| "Type": "AWS::Lambda::Permission", | |
| "Properties": { | |
| "Action": "lambda:invokeFunction", | |
| "FunctionName": { | |
| "Fn::GetAtt": [ | |
| "ApiLambda", | |
| "Arn" | |
| ] | |
| }, | |
| "Principal": "apigateway.amazonaws.com", | |
| "SourceArn": { | |
| "Fn::Sub": "arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${RestApi}/*" | |
| } | |
| } | |
| }, | |
| "ProxyResource": { | |
| "Type": "AWS::ApiGateway::Resource", | |
| "Properties": { | |
| "RestApiId": { | |
| "Ref": "RestApi" | |
| }, | |
| "ParentId": { | |
| "Fn::GetAtt": [ | |
| "RestApi", | |
| "RootResourceId" | |
| ] | |
| }, | |
| "PathPart": "{proxy+}" | |
| } | |
| }, | |
| "ProxyMethod": { | |
| "Type": "AWS::ApiGateway::Method", | |
| "Properties": { | |
| "RestApiId": { | |
| "Ref": "RestApi" | |
| }, | |
| "ResourceId": { | |
| "Ref": "ProxyResource" | |
| }, | |
| "HttpMethod": "ANY", | |
| "AuthorizationType": "NONE", | |
| "Integration": { | |
| "Type": "AWS_PROXY", | |
| "IntegrationHttpMethod": "POST", | |
| "PassthroughBehavior": "NEVER", | |
| "Uri": { | |
| "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}/invocations" | |
| } | |
| } | |
| } | |
| }, | |
| "Deployment": { | |
| "Type": "AWS::ApiGateway::Deployment", | |
| "Properties": { | |
| "RestApiId": { | |
| "Ref": "RestApi" | |
| } | |
| }, | |
| "DependsOn": [ | |
| "ProxyMethod" | |
| ] | |
| }, | |
| "Stage": { | |
| "Type": "AWS::ApiGateway::Stage", | |
| "Properties": { | |
| "StageName": "v1", | |
| "RestApiId": { | |
| "Ref": "RestApi" | |
| }, | |
| "DeploymentId": { | |
| "Ref": "Deployment" | |
| }, | |
| "Variables": { | |
| "env": { | |
| "Ref": "Namespace" | |
| } | |
| }, | |
| "MethodSettings": [ | |
| ] | |
| } | |
| } | |
| }, | |
| "Outputs": { | |
| "ApiId": { | |
| "Value": { | |
| "Ref": "RestApi" | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment