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

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 can I override the codedeploy block of code?

Edited

How can I override the codedeploy block of code and use a different DEPLOYMENT_GROUP? Is this possible? I have two deployment groups (staging and production deployment groups) that target one EC2 instance. 

My goal is to deploy my application to a /staging and /production directory on my EC2.

- step: &deploy
name: Deploy to Staging
deployment: Staging
#trigger: manual # Uncomment to make this a manual step
script:
- apt-get update
- apt-get install -y zip
- zip -r application1.zip .
- pipe: atlassian/aws-code-deploy:0.5.3
name: Upload to S3
variables:
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
APPLICATION_NAME: 'CodeDeployApp'
S3_BUCKET: $S3_BUCKET
COMMAND: 'upload'
ZIP_FILE: 'application1.zip'
VERSION_LABEL: 'app-1.0.0'
- pipe: atlassian/aws-code-deploy:0.5.3
name: Deploy to EC2
variables:
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
APPLICATION_NAME: 'CodeDeployApp'
DEPLOYMENT_GROUP: 'staging-deployment-group'
S3_BUCKET: $S3_BUCKET
COMMAND: 'deploy'
WAIT: 'true'
VERSION_LABEL: 'app-1.0.0'
IGNORE_APPLICATION_STOP_FAILURES: 'true'
FILE_EXISTS_BEHAVIOR: 'OVERWRITE'


master:
- step: *build
- step:
<<: *deploy
name: Deploy to Prod
deployment: production
trigger: manual
script:
variables:
DEPLOYMENT_GROUP: 'production-deployment-group'

1 answer

I'm not so sure if this is practicable feasible with YAML merge key as it is merging hashes and requires to make use of heavy aliasing so to merge the only change at the right place.

It might be easier as this is related to deployments to make DEPLOYMENT_GROUP a deployment variable (can be setup per each deployment environment):

DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP 

and alias the deploy script (in difference to the whole step as you have in your example):

# ...
- step: &deploy
name: Deploy to Staging
deployment: Staging
script: &deploy-script
- apt-get update
# ...
master:

- step: *build
- step:
name: Deploy to Prod
deployment: production
trigger: manual
script: *deploy-script

See as well the suggestion by Oleksandr Kyrdan in a question of yours. 

@ktomk - thanks for the reply!

How would the steps in my deploy-script look like? I still can't get the picture.

If I use the alias, it will be using the same deployment group, is it not?

If I use the alias, it will be using the same deployment group, is it not?

Yes, the same deployment group, but only on the level of the YAML, let's see it again:

DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP 

The deployment group will be always the same: `$DEPLOYMENT_GROUP`.

As this is a variable, one to be set per each deployment environment, this allows you to change the deployment group for each deployment environment.

You can now control the individual deployment group by setting up the deployment variables.

As far as I have understood you, this is what you're looking for, right? Did this clarify your question?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

814 views 17 21
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