AWS Opsworks : How to deploy a particular git tag for an App?
Asked Answered
D

3

5

AWS Opsworks lets you deploy an app. The deployment seems to deploy the master branch always.

How can I make it deploy a git tag?

Thanks

Drouin answered 25/8, 2015 at 4:51 Comment(0)
D
5

Have you check this? You can check Branch/Revision section it is showing how you can deploy according to branch http://docs.aws.amazon.com/opsworks/latest/userguide/gettingstarted-simple-app.html

Diacaustic answered 25/8, 2015 at 5:18 Comment(3)
Perfect. However, I would have wanted the branch/revision section to be filled up when actually deploying - not when editing the app.Drouin
People who deploy tags to production - will always have to edit the app and then deploy. Multi-step process is generally painful.Drouin
@MayankJain I had this exact same issue. After some research/testing, it seems you can specify a tag at deployment time by using custom JSON, OpsWorks documentation isn't very clear about how exactly to do this, please refer to my answer https://mcmap.net/q/1891910/-aws-opsworks-how-to-deploy-a-particular-git-tag-for-an-appSontag
S
9

There is no elegant solution to this. It's a shame OpsWorks doesn't let you specify branch/tag at deployment time.

EDIT: After some digging around with OpsWorks/Chef/Ruby, you actually can deploy a specific tag relatively simply. Either of the two methods below are still valid.

You can deploy a git tag in one of the following ways:

Method 1: Specify in App settings

  1. Before deploying, edit your App, and change the Branch/Revision value to tags/1.2.3 where 1.2.3 is the tag you want to deploy.
  2. Save changes, then deploy your app as normal.
  3. Remember to manually change this each time you deploy!

Method 2: Pass custom JSON on deployment action

Include the following custom JSON when you deploy your app

{"deploy": {"myapp": {"scm": {"revision": "tags/1.2.3"}}}}

where myapp is the Short name of your app and 1.2.3 is the tag you want deployed. Don't forget to include this custom JSON each time, or your deployment will default to whatever you have in your App:Branch/Revision.

Further Thoughts

For apps in build/test, you could specify develop as your Branch/Revision in App Settings, and not worry about using custom JSON each time. This will always deploy the head of develop for you.

For apps in production, you could have master as your Branch/Revision, then specify the custom JSON at deployment time. This way, if you forget to include the custom JSON, at least it will deploy the latest revision from master, which most of the time should be the same as your latest tag.

It is worth noting that if you add new instances to your layer (manually, or automatically according to your layer rules), the default behaviour would be to deploy a fresh version of your app according to the settings in App:Branch/Revision.... so actually, you'll need to be mindful of both methods depending on your exact requirements.

Sontag answered 6/10, 2015 at 8:58 Comment(0)
D
5

Have you check this? You can check Branch/Revision section it is showing how you can deploy according to branch http://docs.aws.amazon.com/opsworks/latest/userguide/gettingstarted-simple-app.html

Diacaustic answered 25/8, 2015 at 5:18 Comment(3)
Perfect. However, I would have wanted the branch/revision section to be filled up when actually deploying - not when editing the app.Drouin
People who deploy tags to production - will always have to edit the app and then deploy. Multi-step process is generally painful.Drouin
@MayankJain I had this exact same issue. After some research/testing, it seems you can specify a tag at deployment time by using custom JSON, OpsWorks documentation isn't very clear about how exactly to do this, please refer to my answer https://mcmap.net/q/1891910/-aws-opsworks-how-to-deploy-a-particular-git-tag-for-an-appSontag
S
0

I am actually dealing with this very same problem right now. We are moving our testing / staging environments into OpsWorks to leverage their time based instances for cost savings.

The way around this I went was a small command line ruby script to poll AWS to show me the stack list, then I can select the layer, app and the instances I want to deploy to. The script then asks for the branch name of the repo to deploy, and pushes a deploy over the AWS CLI to OpsWorks to handle.

This is all done over the AWS CLI. I will see about making this available online and post a link if it is clear with the boss.

Sigmund answered 18/11, 2016 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.