Last active
May 4, 2018 09:29
-
-
Save otbe/d31402e8e97586d9ec1daebb72b9f409 to your computer and use it in GitHub Desktop.
Multiregion Deployment Pipeline
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
| Pipeline: | |
| Type: AWS::CodePipeline::Pipeline | |
| Properties: | |
| Name: !Ref 'AWS::StackName' | |
| RoleArn: !GetAtt CodePipelineServiceRole.Arn | |
| ArtifactStore: | |
| Type: S3 | |
| Location: !Ref ArtifactBucket | |
| Stages: | |
| - Name: Source | |
| Actions: # standard S3 source config | |
| - Name: Deployment | |
| Actions: | |
| - Name: PrerenderLambdas | |
| ActionTypeId: | |
| Category: Build | |
| Owner: AWS | |
| Version: 1 | |
| Provider: CodeBuild | |
| Configuration: | |
| ProjectName: !Ref CodeBuildProjectUpdatePrerender | |
| InputArtifacts: | |
| - Name: Source | |
| OutputArtifacts: | |
| - Name: PrerenderOutput | |
| RunOrder: 1 | |
| - Name: Cloudformation | |
| ActionTypeId: | |
| Category: Build | |
| Owner: AWS | |
| Version: 1 | |
| Provider: CodeBuild | |
| Configuration: | |
| ProjectName: !Ref CodeBuildProjectCloudfront | |
| InputArtifacts: | |
| - Name: PrerenderOutput | |
| OutputArtifacts: | |
| - Name: CloudformationOutput | |
| RunOrder: 2 | |
| - Name: UploadRelease | |
| ActionTypeId: | |
| Category: Build | |
| Owner: AWS | |
| Version: 1 | |
| Provider: CodeBuild | |
| Configuration: | |
| ProjectName: !Ref CodeBuildProjectRelease | |
| InputArtifacts: | |
| - Name: CloudformationOutput | |
| RunOrder: 3 |
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
| service: | |
| name: cloudfront | |
| provider: | |
| name: aws | |
| runtime: nodejs6.10 | |
| region: eu-central-1 | |
| stage: ${opt:stage, 'stack'} | |
| plugins: | |
| - serverless-offline | |
| - serverless-webpack | |
| - serverless-stack-output | |
| custom: | |
| webpackIncludeModules: true | |
| output: | |
| file: stack-output.json | |
| functions: | |
| resources: | |
| Resources: | |
| CloudfrontBucket: | |
| Type: AWS::S3::Bucket | |
| CloudfrontOAI: | |
| Type: AWS::CloudFront::CloudFrontOriginAccessIdentity | |
| Properties: | |
| CloudFrontOriginAccessIdentityConfig: | |
| Comment: Cloudfront MWU OAI | |
| CloudfrontBucketPolicy: | |
| Type: AWS::S3::BucketPolicy | |
| Properties: | |
| Bucket: | |
| Ref: CloudfrontBucket | |
| PolicyDocument: | |
| Statement: | |
| - Action: | |
| - s3:GetObject | |
| Effect: Allow | |
| Resource: | |
| Fn::Join: | |
| - '' | |
| - - Fn::GetAtt: | |
| - CloudfrontBucket | |
| - Arn | |
| - "/*" | |
| Principal: | |
| CanonicalUser: | |
| Fn::GetAtt: | |
| - CloudfrontOAI | |
| - S3CanonicalUserId | |
| CloudfrontDistribution: | |
| Type: AWS::CloudFront::Distribution | |
| Properties: | |
| DistributionConfig: | |
| DefaultCacheBehavior: | |
| Compress: true | |
| DefaultTTL: 86400 | |
| MinTTL: 86400 | |
| MaxTTL: 2592000 | |
| ForwardedValues: | |
| QueryString: true | |
| Cookies: | |
| Forward: none | |
| TargetOriginId: | |
| Ref: CloudfrontBucket | |
| ViewerProtocolPolicy: 'redirect-to-https' | |
| LambdaFunctionAssociations: | |
| - EventType: viewer-request | |
| LambdaFunctionARN: ${env:ViewerRequestLambdaLambdaFunctionQualifiedArn} | |
| - EventType: origin-request | |
| LambdaFunctionARN: ${env:OriginRequestLambdaLambdaFunctionQualifiedArn} | |
| DefaultRootObject: 'index.html' | |
| Enabled: true | |
| HttpVersion: 'http2' | |
| IPV6Enabled: true | |
| Origins: | |
| - Id: | |
| Ref: CloudfrontBucket | |
| DomainName: | |
| Fn::GetAtt: [CloudfrontBucket, DomainName] | |
| S3OriginConfig: | |
| OriginAccessIdentity: | |
| Fn::Join: | |
| - '/' | |
| - - origin-access-identity | |
| - cloudfront | |
| - Ref: | |
| CloudfrontOAI | |
| PriceClass: 'PriceClass_100' | |
| Outputs: | |
| CloudfrontBucketName: | |
| Value: | |
| Ref: CloudfrontBucket | |
| CloudfrontDistId: | |
| Value: | |
| Ref: CloudfrontDistribution | |
| InvalidateCacheFunctionArn: | |
| Value: | |
| Fn::GetAtt: [InvalidateCacheLambdaFunction, Arn] |
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
| service: | |
| name: prerender-lambdas | |
| plugins: | |
| - serverless-webpack | |
| - serverless-stack-output | |
| provider: | |
| name: aws | |
| runtime: nodejs6.10 | |
| region: us-east-1 | |
| memorySize: 128 | |
| role: LambdaEdgeRole | |
| custom: | |
| webpack: | |
| packager: yarn | |
| includeModules: true | |
| output: | |
| file: stack-output.json | |
| functions: | |
| viewerRequestLambda: | |
| handler: src/index.viewerRequestApi | |
| timeout: 5 | |
| originRequestLambda: | |
| handler: src/index.originRequestApi | |
| timeout: 30 | |
| resources: | |
| Resources: | |
| LambdaEdgeRole: | |
| Type: AWS::IAM::Role | |
| Properties: | |
| AssumeRolePolicyDocument: | |
| Statement: | |
| - Effect: Allow | |
| Principal: | |
| Service: | |
| - edgelambda.amazonaws.com | |
| - lambda.amazonaws.com | |
| Action: | |
| - sts:AssumeRole | |
| Policies: | |
| - PolicyName: LambdaEdgeExecutionRole | |
| PolicyDocument: | |
| Version: "2012-10-17" | |
| Statement: | |
| - Effect: Allow | |
| Action: | |
| - logs:CreateLogGroup | |
| - logs:CreateLogStream | |
| - logs:PutLogEvents | |
| Resource: "arn:aws:logs:*:*:*" |
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
| const path = require('path'); | |
| const slsw = require('serverless-webpack'); | |
| const nodeExternals = require('webpack-node-externals'); | |
| const Dotenv = require('dotenv-webpack'); | |
| module.exports = { | |
| entry: slsw.lib.entries, | |
| resolve: { | |
| extensions: ['.js', '.json'] | |
| }, | |
| output: { | |
| libraryTarget: 'commonjs', | |
| path: path.join(__dirname, '.webpack'), | |
| filename: '[name].js' | |
| }, | |
| target: 'node', | |
| externals: [nodeExternals()], | |
| plugins: [ | |
| new Dotenv({ | |
| path: `../.my.env`, | |
| silent: false | |
| }) | |
| ], | |
| module: { | |
| rules: [ | |
| { | |
| test: /\.js$/, | |
| exclude: /node_modules/, | |
| use: [ | |
| { | |
| loader: 'babel-loader' | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment