├── .gitignore ├── s3-app-linux.zip ├── images └── multiregion-codepipeline.jpg ├── .github └── PULL_REQUEST_TEMPLATE.md ├── CODE_OF_CONDUCT.md ├── cfn-templates ├── source-bucket-creation.yaml ├── cross-region-artifact-store-creation.yaml ├── code-deploy │ ├── codedeploy-us-east-1.json │ ├── codedeploy-us-west-2.json │ └── codedeploy-ap-southeast-2.json └── cross-region-code-pipeline.yaml ├── README.md ├── LICENSE └── CONTRIBUTING.md /.gitignore: -------------------------------------------------------------------------------- 1 | # file: ~/.gitignore_global 2 | .DS_Store 3 | .idea 4 | .iml -------------------------------------------------------------------------------- /s3-app-linux.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/HEAD/s3-app-linux.zip -------------------------------------------------------------------------------- /images/multiregion-codepipeline.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/HEAD/images/multiregion-codepipeline.jpg -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 7 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /cfn-templates/source-bucket-creation.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | Description: > 3 | This template creates a resources for test, like artifact bucket, service role, webhook pipeline and test webhook. 4 | Parameters: 5 | SourceCodeBucketNamePrefix: 6 | Type: String 7 | Resources: 8 | SourceCodeS3Bucket: 9 | Type: "AWS::S3::Bucket" 10 | Properties: 11 | VersioningConfiguration: 12 | Status: Enabled 13 | BucketName: !Join [-, [source-code-bucket, !Ref "AWS::Region", !Ref SourceCodeBucketNamePrefix]] 14 | LifecycleConfiguration: 15 | Rules: 16 | - Status: "Enabled" 17 | ExpirationInDays : "1" 18 | -------------------------------------------------------------------------------- /cfn-templates/cross-region-artifact-store-creation.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | Description: > 3 | This template creates a resources for test, like artifact bucket, service role, webhook pipeline and test webhook. 4 | Parameters: 5 | ArtifactStoreBucketNamePrefix: 6 | Type: String 7 | Resources: 8 | TestCrossRegionArtifactStoreS3Bucket: 9 | Type: "AWS::S3::Bucket" 10 | Properties: 11 | VersioningConfiguration: 12 | Status: Enabled 13 | BucketName: !Join [-, [cross-region-artifact-store-bucket, !Ref "AWS::Region", !Ref ArtifactStoreBucketNamePrefix]] 14 | LifecycleConfiguration: 15 | Rules: 16 | - Status: "Enabled" 17 | ExpirationInDays : "1" 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## License Summary 2 | 3 | This sample code is made available under a modified MIT license. See the LICENSE file. 4 | 5 | ## Reference Architecture: Multi Region Deployment using AWS CodePipeline 6 | 7 | This reference architecture demonstrates how to use a single [AWS CodePipeline](https://aws.amazon.com/codepipeline/) in 8 | one of your primary regions to deploy application to multiple secondary regions to improve both latency and availability 9 | of your application. This orchestration of code movement from code checkin to deployment is securely handled 10 | by [AWS CodePipeline](https://aws.amazon.com/codepipeline/). 11 | 12 | ## Deployment Architecture 13 | ![](https://github.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/blob/master/images/multiregion-codepipeline.jpg) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this 4 | software and associated documentation files (the "Software"), to deal in the Software 5 | without restriction, including without limitation the rights to use, copy, modify, 6 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 7 | permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 10 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 11 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 12 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 13 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 14 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | -------------------------------------------------------------------------------- /cfn-templates/code-deploy/codedeploy-us-east-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "Description":"Launch nested CloudFormation stack to provision and run AWS CodeDeploy", 3 | "AWSTemplateFormatVersion":"2010-09-09", 4 | "Parameters":{ 5 | "EC2TagValue":{ 6 | "Description":"The tag value that identifies this as a target for deployments.", 7 | "Type":"String", 8 | "AllowedPattern":"[\\x20-\\x7E]*", 9 | "ConstraintDescription":"Can contain only ASCII characters." 10 | }, 11 | "EC2KeyPairName":{ 12 | "Description":"Name of an existing Amazon EC2 key pair to enable SSH or RDP access to the instances.", 13 | "Type":"AWS::EC2::KeyPair::KeyName", 14 | "MinLength":"1", 15 | "MaxLength":"255", 16 | "AllowedPattern":"[\\x20-\\x7E]*", 17 | "ConstraintDescription":"Can contain only ASCII characters." 18 | }, 19 | "ApplicationName":{ 20 | "Description":"Name of the application in the target group", 21 | "Type":"String", 22 | "AllowedPattern":"[\\x20-\\x7E]*", 23 | "ConstraintDescription":"Can contain only ASCII characters." 24 | }, 25 | "DeploymentGroupName":{ 26 | "Description":"Name of the deployment group that specifies which instances your application revisions are deployed to", 27 | "Type":"String", 28 | "AllowedPattern":"[\\x20-\\x7E]*", 29 | "ConstraintDescription":"Can contain only ASCII characters." 30 | }, 31 | "EC2TagTagKeyName":{ 32 | "Type":"String", 33 | "Default":"Name", 34 | "Description":"The tag name that is associated with EC2 instances on which CodeDeploy agent is installed" 35 | } 36 | }, 37 | "Resources":{ 38 | "CodeDeployEC2InstancesStack":{ 39 | "Type":"AWS::CloudFormation::Stack", 40 | "Properties":{ 41 | "TemplateURL": "http://s3.amazonaws.com/aws-codedeploy-us-east-1/templates/latest/CodeDeploy_SampleCF_Template.json", 42 | "TimeoutInMinutes":"60", 43 | "Parameters":{ 44 | "TagValue":{ 45 | "Ref":"EC2TagValue" 46 | }, 47 | "KeyPairName":{ 48 | "Ref":"EC2KeyPairName" 49 | } 50 | } 51 | } 52 | }, 53 | "MyApplication":{ 54 | "Type":"AWS::CodeDeploy::Application", 55 | "DependsOn":"CodeDeployEC2InstancesStack", 56 | "Properties" : { 57 | "ApplicationName" : { 58 | "Ref":"ApplicationName" 59 | } 60 | } 61 | }, 62 | "MyDeploymentGroup":{ 63 | "Type":"AWS::CodeDeploy::DeploymentGroup", 64 | "DependsOn":"MyApplication", 65 | "Properties":{ 66 | "DeploymentGroupName" : { 67 | "Ref":"DeploymentGroupName" 68 | }, 69 | "ApplicationName":{ 70 | "Ref":"MyApplication" 71 | }, 72 | "Ec2TagFilters":[ 73 | { 74 | "Key":{ 75 | "Ref":"EC2TagTagKeyName" 76 | }, 77 | "Value":{ 78 | "Ref":"EC2TagValue" 79 | }, 80 | "Type":"KEY_AND_VALUE" 81 | } 82 | ], 83 | "ServiceRoleArn":{ 84 | "Fn::GetAtt":[ 85 | "CodeDeployEC2InstancesStack", 86 | "Outputs.CodeDeployTrustRoleARN" 87 | ] 88 | } 89 | } 90 | } 91 | }, 92 | "Outputs":{ 93 | "MyAWSAccountId":{ 94 | "Value":{ 95 | "Ref":"AWS::AccountId" 96 | } 97 | }, 98 | "MyApplication":{ 99 | "Value":{ 100 | "Ref":"MyApplication" 101 | } 102 | }, 103 | "MyDeploymentGroup":{ 104 | "Value":{ 105 | "Ref":"MyDeploymentGroup" 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cfn-templates/code-deploy/codedeploy-us-west-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "Description":"Launch nested CloudFormation stack to provision and run AWS CodeDeploy", 3 | "AWSTemplateFormatVersion":"2010-09-09", 4 | "Parameters":{ 5 | "EC2TagValue":{ 6 | "Description":"The tag value that identifies this as a target for deployments.", 7 | "Type":"String", 8 | "AllowedPattern":"[\\x20-\\x7E]*", 9 | "ConstraintDescription":"Can contain only ASCII characters." 10 | }, 11 | "EC2KeyPairName":{ 12 | "Description":"Name of an existing Amazon EC2 key pair to enable SSH or RDP access to the instances.", 13 | "Type":"AWS::EC2::KeyPair::KeyName", 14 | "MinLength":"1", 15 | "MaxLength":"255", 16 | "AllowedPattern":"[\\x20-\\x7E]*", 17 | "ConstraintDescription":"Can contain only ASCII characters." 18 | }, 19 | "ApplicationName":{ 20 | "Description":"Name of the application in the target group", 21 | "Type":"String", 22 | "AllowedPattern":"[\\x20-\\x7E]*", 23 | "ConstraintDescription":"Can contain only ASCII characters." 24 | }, 25 | "DeploymentGroupName":{ 26 | "Description":"Name of the deployment group that specifies which instances your application revisions are deployed to", 27 | "Type":"String", 28 | "AllowedPattern":"[\\x20-\\x7E]*", 29 | "ConstraintDescription":"Can contain only ASCII characters." 30 | }, 31 | "EC2TagTagKeyName":{ 32 | "Type":"String", 33 | "Default":"Name", 34 | "Description":"The tag name that is associated with EC2 instances on which CodeDeploy agent is installed" 35 | } 36 | }, 37 | "Resources":{ 38 | "CodeDeployEC2InstancesStack":{ 39 | "Type":"AWS::CloudFormation::Stack", 40 | "Properties":{ 41 | "TemplateURL": "http://s3-us-west-2.amazonaws.com/aws-codedeploy-us-west-2/templates/latest/CodeDeploy_SampleCF_Template.json", 42 | "TimeoutInMinutes":"60", 43 | "Parameters":{ 44 | "TagValue":{ 45 | "Ref":"EC2TagValue" 46 | }, 47 | "KeyPairName":{ 48 | "Ref":"EC2KeyPairName" 49 | } 50 | } 51 | } 52 | }, 53 | "MyApplication":{ 54 | "Type":"AWS::CodeDeploy::Application", 55 | "DependsOn":"CodeDeployEC2InstancesStack", 56 | "Properties" : { 57 | "ApplicationName" : { 58 | "Ref":"ApplicationName" 59 | } 60 | } 61 | }, 62 | "MyDeploymentGroup":{ 63 | "Type":"AWS::CodeDeploy::DeploymentGroup", 64 | "DependsOn":"MyApplication", 65 | "Properties":{ 66 | "DeploymentGroupName" : { 67 | "Ref":"DeploymentGroupName" 68 | }, 69 | "ApplicationName":{ 70 | "Ref":"MyApplication" 71 | }, 72 | "Ec2TagFilters":[ 73 | { 74 | "Key":{ 75 | "Ref":"EC2TagTagKeyName" 76 | }, 77 | "Value":{ 78 | "Ref":"EC2TagValue" 79 | }, 80 | "Type":"KEY_AND_VALUE" 81 | } 82 | ], 83 | "ServiceRoleArn":{ 84 | "Fn::GetAtt":[ 85 | "CodeDeployEC2InstancesStack", 86 | "Outputs.CodeDeployTrustRoleARN" 87 | ] 88 | } 89 | } 90 | } 91 | }, 92 | "Outputs":{ 93 | "MyAWSAccountId":{ 94 | "Value":{ 95 | "Ref":"AWS::AccountId" 96 | } 97 | }, 98 | "MyApplication":{ 99 | "Value":{ 100 | "Ref":"MyApplication" 101 | } 102 | }, 103 | "MyDeploymentGroup":{ 104 | "Value":{ 105 | "Ref":"MyDeploymentGroup" 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cfn-templates/code-deploy/codedeploy-ap-southeast-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "Description":"Launch nested CloudFormation stack to provision and run AWS CodeDeploy", 3 | "AWSTemplateFormatVersion":"2010-09-09", 4 | "Parameters":{ 5 | "EC2TagValue":{ 6 | "Description":"The tag value that identifies this as a target for deployments.", 7 | "Type":"String", 8 | "AllowedPattern":"[\\x20-\\x7E]*", 9 | "ConstraintDescription":"Can contain only ASCII characters." 10 | }, 11 | "EC2KeyPairName":{ 12 | "Description":"Name of an existing Amazon EC2 key pair to enable SSH or RDP access to the instances.", 13 | "Type":"AWS::EC2::KeyPair::KeyName", 14 | "MinLength":"1", 15 | "MaxLength":"255", 16 | "AllowedPattern":"[\\x20-\\x7E]*", 17 | "ConstraintDescription":"Can contain only ASCII characters." 18 | }, 19 | "ApplicationName":{ 20 | "Description":"Name of the application in the target group", 21 | "Type":"String", 22 | "AllowedPattern":"[\\x20-\\x7E]*", 23 | "ConstraintDescription":"Can contain only ASCII characters." 24 | }, 25 | "DeploymentGroupName":{ 26 | "Description":"Name of the deployment group that specifies which instances your application revisions are deployed to", 27 | "Type":"String", 28 | "AllowedPattern":"[\\x20-\\x7E]*", 29 | "ConstraintDescription":"Can contain only ASCII characters." 30 | }, 31 | "EC2TagTagKeyName":{ 32 | "Type":"String", 33 | "Default":"Name", 34 | "Description":"The tag name that is associated with EC2 instances on which CodeDeploy agent is installed" 35 | } 36 | }, 37 | "Resources":{ 38 | "CodeDeployEC2InstancesStack":{ 39 | "Type":"AWS::CloudFormation::Stack", 40 | "Properties":{ 41 | "TemplateURL": "http://s3-ap-southeast-2.amazonaws.com/aws-codedeploy-ap-southeast-2/templates/latest/CodeDeploy_SampleCF_Template.json", 42 | "TimeoutInMinutes":"60", 43 | "Parameters":{ 44 | "TagValue":{ 45 | "Ref":"EC2TagValue" 46 | }, 47 | "KeyPairName":{ 48 | "Ref":"EC2KeyPairName" 49 | } 50 | } 51 | } 52 | }, 53 | "MyApplication":{ 54 | "Type":"AWS::CodeDeploy::Application", 55 | "DependsOn":"CodeDeployEC2InstancesStack", 56 | "Properties" : { 57 | "ApplicationName" : { 58 | "Ref":"ApplicationName" 59 | } 60 | } 61 | }, 62 | "MyDeploymentGroup":{ 63 | "Type":"AWS::CodeDeploy::DeploymentGroup", 64 | "DependsOn":"MyApplication", 65 | "Properties":{ 66 | "DeploymentGroupName" : { 67 | "Ref":"DeploymentGroupName" 68 | }, 69 | "ApplicationName":{ 70 | "Ref":"MyApplication" 71 | }, 72 | "Ec2TagFilters":[ 73 | { 74 | "Key":{ 75 | "Ref":"EC2TagTagKeyName" 76 | }, 77 | "Value":{ 78 | "Ref":"EC2TagValue" 79 | }, 80 | "Type":"KEY_AND_VALUE" 81 | } 82 | ], 83 | "ServiceRoleArn":{ 84 | "Fn::GetAtt":[ 85 | "CodeDeployEC2InstancesStack", 86 | "Outputs.CodeDeployTrustRoleARN" 87 | ] 88 | } 89 | } 90 | } 91 | }, 92 | "Outputs":{ 93 | "MyAWSAccountId":{ 94 | "Value":{ 95 | "Ref":"AWS::AccountId" 96 | } 97 | }, 98 | "MyApplication":{ 99 | "Value":{ 100 | "Ref":"MyApplication" 101 | } 102 | }, 103 | "MyDeploymentGroup":{ 104 | "Value":{ 105 | "Ref":"MyDeploymentGroup" 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check [existing open](https://github.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/issues), or [recently closed](https://github.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/labels/help%20wanted) issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](https://github.com/aws-samples/aws-codepipeline-cross-region-continuous-deployment/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /cfn-templates/cross-region-code-pipeline.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | Description: > 3 | This template creates a resources for test, like artifact bucket, service role, webhook pipeline and test webhook. 4 | 5 | Parameters: 6 | S3SourceBucket: 7 | Type: String 8 | S3SourceBucketKey: 9 | Type: String 10 | DeploymentGroupName: 11 | Type: String 12 | ApplicationName: 13 | Type: String 14 | USEast1ArtifactStoreBucket: 15 | Type: String 16 | USWest2ArtifactStoreBucket: 17 | Type: String 18 | APSouthEast2ArtifactStoreBucket: 19 | Type: String 20 | 21 | Mappings: 22 | SecondRegionMap: 23 | us-west-2: 24 | SecondRegion1: us-east-1 25 | SecondRegion2: ap-southeast-2 26 | us-east-1: 27 | SecondRegion1: us-west-2 28 | SecondRegion2: ap-southeast-2 29 | Resources: 30 | 31 | CodePipelineServiceRole: 32 | Type: AWS::IAM::Role 33 | Properties: 34 | AssumeRolePolicyDocument: 35 | Version: '2012-10-17' 36 | Statement: 37 | - Sid: '' 38 | Effect: Allow 39 | Principal: 40 | Service: 41 | - codepipeline.amazonaws.com 42 | Action: sts:AssumeRole 43 | Policies: 44 | - PolicyName: CodePipelinePolicy 45 | PolicyDocument: 46 | Version: '2012-10-17' 47 | Statement: 48 | - Action: 49 | - s3:GetObject 50 | - s3:GetObjectVersion 51 | - s3:GetBucketVersioning 52 | Resource: "*" 53 | Effect: Allow 54 | - Action: 55 | - s3:PutObject 56 | Resource: 57 | - arn:aws:s3:::codepipeline* 58 | - arn:aws:s3:::elasticbeanstalk* 59 | Effect: Allow 60 | - Action: 61 | - codebuild:* 62 | Resource: "*" 63 | Effect: Allow 64 | - Action: 65 | - autoscaling:* 66 | - cloudwatch:* 67 | - s3:* 68 | - sns:* 69 | - cloudformation:* 70 | - sqs:* 71 | - iam:PassRole 72 | Resource: "*" 73 | Effect: Allow 74 | - Action: 75 | - lambda:InvokeFunction 76 | - lambda:ListFunctions 77 | Resource: "*" 78 | Effect: Allow 79 | - Action: 80 | - codedeploy:CreateDeployment 81 | - codedeploy:GetApplicationRevision 82 | - codedeploy:GetDeployment 83 | - codedeploy:GetDeploymentConfig 84 | - codedeploy:RegisterApplicationRevision 85 | Resource: "*" 86 | Effect: Allow 87 | 88 | MultiRegionPipeline: 89 | Type: AWS::CodePipeline::Pipeline 90 | Properties: 91 | RoleArn: 92 | Fn::GetAtt: 93 | - CodePipelineServiceRole 94 | - Arn 95 | Stages: 96 | - 97 | Name: Source 98 | Actions: 99 | - 100 | Name: Source 101 | ActionTypeId: 102 | Category: Source 103 | Owner: AWS 104 | Version: 1 105 | Provider: S3 106 | OutputArtifacts: 107 | - 108 | Name: SourceOutput 109 | Configuration: 110 | S3Bucket: !Ref S3SourceBucket 111 | S3ObjectKey: !Ref S3SourceBucketKey 112 | PollForSourceChanges: true 113 | RunOrder: 1 114 | - 115 | Name: Prod 116 | Actions: 117 | - 118 | Name: SecondRegion1Deploy 119 | InputArtifacts: 120 | - 121 | Name: SourceOutput 122 | ActionTypeId: 123 | Category: Deploy 124 | Owner: AWS 125 | Version: 1 126 | Provider: CodeDeploy 127 | Configuration: 128 | ApplicationName: !Ref ApplicationName 129 | DeploymentGroupName: !Ref DeploymentGroupName 130 | RunOrder: 1 131 | Region: !FindInMap [SecondRegionMap, !Ref "AWS::Region", SecondRegion1] 132 | - 133 | Name: SecondRegion2Deploy 134 | InputArtifacts: 135 | - 136 | Name: SourceOutput 137 | ActionTypeId: 138 | Category: Deploy 139 | Owner: AWS 140 | Version: 1 141 | Provider: CodeDeploy 142 | Configuration: 143 | ApplicationName: !Ref ApplicationName 144 | DeploymentGroupName: !Ref DeploymentGroupName 145 | RunOrder: 1 146 | Region: !FindInMap [SecondRegionMap, !Ref "AWS::Region", SecondRegion2] 147 | - 148 | Name: PrimaryRegionDeploy 149 | InputArtifacts: 150 | - 151 | Name: SourceOutput 152 | ActionTypeId: 153 | Category: Deploy 154 | Owner: AWS 155 | Version: 1 156 | Provider: CodeDeploy 157 | Configuration: 158 | ApplicationName: !Ref ApplicationName 159 | DeploymentGroupName: !Ref DeploymentGroupName 160 | RunOrder: 1 161 | Region: !Ref "AWS::Region" 162 | ArtifactStores: 163 | - 164 | Region: us-west-2 165 | ArtifactStore: 166 | Type: S3 167 | Location: !Ref USWest2ArtifactStoreBucket 168 | - 169 | Region: us-east-1 170 | ArtifactStore: 171 | Type: S3 172 | Location: !Ref USEast1ArtifactStoreBucket 173 | - 174 | Region: ap-southeast-2 175 | ArtifactStore: 176 | Type: S3 177 | Location: !Ref APSouthEast2ArtifactStoreBucket 178 | --------------------------------------------------------------------------------