Difference between revisions of "AWS/Bash-my-AWS"
< AWS
Jump to navigation
Jump to search
| Line 4: | Line 4: | ||
= [https://bash-my-aws.org/pipe-skimming/ Pipe-Skimming] = | = [https://bash-my-aws.org/pipe-skimming/ Pipe-Skimming] = | ||
;<code>instances</code> | |||
<source lang=bash> | <source lang=bash> | ||
$ instances | instance-asg | asg-capacity | $ instances | instance-asg | asg-capacity | ||
| Line 9: | Line 10: | ||
huginn-bma-AutoScalingGroup-QS7EQOT1G7OX 1 1 2 | huginn-bma-AutoScalingGroup-QS7EQOT1G7OX 1 1 2 | ||
nginx-bma-AutoScalingGroup-106KHAYHUSRHU 1 1 2 | nginx-bma-AutoScalingGroup-106KHAYHUSRHU 1 1 2 | ||
</source> | |||
;ASGs resize, rolling update | |||
<source lang=bash> | |||
# Get list of ASGs you wish to resize | |||
$ asgs | grep dev-asg | |||
dev-asg-ai-spot-12020082510030522560000001d dev-asg-ai-spot-1-eks_asg 2020-08-25T10:03:05.798Z eu-west-1a,eu-west-1b,eu-west-1c | |||
dev-asg-ga-spot-120200825100305284100000020 dev-asg-ga-spot-1-eks_asg 2020-08-25T10:03:05.841Z eu-west-1a,eu-west-1b,eu-west-1c | |||
dev-asg-ai-spot-22020082510030527670000001e dev-asg-ai-spot-2-eks_asg 2020-08-25T10:03:05.843Z eu-west-1a,eu-west-1b,eu-west-1c | |||
dev-asg-ga-spot-220200825100305292100000021 dev-asg-ga-spot-2-eks_asg 2020-08-25T10:03:05.851Z eu-west-1a,eu-west-1b,eu-west-1c | |||
dev-asg-on-demand-12020082510030527990000001f dev-asg-on-demand-1-eks_asg 2020-08-25T10:03:05.948Z eu-west-1a,eu-west-1b,eu-west-1c | |||
# Show current capacity | |||
$ asgs | grep dev-asg | asg-capacity | |||
dev-asg-ai-spot-12020082510030522560000001d 1 1 5 | |||
dev-asg-ai-spot-22020082510030527670000001e 1 1 5 | |||
dev-asg-ga-spot-120200825100305284100000020 1 1 5 | |||
dev-asg-ga-spot-220200825100305292100000021 1 1 5 | |||
dev-asg-on-demand-12020082510030527990000001f 1 1 5 | |||
# Set minimum | |||
$ asgs | grep dev-asg | asg-min-size-set 0 | |||
$ asgs | grep dev-asg | asg-capacity | |||
dev-asg-ai-spot-12020082510030522560000001d 0 1 5 | |||
dev-asg-ai-spot-22020082510030527670000001e 0 1 5 | |||
dev-asg-ga-spot-120200825100305284100000020 0 1 5 | |||
dev-asg-ga-spot-220200825100305292100000021 0 1 5 | |||
dev-asg-on-demand-12020082510030527990000001f 0 1 5 | |||
# Set desired number | |||
$ asgs | grep dev-asg | asg-desired-size-set 0 | |||
$ asgs | grep dev-asg | asg-capacity | |||
dev-asg-ai-spot-12020082510030522560000001d 0 0 5 | |||
dev-asg-ai-spot-22020082510030527670000001e 0 0 5 | |||
dev-asg-ga-spot-120200825100305284100000020 0 0 5 | |||
dev-asg-ga-spot-220200825100305292100000021 0 0 5 | |||
dev-asg-on-demand-12020082510030527990000001f 0 0 5 | |||
# Watch activity | |||
$ asgs | grep dev-asg | asg-scaling-activities | |||
{ | |||
"Activities": [ | |||
{ | |||
"ActivityId": "eb9e4def-62c7-479f-8d64-2352763d5780", | |||
"AutoScalingGroupName": "dev-asg-ai-spot-12020082510030522560000001d", | |||
"Description": "Terminating EC2 instance: i-0fd2b8d88133aaaaa", | |||
"Cause": "At 2020-08-25T21:27:51Z a user request explicitly set group desired capacity changing the desired capacity from 1 to 0. At 2020-08-25T21:28:03Z an instance was taken out of service in response to a difference between desired and actual capacity, shrinking the capacity from 1 to 0. At 2020-08-25T21:28:03Z instance i-0fd2b8d88133aaaaa was selected for termination.", | |||
"StartTime": "2020-08-25T21:28:03.588Z", | |||
"StatusCode": "InProgress", | |||
"Progress": 50, | |||
"Details": "{\"Subnet ID\":\"subnet-aaaaaad7a79baaaaa\",\"Availability Zone\":\"eu-west-1a\"}" | |||
}, | |||
... | |||
# Set minimum and desired count back as it was | |||
$ asgs | grep dev-asg | asg-desired-size-set 1 | |||
$ asgs | grep dev-asg | asg-capacity | |||
dev-asg-ai-spot-12020082510030522560000001d 0 1 5 | |||
dev-asg-ai-spot-22020082510030527670000001e 0 1 5 | |||
dev-asg-ga-spot-120200825100305284100000020 0 1 5 | |||
dev-asg-ga-spot-220200825100305292100000021 0 1 5 | |||
dev-asg-on-demand-12020082510030527990000001f 0 1 5 | |||
</source> | </source> | ||
= References = | = References = | ||
* [https://bash-my-aws.org/command-reference/ command-reference] | * [https://bash-my-aws.org/command-reference/ command-reference] | ||
Revision as of 08:36, 26 August 2020
Install
{{Note:bma support for assumed roles setup within ~/.aws/config requires setting profile via environment variable eg. export AWS_PROFILE=dev as --profile flag is not supported or just not working for me}}
Pipe-Skimming
instances
$ instances | instance-asg | asg-capacity grafana-bma-AutoScalingGroup-1NXJHMJVZQVMB 1 1 2 huginn-bma-AutoScalingGroup-QS7EQOT1G7OX 1 1 2 nginx-bma-AutoScalingGroup-106KHAYHUSRHU 1 1 2
- ASGs resize, rolling update
# Get list of ASGs you wish to resize
$ asgs | grep dev-asg
dev-asg-ai-spot-12020082510030522560000001d dev-asg-ai-spot-1-eks_asg 2020-08-25T10:03:05.798Z eu-west-1a,eu-west-1b,eu-west-1c
dev-asg-ga-spot-120200825100305284100000020 dev-asg-ga-spot-1-eks_asg 2020-08-25T10:03:05.841Z eu-west-1a,eu-west-1b,eu-west-1c
dev-asg-ai-spot-22020082510030527670000001e dev-asg-ai-spot-2-eks_asg 2020-08-25T10:03:05.843Z eu-west-1a,eu-west-1b,eu-west-1c
dev-asg-ga-spot-220200825100305292100000021 dev-asg-ga-spot-2-eks_asg 2020-08-25T10:03:05.851Z eu-west-1a,eu-west-1b,eu-west-1c
dev-asg-on-demand-12020082510030527990000001f dev-asg-on-demand-1-eks_asg 2020-08-25T10:03:05.948Z eu-west-1a,eu-west-1b,eu-west-1c
# Show current capacity
$ asgs | grep dev-asg | asg-capacity
dev-asg-ai-spot-12020082510030522560000001d 1 1 5
dev-asg-ai-spot-22020082510030527670000001e 1 1 5
dev-asg-ga-spot-120200825100305284100000020 1 1 5
dev-asg-ga-spot-220200825100305292100000021 1 1 5
dev-asg-on-demand-12020082510030527990000001f 1 1 5
# Set minimum
$ asgs | grep dev-asg | asg-min-size-set 0
$ asgs | grep dev-asg | asg-capacity
dev-asg-ai-spot-12020082510030522560000001d 0 1 5
dev-asg-ai-spot-22020082510030527670000001e 0 1 5
dev-asg-ga-spot-120200825100305284100000020 0 1 5
dev-asg-ga-spot-220200825100305292100000021 0 1 5
dev-asg-on-demand-12020082510030527990000001f 0 1 5
# Set desired number
$ asgs | grep dev-asg | asg-desired-size-set 0
$ asgs | grep dev-asg | asg-capacity
dev-asg-ai-spot-12020082510030522560000001d 0 0 5
dev-asg-ai-spot-22020082510030527670000001e 0 0 5
dev-asg-ga-spot-120200825100305284100000020 0 0 5
dev-asg-ga-spot-220200825100305292100000021 0 0 5
dev-asg-on-demand-12020082510030527990000001f 0 0 5
# Watch activity
$ asgs | grep dev-asg | asg-scaling-activities
{
"Activities": [
{
"ActivityId": "eb9e4def-62c7-479f-8d64-2352763d5780",
"AutoScalingGroupName": "dev-asg-ai-spot-12020082510030522560000001d",
"Description": "Terminating EC2 instance: i-0fd2b8d88133aaaaa",
"Cause": "At 2020-08-25T21:27:51Z a user request explicitly set group desired capacity changing the desired capacity from 1 to 0. At 2020-08-25T21:28:03Z an instance was taken out of service in response to a difference between desired and actual capacity, shrinking the capacity from 1 to 0. At 2020-08-25T21:28:03Z instance i-0fd2b8d88133aaaaa was selected for termination.",
"StartTime": "2020-08-25T21:28:03.588Z",
"StatusCode": "InProgress",
"Progress": 50,
"Details": "{\"Subnet ID\":\"subnet-aaaaaad7a79baaaaa\",\"Availability Zone\":\"eu-west-1a\"}"
},
...
# Set minimum and desired count back as it was
$ asgs | grep dev-asg | asg-desired-size-set 1
$ asgs | grep dev-asg | asg-capacity
dev-asg-ai-spot-12020082510030522560000001d 0 1 5
dev-asg-ai-spot-22020082510030527670000001e 0 1 5
dev-asg-ga-spot-120200825100305284100000020 0 1 5
dev-asg-ga-spot-220200825100305292100000021 0 1 5
dev-asg-on-demand-12020082510030527990000001f 0 1 5