1

I have an existing Bitbucket Pipelines setup with AWS CodeDeploy that works on single region. Now I'm trying to modify the existing setup to cater for multi region deployment. Here's my bitbucket-pipelines.yml:

image: php:7.1.29

pipelines:
  branches:
    develop:
      - step:
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y unzip zip
            - zip -r MobileAPIDEV.zip .
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'MobileAPIDEV'
                ZIP_FILE: 'MobileAPIDEV.zip'
                COMMAND: 'upload' 
                S3_BUCKET: $S3_BUCKET
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'MobileAPIDEV'
                DEPLOYMENT_GROUP: 'MobileAPIDEV'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
    master:
      - step:
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y unzip zip
            - zip -r prodMobileAPI.zip .
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'prodMobileAPI'
                ZIP_FILE: 'prodMobileAPI.zip'
                COMMAND: 'upload' 
                S3_BUCKET: $S3_BUCKET
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                APPLICATION_NAME: 'prodMobileAPI'
                DEPLOYMENT_GROUP: 'prodMobileAPI'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
                AWS_DEFAULT_REGION: eu-central-1 
                APPLICATION_NAME: 'prodMobileAPI'
                DEPLOYMENT_GROUP: 'prodMobileAPI'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'

I added the third pipe under master branch and set eu-central-1 as the new default region. I'm not sure if I'm doing it correctly because I couldn't find any example for multi region deployment using this approach.

When I tried to deploy, I got this error: An error occurred (RevisionDoesNotExistException) when calling the GetApplicationRevision operation: No application revision found for revision.

I confirm that my CodeDeploy setup in the other region has the correct role, and the Access Key that I used for the Bitbucket Pipeline has sufficient permission as well.

1 Answer 1

2

From error

An error occurred (RevisionDoesNotExistException) when calling the GetApplicationRevision operation: No application revision found for revision.

There is no artifact available in the mentioned region eu-central-1 RevisionDoesNotExistException.

As per the documentation

When you create or edit a pipeline, you must have an artifact bucket in the pipeline Region and then you must have one artifact bucket per Region where you plan to execute an action.

So you have to have an upload section as well OR

what I would do is have a separate step per region OR

setup Cross-Region Replication for Amazon S3, this would let me copy the articats whichever region I want to and I can have only one upload in the pipeline.yml

check this blog post Using AWS CodePipeline to Perform Multi-Region Deployments


pipelines:
  branches:
    develop:
      - step:
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y unzip zip
            - zip -r MobileAPIDEV.zip .
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'MobileAPIDEV'
                ZIP_FILE: 'MobileAPIDEV.zip'
                COMMAND: 'upload' 
                S3_BUCKET: $S3_BUCKET
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'MobileAPIDEV'
                DEPLOYMENT_GROUP: 'MobileAPIDEV'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
    master:
      - step:
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y unzip zip
            - zip -r prodMobileAPI.zip .
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION 
                APPLICATION_NAME: 'prodMobileAPI'
                ZIP_FILE: 'prodMobileAPI.zip'
                COMMAND: 'upload' 
                S3_BUCKET: $S3_BUCKET
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
                APPLICATION_NAME: 'prodMobileAPI'
                DEPLOYMENT_GROUP: 'prodMobileAPI'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY 
                AWS_DEFAULT_REGION: 'eu-central-1'
                APPLICATION_NAME: 'prodMobileAPI'
                ZIP_FILE: 'prodMobileAPI.zip'
                COMMAND: 'upload' 
                S3_BUCKET: $S3_BUCKET
            - pipe: atlassian/aws-code-deploy:0.5.3
              variables:
                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID 
                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY # Optional if already defined in the context.
                AWS_DEFAULT_REGION: 'eu-central-1' 
                APPLICATION_NAME: 'prodMobileAPI'
                DEPLOYMENT_GROUP: 'prodMobileAPI'
                WAIT: 'false'
                S3_BUCKET: $S3_BUCKET
                COMMAND: 'deploy' 
                IGNORE_APPLICATION_STOP_FAILURES: 'true'
                FILE_EXISTS_BEHAVIOR: 'OVERWRITE'

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! I wasn't aware that it's a requirement to have a bucket in the region I'm deploying to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.