We use asgard at work to do deployments in both qa and production. Our general flow is to check in, have jenkins build, an AMI is created, and then … we have to manually go to asgard and deploy it. That sucks.
However, its actually not super hard to write some scripts to find the latest AMI for a cluster and prepare an automated deployment pipeline from a template. Here you go:
function asgard(){
verb=$1
url="https://my.asgard.com/us-east-1/$2"
shift
http ${VERB} --verify=no "$url" -b
}
function next-ami(){
cluster=$1
prepare-ami $cluster true | \
jq ".environment.images | reverse | .[0]"
}
function prepare-ami(){
cluster=$1
includeEnv=$2
asgard GET "deployment/prepare/${cluster}?deploymentTemplateName=CreateAndCleanUpPreviousAsg&includeEnvironment=${includeEnv}"
}
function get-next-ami(){
cluster=$1
next=`next-ami ${cluster} | jq ".id"`
prepare-ami ${cluster} "false" | jq ".lcOptions.imageId |= ${next}"
}
function start-deployment(){
cluster=$1
payload=$2
echo $payload | asgard POST "deployment/start/${cluster}"
}
The gist here is to
Find the next AMI image of a cluster
Get the prepared JSON for the next deployment
Update the prepared json with the new ami image
To use it you’d do
\> clusterName="foo"
\> next=`get-next-ami $clusterName`
\> start-deployment $clusterName $next
{
"deploymentId": "1773"
}
And thats it!

