Created
July 28, 2017 19:13
-
-
Save catvec/f4a8bced6ca510a44746e3e6aafed99d 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": { | |
"GithubRepoOwner": { | |
"Type": "String", | |
"Description": "Owner of Github repository", | |
"Default": "ROODAY" | |
}, | |
"GithubRepoName": { | |
"Type": "String", | |
"Description": "Name of Github repository", | |
"Default": "Nike-Filter" | |
}, | |
"GithubRepoBranch": { | |
"Type": "String", | |
"Description": "Github repository branch to build and deploy", | |
"Default": "Master" | |
}, | |
"GithubToken": { | |
"Type": "String", | |
"Description": "Github OAuth token to authenticate with when checking out the source repository", | |
"NoEcho": true | |
}, | |
"AWSAppOwner": { | |
"Type": "String", | |
"Description": "Name of application owner to be used in AWS identifiers", | |
"AllowedPattern": "^[a-z]*$", | |
"ConstraintDescription": "must only contain lowercase letters ([a-z])" | |
}, | |
"AWSAppBranch": { | |
"Type": "String", | |
"Description": "Name of branch to be used in AWS identifiers", | |
"AllowedPattern": "^[a-z-]*$", | |
"ConstraintDescription": "must only contain lowercase letters ([a-z])" | |
}, | |
"AppName": { | |
"Type": "String", | |
"Description": "Name of application in repo to run, should be directory with identical name in repo", | |
"AllowedPattern": "(filter|admin)", | |
"ConstraintDescription": "must be only \"filter\" or \"admin\"" | |
}, | |
"AppDatabasePassword": { | |
"Type": "String", | |
"Description": "Password for application database", | |
"NoEcho": true | |
}, | |
"AppFilterUrl": { | |
"Type": "String", | |
"Description": "Url for Iris Filter service, leave blank if deploying Filter service", | |
"Default": "" | |
}, | |
"AppAdminUrl": { | |
"Type": "String", | |
"Description": "Url for Iris Admin service, leave blank if deploying Admin service", | |
"Default": "" | |
}, | |
"AppGAPIClientEmail": { | |
"Type": "String", | |
"Description": "Google API Key Client Email, leave blank if deploying Admin service", | |
"Default": "" | |
}, | |
"AppGAPIPrivateKey": { | |
"Type": "String", | |
"Description": "Google API Private Key, leave blank if deploying Admin service", | |
"Default": "" | |
} | |
}, | |
"Resources": { | |
"PipelineArtifactStore": { | |
"Type": "AWS::S3::Bucket", | |
"Properties": { | |
"BucketName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"s3.build.artifacts.codepipeline.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName"}, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"AccessControl": "Private" | |
} | |
}, | |
"AppPipelineServiceRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"RoleName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iam.codepipeline.servicerole.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "codepipeline.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/AWSCodePipelineFullAccess", | |
"arn:aws:iam::aws:policy/AmazonS3FullAccess", | |
"arn:aws:iam::aws:policy/AWSCodeBuildAdminAccess", | |
"arn:aws:iam::aws:policy/AWSLambdaFullAccess" | |
], | |
"Policies": [ | |
{ | |
"PolicyName": "CloudFormationDeployAccess", | |
"PolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "cloudformation:*", | |
"Resource": "*" | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"AppDeployServiceRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"RoleName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iam.cloudformation.servicerole.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "cloudformation.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/AmazonS3FullAccess", | |
"arn:aws:iam::aws:policy/AWSLambdaFullAccess" | |
], | |
"Policies": [ | |
{ | |
"PolicyName": "CloudFormationFullAccess", | |
"PolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "cloudformation:*", | |
"Resource": "*" | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"AppPipeline": { | |
"Type": "AWS::CodePipeline::Pipeline", | |
"Properties": { | |
"Name": { | |
"Fn::Join": [ | |
"", | |
[ | |
"codepipeline.build.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"ArtifactStore": { | |
"Location": { | |
"Ref": "PipelineArtifactStore" | |
}, | |
"Type": "S3" | |
}, | |
"RestartExecutionOnUpdate": true, | |
"RoleArn": { "Fn::GetAtt": [ "AppPipelineServiceRole", "Arn" ] }, | |
"Stages": [ | |
{ | |
"Name": "Source", | |
"Actions": [ | |
{ | |
"Name": "Github-Source", | |
"ActionTypeId": { | |
"Category": "Source", | |
"Owner": "ThirdParty", | |
"Provider": "GitHub", | |
"Version": "1" | |
}, | |
"Configuration": { | |
"Owner": { "Ref": "GithubRepoOwner" }, | |
"Repo": { "Ref": "GithubRepoName" }, | |
"Branch": { "Ref": "GithubRepoBranch" }, | |
"OAuthToken": { "Ref": "GithubToken" } | |
}, | |
"OutputArtifacts": [ | |
{ | |
"Name": "SourceOutput" | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"Name": "Build", | |
"Actions": [ | |
{ | |
"Name": "CodeBuild-Build", | |
"ActionTypeId": { | |
"Category": "Build", | |
"Owner": "AWS", | |
"Provider": "CodeBuild", | |
"Version": "1" | |
}, | |
"InputArtifacts": [ | |
{ | |
"Name": "SourceOutput" | |
} | |
], | |
"Configuration": { | |
"ProjectName": { "Ref": "AppBuild" } | |
}, | |
"OutputArtifacts": [ | |
{ | |
"Name": "BuildOutput" | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"Name": "Deploy-Staging", | |
"Actions": [ | |
{ | |
"Name": "CloudWatch-Create", | |
"ActionTypeId": { | |
"Category": "Deploy", | |
"Owner": "AWS", | |
"Provider": "CloudFormation", | |
"Version": "1" | |
}, | |
"InputArtifacts": [ | |
{ | |
"Name": "BuildOutput" | |
} | |
], | |
"Configuration": { | |
"ActionMode": "CHANGE_SET_REPLACE", | |
"RoleArn": { "Fn::GetAtt": [ "AppDeployServiceRole", "Arn" ] }, | |
"StackName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"cloudformation-build-stack", | |
{ "Ref": "AWSAppOwner" }, | |
"-iris-", | |
{ "Ref": "AppName" }, | |
"-", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"ChangeSetName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"cloudformation-build-changeset-", | |
{ "Ref": "AWSAppOwner" }, | |
"-iris-", | |
{ "Ref": "AppName" }, | |
"-", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"Capabilities": "CAPABILITY_NAMED_IAM", | |
"ParameterOverrides": "{ \"StageName\": \"staging\"}", | |
"TemplateConfiguration": "BuildOutput::TemplateConfiguration.auto.json", | |
"TemplatePath": "BuildOutput::StackTemplate.auto.yml" | |
}, | |
"RunOrder": 1 | |
}, | |
{ | |
"Name": "CloudWatch-Exec", | |
"ActionTypeId": { | |
"Category": "Deploy", | |
"Owner": "AWS", | |
"Provider": "CloudFormation", | |
"Version": "1" | |
}, | |
"InputArtifacts": [ | |
{ | |
"Name": "BuildOutput" | |
} | |
], | |
"Configuration": { | |
"ActionMode": "CHANGE_SET_EXECUTE", | |
"RoleArn": { "Fn::GetAtt": [ "AppDeployServiceRole", "Arn" ] }, | |
"StackName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"cloudformation-build-stack", | |
{ "Ref": "AWSAppOwner" }, | |
"-iris-", | |
{ "Ref": "AppName" }, | |
"-", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"ChangeSetName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"cloudformation-build-changeset-", | |
{ "Ref": "AWSAppOwner" }, | |
"-iris-", | |
{ "Ref": "AppName" }, | |
"-", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
} | |
}, | |
"RunOrder": 2 | |
} | |
] | |
} | |
] | |
} | |
}, | |
"AppBuildServiceRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"RoleName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iam.codebuild.servicerole.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "codebuild.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/AWSCodeBuildAdminAccess", | |
"arn:aws:iam::aws:policy/CloudWatchFullAccess", | |
"arn:aws:iam::aws:policy/AmazonS3FullAccess" | |
] | |
} | |
}, | |
"AppBuild": { | |
"Type": "AWS::CodeBuild::Project", | |
"Properties": { | |
"Name": { | |
"Fn::Join": [ | |
"", | |
[ | |
"codebuild_build_", | |
{ "Ref": "AWSAppOwner" }, | |
"_iris_", | |
{ "Ref": "AppName" }, | |
"_", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"Description": "Builds AWS Serverless application for deployment", | |
"Artifacts": { | |
"Type": "CODEPIPELINE" | |
}, | |
"Environment": { | |
"ComputeType": "BUILD_GENERAL1_LARGE", | |
"Image": "aws/codebuild/nodejs:7.0.0", | |
"Type": "LINUX_CONTAINER", | |
"EnvironmentVariables": [ | |
{ | |
"Name": "CF_S3_BUCKET_NAME", | |
"Value": { | |
"Fn::Join": [ | |
"", | |
[ | |
"s3.build.artifacts.codepipeline.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName"}, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
} | |
}, | |
{ | |
"Name": "APP_NAME", | |
"Value": { "Ref": "AppName" } | |
}, | |
{ | |
"Name": "AWS_APP_OWNER", | |
"Value": { "Ref": "AWSAppOwner" } | |
}, | |
{ | |
"Name": "AWS_APP_BRANCH", | |
"Value": { "Ref": "AWSAppBranch" } | |
}, | |
{ | |
"Name": "APP_DATABASE_PASSWORD", | |
"Value": { "Ref": "AppDatabasePassword" } | |
}, | |
{ | |
"Name": "APP_FILTER_URL", | |
"Value": { "Ref": "AppFilterUrl" } | |
}, | |
{ | |
"Name": "APP_ADMIN_URL", | |
"Value": { "Ref": "AppAdminUrl" } | |
}, | |
{ | |
"Name": "APP_GAPI_CLIENT_EMAIL", | |
"Value": { "Ref": "AppGAPIClientEmail" } | |
}, | |
{ | |
"Name": "APP_GAPI_PRIVATE_KEY", | |
"Value": { "Ref": "AppGAPIPrivateKey" } | |
} | |
] | |
}, | |
"ServiceRole": { "Ref": "AppBuildServiceRole" }, | |
"Source": { | |
"Type": "CODEPIPELINE" | |
} | |
} | |
} | |
} | |
} |
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", | |
"Transform": "AWS::Serverless-2016-10-31", | |
"Description": "CloudFormation template to host a Serverless application", | |
"Parameters": { | |
"AppName": { | |
"Type": "String", | |
"Description": "Name of application in repo to run, should be directory with identical name in repo", | |
"AllowedPattern": "^[a-z]*$", | |
"ConstraintDescription": "must only container lowercase letters ([a-z])" }, | |
"StageName": { | |
"Type": "String", | |
"Description": "Which stage in deployment pipeline this stack is", | |
"AllowedPattern": "(development|staging|master)", | |
"ConstraintDescription": "must be one of \"development\", \"staging\" or \"master\"" | |
}, | |
"AWSAppOwner": { | |
"Type": "String", | |
"Description": "Name of application owner to be used in AWS identifiers", | |
"AllowedPattern": "^[a-z]*$", | |
"ConstraintDescription": "must only contain lowercase letters ([a-z])" | |
}, | |
"AWSAppBranch": { | |
"Type": "String", | |
"Description": "Name of branch to be used in AWS identifiers", | |
"AllowedPattern": "^[a-z-]*$", | |
"ConstraintDescription": "must only contain lowercase letters ([a-z])" | |
}, | |
"AppDatabasePassword": { | |
"Type": "String", | |
"Description": "Password for application database", | |
"NoEcho": true | |
}, | |
"AppFilterUrl": { | |
"Type": "String", | |
"Description": "Url for Iris Filter service, leave blank if deploying Filter service", | |
"Default": "" | |
}, | |
"AppAdminUrl": { | |
"Type": "String", | |
"Description": "Url for Iris Admin service, leave blank if deploying Admin service", | |
"Default": "" | |
}, | |
"AppSelfUrl": { | |
"Type": "String", | |
"Description": "Url of service you are currently deploying" | |
}, | |
"AppGAPIClientEmail": { | |
"Type": "String", | |
"Description": "Google API Key Client Email, leave blank if deploying Admin service", | |
"Default": "" | |
}, | |
"AppGAPIPrivateKey": { | |
"Type": "String", | |
"Description": "Google API Private Key, leave blank if deploying Admin service", | |
"Default": "" | |
} | |
}, | |
"Resources": { | |
"AppServiceRole": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"RoleName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iam.lambda.servicerole.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
}, | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "rds.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
}, | |
"ManagedPolicyArns": [ | |
"arn:aws:iam::aws:policy/AWSLambdaExecute", | |
"arn:aws:iam::aws:policy/CloudWatchFullAccess" | |
] | |
} | |
}, | |
"AppVpc": { | |
"Type": "AWS::EC2::VPC", | |
"Properties": { | |
"CidrBlock": "10.0.0.0/16", | |
"EnableDnsHostnames": true | |
} | |
}, | |
"AppNatElasticIp": { | |
"Type": "AWS::EC2::EIP", | |
"Properties": { | |
"Domain": "vpc" | |
} | |
}, | |
"AppNatGateway": { | |
"Type": "AWS::EC2::NatGateway", | |
"Properties": { | |
"AllocationId": { | |
"Fn::GetAtt": [ "AppNatElasticIp", "AllocationId" ] | |
}, | |
"SubnetId": { "Ref": "AppExternalSubnet" } | |
} | |
}, | |
"AppInternetGateway": { | |
"Type": "AWS::EC2::InternetGateway" | |
}, | |
"AppInternetGatewayAttachment": { | |
"Type": "AWS::EC2::VPCGatewayAttachment", | |
"Properties": { | |
"VpcId": { "Ref": "AppVpc" }, | |
"InternetGatewayId": { "Ref": "AppInternetGateway" } | |
} | |
}, | |
"AppInternalRouteTable": { | |
"Type": "AWS::EC2::RouteTable", | |
"Properties": { | |
"VpcId": { "Ref": "AppVpc" } | |
} | |
}, | |
"AppExternalRouteTable": { | |
"Type": "AWS::EC2::RouteTable", | |
"Properties": { | |
"VpcId": { "Ref": "AppVpc" } | |
} | |
}, | |
"AppInternalRouteTableAssociation": { | |
"Type": "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties": { | |
"RouteTableId": { "Ref": "AppInternalRouteTable" }, | |
"SubnetId": { "Ref": "AppInternalSubnet" } | |
} | |
}, | |
"AppExternalRouteTableAssociation": { | |
"Type": "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties": { | |
"RouteTableId": { "Ref": "AppExternalRouteTable" }, | |
"SubnetId": { "Ref": "AppExternalSubnet" } | |
} | |
}, | |
"AppInternalToNatRoute": { | |
"Type": "AWS::EC2::Route", | |
"Properties": { | |
"RouteTableId": { "Ref": "AppInternalRouteTable" }, | |
"DestinationCidrBlock": "0.0.0.0/0", | |
"NatGatewayId": { "Ref": "AppNatGateway" } | |
} | |
}, | |
"AppExternalToInternetGatewayRoute": { | |
"Type": "AWS::EC2::Route", | |
"Properties": { | |
"RouteTableId": { "Ref": "AppExternalRouteTable" }, | |
"DestinationCidrBlock": "0.0.0.0/0", | |
"GatewayId": { "Ref": "AppInternetGateway" } | |
} | |
}, | |
"AppExternalSubnet": { | |
"Type": "AWS::EC2::Subnet", | |
"Properties": { | |
"CidrBlock": "10.0.0.0/24", | |
"MapPublicIpOnLaunch": true, | |
"VpcId": { "Ref": "AppVpc" } | |
} | |
}, | |
"AppInternalSubnet": { | |
"Type": "AWS::EC2::Subnet", | |
"Properties": { | |
"CidrBlock": "10.0.1.0/24", | |
"MapPublicIpOnLaunch": false, | |
"VpcId": { "Ref": "AppVpc" } | |
} | |
}, | |
"AppServiceSecurityGroup": { | |
"Type": "AWS::EC2::SecurityGroup", | |
"Properties": { | |
"GroupName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"ec2.securitygroup.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"GroupDescription": { | |
"Fn::Join": [ | |
"", | |
[ | |
"EC2 Security Group for iris ", | |
{ "Ref": "AppName" }, | |
" service network traffic, branch ", | |
{ "Ref": "AWSAppBranch" }, | |
" owned by ", | |
{ "Ref": "AWSAppOwner" } | |
] | |
] | |
}, | |
"SecurityGroupIngress": [ | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "443", | |
"ToPort": "443", | |
"CidrIp": "0.0.0.0/0,::/0" | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "80", | |
"ToPort": "80", | |
"CidrIp": "0.0.0.0/0,::0/" | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "22", | |
"ToPort": "22", | |
"CidrIp": "0.0.0.0/0,::0/" | |
} | |
], | |
"SecurityGroupEgress": [ | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "443", | |
"ToPort": "443", | |
"CidrIp": "0.0.0.0/0,::/0" | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "80", | |
"ToPort": "80", | |
"CidrIp": "0.0.0.0/0,::0/" | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "22", | |
"ToPort": "22", | |
"CidrIp": "0.0.0.0/0,::0/" | |
} | |
] | |
} | |
}, | |
"AppDatabaseSecurityGroup": { | |
"Type": "AWS::EC2::SecurityGroup", | |
"Properties": { | |
"GroupName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"ec2.securitygroup.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"GroupDescription": { | |
"Fn::Join": [ | |
"", | |
[ | |
"EC2 Security Group for private internal iris ", | |
{ "Ref": "AppName" }, | |
" service network traffic, branch ", | |
{ "Ref": "AWSAppBranch" }, | |
" owned by ", | |
{ "Ref": "AWSAppOwner" } | |
] | |
] | |
}, | |
"SecurityGroupIngress": [ | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "5432", | |
"ToPort": "5432", | |
"SourceSecurityGroupId": { "Ref": "AppServiceSecurityGroup" } | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "22", | |
"ToPort": "22", | |
"SourceSecurityGroupId": { "Ref": "AppServiceSecurityGroup" } | |
} | |
], | |
"SecurityGroupEgress": [ | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "5432", | |
"ToPort": "5432", | |
"SourceSecurityGroupId": { "Ref": "AppServiceSecurityGroup" } | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "22", | |
"ToPort": "22", | |
"SourceSecurityGroupId": { "Ref": "AppServiceSecurityGroup" } | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "443", | |
"ToPort": "443", | |
"CidrIp": "0.0.0.0/0,::/0" | |
}, | |
{ | |
"IpProtocol": "tcp", | |
"FromPort": "80", | |
"ToPort": "80", | |
"CidrIp": "0.0.0.0/0,::0/" | |
} | |
] | |
} | |
}, | |
"AppDatabaseSubnetGroup": { | |
"Type": "AWS::RDS::DBSubnetGroup", | |
"Properties": { | |
"DBSubnetGroupDescription": { | |
"Fn::Join": [ | |
"", | |
[ | |
"RDS DB Subnet Group for iris ", | |
{ "Ref": "AppName" }, | |
" database network traffic, branch ", | |
{ "Ref": "AWSAppBranch" }, | |
" owned by ", | |
{ "Ref": "AWSAppOwner" } | |
] | |
] | |
}, | |
"SubnetIds": [ | |
{ "Ref": "AppInternalSubnet" } | |
] | |
} | |
}, | |
"AppDatabase": { | |
"Type": "AWS::RDS::DBInstance", | |
"Properties": { | |
"AllocatedStorage": "10", | |
"BackupRetentionPeriod": "90", | |
"DBInstanceClass": "db.m4.large", | |
"DBInstanceIdentifier": { | |
"Fn::Join": [ | |
"", | |
[ | |
"rds.lambda.", | |
{ "Ref": "AWSAppOwner" }, | |
".iris.", | |
{ "Ref": "AppName" }, | |
".", | |
{ "Ref": "AWSAppBranch" } | |
] | |
] | |
}, | |
"DBName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iris_", | |
{ "Ref": "AppName" }, | |
"_production_", | |
{ "Ref": "StageName" } | |
] | |
] | |
}, | |
"Engine": "postgres", | |
"EngineVersion": "9.6.2", | |
"MasterUsername": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iris_", | |
{ "Ref": "AppName" }, | |
"_production_", | |
{ "Ref": "StageName" } | |
] | |
] | |
}, | |
"MasterUserPassword": { "Ref": "AppDatabasePassword" }, | |
"MonitoringRoleArn": { "Fn::GetAtt": [ "AppServiceRole", "Arn" ] }, | |
"MonitoringInterval": 10, | |
"Port": "5432", | |
"DBSubnetGroupName": { "Ref": "AppDatabaseSubnetGroup" }, | |
"VPCSecurityGroups": [ | |
{ "Ref": "AppDatabaseSecurityGroup" } | |
] | |
} | |
}, | |
"AppFunction": { | |
"Type": "AWS::Serverless::Function", | |
"Properties": { | |
"Handler": { | |
"Fn::Join": [ | |
"", | |
[ | |
{ "Ref": "AppName" }, | |
".lambda.handler" | |
] | |
] | |
}, | |
"Runtime": "nodejs6.10", | |
"CodeUri": "../", | |
"FunctionName": { | |
"Fn::Join": [ | |
"", | |
[ | |
"/lambda/app/", | |
{ | |
"Ref": "AppName" | |
} | |
] | |
] | |
}, | |
"Description": { | |
"Fn::Join": [ | |
"", | |
[ | |
"Lambda function which runs the ", | |
{ | |
"Ref": "AppName" | |
}, | |
" service" | |
] | |
] | |
}, | |
"MemorySize": 128, | |
"Timeout": 4, | |
"Role": { | |
"Fn::GetAtt": [ | |
"AppServiceRole", | |
"Arn" | |
] | |
}, | |
"Environment": { | |
"Variables": { | |
"NODE_ENV": "production", | |
"DB_HOST": { | |
"Fn::GetAtt": [ | |
"AppDatabase", | |
"Endpoint.Address" | |
] | |
}, | |
"DB_NAME": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iris_", | |
{ | |
"Ref": "AppName" | |
}, | |
"_production_", | |
{ | |
"Ref": "StageName" | |
} | |
] | |
] | |
}, | |
"DB_USER": { | |
"Fn::Join": [ | |
"", | |
[ | |
"iris_", | |
{ | |
"Ref": "AppName" | |
}, | |
"_production_", | |
{ | |
"Ref": "StageName" | |
} | |
] | |
] | |
}, | |
"DB_PASSWORD": { | |
"Ref": "AppDatabasePassword" | |
}, | |
"APP_PORT": 443, | |
"FILTER_URL": { | |
"Ref": "AppFilterUrl" | |
}, | |
"ADMIN_URL": { | |
"Ref": "AppAdminUrl" | |
}, | |
"SELF_URL": { | |
"Ref": "AppSelfUrl" | |
}, | |
"GAPI_CLIENT_EMAIL": { | |
"Ref": "AppGAPIClientEmail" | |
}, | |
"GAPI_PRIVATE_KEY": { | |
"Ref": "AppGAPIPrivateKey" | |
} | |
} | |
}, | |
"VpcConfig": { | |
"SecurityGroupIds": [ | |
{ "Ref": "AppServiceSecurityGroup" } | |
], | |
"SubnetIds": [ | |
{ "Ref": "AppExternalSubnet" } | |
] | |
} | |
} | |
}, | |
"AppApi": { | |
"Type": "AWS::Serverless:Api", | |
"Properties": { | |
"Name": { | |
"Fn::Join": [ | |
"", | |
[ | |
"/apigateway/app/", | |
{ | |
"Ref": "AppName" | |
} | |
] | |
] | |
}, | |
"StageName": { | |
"Ref": "StageName" | |
}, | |
"DefinitionUri": { | |
"Fn::Join": [ | |
"", | |
[ | |
"./", | |
{ | |
"Ref": "AppName" | |
}, | |
"/swagger.auto.json" | |
] | |
] | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment