-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #546 from guardian/aa/scaling
feat: Add scripts to trigger ASG scale in/out events
- Loading branch information
Showing
5 changed files
with
184 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CLOUDFORMATION_STACK_NAME=playground-PROD-cdk-playground | ||
|
||
POLICY_ARN=$( | ||
aws cloudformation describe-stacks \ | ||
--stack-name "$CLOUDFORMATION_STACK_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 \ | ||
--no-cli-pager | \ | ||
jq -r '.Stacks[].Outputs[] | select( [.OutputKey | contains("ScaleInArn") ] | any) | .OutputValue' | ||
) | ||
|
||
ASG_NAME=$( | ||
aws cloudformation describe-stacks \ | ||
--stack-name "$CLOUDFORMATION_STACK_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 \ | ||
--no-cli-pager | \ | ||
jq -r '.Stacks[].Outputs[] | select( [.OutputKey | contains("AutoscalingGroupName") ] | any) | .OutputValue' | ||
) | ||
|
||
CURRENT_DESIRED_CAPACITY=$( | ||
aws autoscaling describe-auto-scaling-groups \ | ||
--auto-scaling-group-names "$ASG_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | \ | ||
jq -r '.AutoScalingGroups[].DesiredCapacity' | ||
) | ||
|
||
aws autoscaling execute-policy \ | ||
--policy-name "$POLICY_ARN" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | ||
|
||
NEW_DESIRED_CAPACITY=$( | ||
aws autoscaling describe-auto-scaling-groups \ | ||
--auto-scaling-group-names "$ASG_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | \ | ||
jq -r '.AutoScalingGroups[].DesiredCapacity' | ||
) | ||
|
||
echo "Desired capacity has been updated from $CURRENT_DESIRED_CAPACITY to $NEW_DESIRED_CAPACITY" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CLOUDFORMATION_STACK_NAME=playground-CODE-scaling-asg-rolling-update | ||
|
||
POLICY_ARN=$( | ||
aws cloudformation describe-stacks \ | ||
--stack-name "$CLOUDFORMATION_STACK_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 \ | ||
--no-cli-pager | \ | ||
jq -r '.Stacks[].Outputs[] | select( [.OutputKey | contains("ScaleOutArn") ] | any) | .OutputValue' | ||
) | ||
|
||
ASG_NAME=$( | ||
aws cloudformation describe-stacks \ | ||
--stack-name "$CLOUDFORMATION_STACK_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 \ | ||
--no-cli-pager | \ | ||
jq -r '.Stacks[].Outputs[] | select( [.OutputKey | contains("AutoscalingGroupName") ] | any) | .OutputValue' | ||
) | ||
|
||
CURRENT_DESIRED_CAPACITY=$( | ||
aws autoscaling describe-auto-scaling-groups \ | ||
--auto-scaling-group-names "$ASG_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | \ | ||
jq -r '.AutoScalingGroups[].DesiredCapacity' | ||
) | ||
|
||
aws autoscaling execute-policy \ | ||
--policy-name "$POLICY_ARN" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | ||
|
||
NEW_DESIRED_CAPACITY=$( | ||
aws autoscaling describe-auto-scaling-groups \ | ||
--auto-scaling-group-names "$ASG_NAME" \ | ||
--profile developerPlayground \ | ||
--region eu-west-1 | \ | ||
jq -r '.AutoScalingGroups[].DesiredCapacity' | ||
) | ||
|
||
echo "Desired capacity has been updated from $CURRENT_DESIRED_CAPACITY to $NEW_DESIRED_CAPACITY" |