AWS - Find Blue-Green ASG
Octopus.AwsRunScript exported 01/10/2025 by mcasperson belongs to 'AWS' category.
Return the name of the online and offline blue and green Auto Scaling Groups
Parameters
When steps based on the template are included in a project's deployment process, the parameters below can be set.
Inactive Color
The color of the inactive group (Green or Blue). This value is usually found from the "AWS - Find Blue-Green Target Group" step.
Green ASG Name
The name of the green auto scaler group. See https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html for more details.
Blue ASG Name
The name of the blue auto scaler group. See https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html for more details.
Region
The AWS region. See https://aws.amazon.com/about-aws/global-infrastructure/regions_az/ for more information.
Account
Script body
#!/bin/bash
INACTIVECOLOR=${1:-'#{AWSBlueGreen.InactiveColor | Trim}'}
GREENASG=${2:-'#{AWSBlueGreen.AWS.GreenASG | Trim}'}
BLUEASG=${3:-'#{AWSBlueGreen.AWS.BlueASG | Trim}'}
echoerror() { echo "$@" 1>&2; }
if [[ -z "${INACTIVECOLOR}" ]]
then
echoerror "Please provide the color of the inactive Auto Scaling group (Green or Blue) as the first argument"
exit 1
fi
if [[ -z "${GREENASG}" ]]
then
echoerror "Please provide the name of the Green Auto Scaling group as the second argument"
exit 1
fi
if [[ -z "${BLUEASG}" ]]
then
echoerror "Please provide the name of the Blue Auto Scaling group as the third argument"
exit 1
fi
if [[ "${INACTIVECOLOR^^}" == "GREEN" ]]
then
set_octopusvariable "ActiveGroup" "${BLUEASG}"
set_octopusvariable "InactiveGroup" "${GREENASG}"
echo "Active group is Blue (${BLUEASG}), inactive group is Green (${GREENASG})"
else
set_octopusvariable "ActiveGroup" "${GREENASG}"
set_octopusvariable "InactiveGroup" "${BLUEASG}"
echo "Active group is Green (${GREENASG}), inactive group is Blue (${BLUEASG})"
fiTo use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
Show JSON{
"Id": "6b72995e-500c-4b4b-9121-88f3a988ec71",
"Name": "AWS - Find Blue-Green ASG",
"Description": "Return the name of the online and offline blue and green Auto Scaling Groups",
"Version": 1,
"ExportedAt": "2025-01-10T03:42:14.665Z",
"ActionType": "Octopus.AwsRunScript",
"Author": "mcasperson",
"Packages": [],
"Parameters": [
{
"Id": "f8522014-f1ba-4e4a-a06d-59ebdba6f276",
"Name": "AWSBlueGreen.InactiveColor",
"Label": "Inactive Color",
"HelpText": "The color of the inactive group (Green or Blue). This value is usually found from the \"AWS - Find Blue-Green Target Group\" step.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "8753e6ed-0ae6-4a4c-ae5b-155139037633",
"Name": "AWSBlueGreen.AWS.GreenASG",
"Label": "Green ASG Name",
"HelpText": "The name of the green auto scaler group. See https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html for more details.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "bf9187f5-62e9-4ad9-b53f-459466b84994",
"Name": "AWSBlueGreen.AWS.BlueASG",
"Label": "Blue ASG Name",
"HelpText": "The name of the blue auto scaler group. See https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html for more details.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "eb02bbf2-e05a-4469-9359-c77d77d87dd2",
"Name": "AWSBlueGreen.AWS.Region",
"Label": "Region",
"HelpText": "The AWS region. See https://aws.amazon.com/about-aws/global-infrastructure/regions_az/ for more information.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "99a74afc-ee67-4295-8281-3bb1c6e83d06",
"Name": "AWSBlueGreen.AWS.Account",
"Label": "Account",
"HelpText": null,
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "AmazonWebServicesAccount"
}
}
],
"Properties": {
"OctopusUseBundledTooling": "False",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "Bash",
"Octopus.Action.Aws.AssumeRole": "False",
"Octopus.Action.AwsAccount.UseInstanceRole": "False",
"Octopus.Action.AwsAccount.Variable": "#{AWSBlueGreen.AWS.Account}",
"Octopus.Action.Script.ScriptBody": "#!/bin/bash\n\nINACTIVECOLOR=${1:-'#{AWSBlueGreen.InactiveColor | Trim}'}\nGREENASG=${2:-'#{AWSBlueGreen.AWS.GreenASG | Trim}'}\nBLUEASG=${3:-'#{AWSBlueGreen.AWS.BlueASG | Trim}'}\n\nechoerror() { echo \"$@\" 1>&2; }\n\nif [[ -z \"${INACTIVECOLOR}\" ]]\nthen\n echoerror \"Please provide the color of the inactive Auto Scaling group (Green or Blue) as the first argument\"\n exit 1\nfi\n\nif [[ -z \"${GREENASG}\" ]]\nthen\n echoerror \"Please provide the name of the Green Auto Scaling group as the second argument\"\n exit 1\nfi\n\nif [[ -z \"${BLUEASG}\" ]]\nthen\n echoerror \"Please provide the name of the Blue Auto Scaling group as the third argument\"\n exit 1\nfi\n\nif [[ \"${INACTIVECOLOR^^}\" == \"GREEN\" ]]\nthen\n set_octopusvariable \"ActiveGroup\" \"${BLUEASG}\"\n set_octopusvariable \"InactiveGroup\" \"${GREENASG}\"\n echo \"Active group is Blue (${BLUEASG}), inactive group is Green (${GREENASG})\"\nelse\n set_octopusvariable \"ActiveGroup\" \"${GREENASG}\"\n set_octopusvariable \"InactiveGroup\" \"${BLUEASG}\"\n echo \"Active group is Green (${GREENASG}), inactive group is Blue (${BLUEASG})\"\nfi",
"Octopus.Action.Aws.Region": "#{AWSBlueGreen.AWS.Region}"
},
"Category": "AWS",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates/aws-find-blue-green-asg.json",
"Website": "/step-templates/6b72995e-500c-4b4b-9121-88f3a988ec71",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////9o0R/eLD/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+0BeX/x7Ue40W3xacfb2gXFxUZcX8TYB3Kyfp+GThsjKti2zgZuMiLshxW3gpiQyrn/DXhR/i1NqIte5pkUEEUQQQQQRRBBBBBFEEEEEEUR+g4jQUZBEqjqFO9mOiyeShoXvYoukZOG4GCLpWZgu83/vTNRidhlE0rYAAAAAAAAAAAAAAAAAAACAZPkjwAAMDi+bsnPP/wAAAABJRU5ErkJggg==",
"$Meta": {
"Type": "ActionTemplate"
}
}Provided under the Apache License version 2.0.