It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to deploy to AWS Codedeploy with multiple Deployment Groups? Edited

I am following the Deploy to AWS with CodeDeploy guide found on this site but i am struggling with how to deploy to more than 1 deployment group in the same code deploy application. Should I create a repository variable for each deployment group?

To be clear, I want to be able to pick which deployment group I deploy to because i have more than 1.

1 answer

Hi @gbrown , if you wan't to be able to select a deployment group to deploy to, you should use the DEPLOYMENT_GROUP pipe variable. For example, this is how you would deploy to a staging and production deployment groups:

image: atlassian/default-image:2

pipelines:
  default:
    - step:
        name: Build
        script:
          - cd app && zip -r ../myapp.zip *
        artifacts:
          - myapp.zip

    - step:
        name: Upload to S3
        script:
          - pipe: atlassian/aws-code-deploy:0.2.10
            variables:
              AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
              AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
              AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
              COMMAND: 'upload'
              APPLICATION_NAME: ${APPLICATION_NAME}
              ZIP_FILE: 'myapp.zip'

    - step:
        name: Deploy to Staging
        deployment: Staging
        script:
        - pipe: atlassian/aws-code-deploy:0.2.10
          variables:

DEPLOYMENT_GROUP: staging-deployment-group
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION} COMMAND: 'deploy' APPLICATION_NAME: ${APPLICATION_NAME} WAIT: 'true'

- step:
name: Deploy to Prod
deployment: Production
script:
- pipe: atlassian/aws-code-deploy:0.2.10
variables:

DEPLOYMENT_GROUP: production-deployment-group
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
COMMAND: 'deploy'
APPLICATION_NAME: ${APPLICATION_NAME}
WAIT: 'true'

Hi @Alexander Zhukov ,

I came across this thread looking for the same solution as gbrown. I have a question though:

Would the proposed pipe above deploy to both Staging and Production in one go? I think it does.

How would I be able to choose in bitbucket which singular deployment group I will deploy to? Just QA or just Staging or just Prod?

 

Thanks

Dan

I have the same issue. @gbrown and @Daniel Forer were you able to solve this?

@Alexander Zhukov how does this work if you can only define one DEPLOYMENT_GROUP variable in the Repository variables?

 

    - step:
        name: Deploy to Staging
        deployment: Staging
        script:
        - pipe: atlassian/aws-code-deploy:0.2.10
          variables:

DEPLOYMENT_GROUP: staging-deployment-group
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION} COMMAND: 'deploy' APPLICATION_NAME: ${APPLICATION_NAME} WAIT: 'true'

- step:
name: Deploy to Prod
deployment: Production
script:
- pipe: atlassian/aws-code-deploy:0.2.10
variables:

DEPLOYMENT_GROUP: production-deployment-group
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
COMMAND: 'deploy'
APPLICATION_NAME: ${APPLICATION_NAME}
WAIT: 'true'R 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,049 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you