Created
May 14, 2021 10:17
-
-
Save arush15june/c3825d37f2a493ae067a944cc5dae029 to your computer and use it in GitHub Desktop.
AWS CLI: start and stop instances by tag key-value (Powershell and bash)
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
aws ec2 start-instances --instance-ids $((aws ec2 describe-instances --filters "Name=tag:name,Values=test" --query 'Reservations[].Instances[].InstanceId' --output json | ConvertFrom-Json)) | |
aws ec2 stop-instances --instance-ids $((aws ec2 describe-instances --filters "Name=tag:name,Values=test" --query 'Reservations[].Instances[].InstanceId' --output json | ConvertFrom-Json)) |
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
#!/usr/bin/env bash | |
aws ec2 start-instances --instance-ids $((aws ec2 describe-instances --filters "Name=tag:name,Values=test" --query 'Reservations[].Instances[].InstanceId' --output json | jq -r)) | |
aws ec2 stop-instances --instance-ids $((aws ec2 describe-instances --filters "Name=tag:name,Values=test" --query 'Reservations[].Instances[].InstanceId' --output json | jq -r)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment