Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to deploy to AWS Codedeploy with multiple Deployment Groups?

gbrown January 8, 2020

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

1 vote
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 17, 2020

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'
Daniel Forer May 29, 2020

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

Abryan Manalansang August 16, 2020

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

Abryan Manalansang August 18, 2020

@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
AUG Leaders

Atlassian Community Events