I need to stop start multiple ec2 and run few command before and after ,using bash on the same manage server so no need to ssh. I know how to start and stop ec2, example:
start instance:
#! /bin/bash
aws ec2 start-instances --instance-ids i-1a1234
stop instance:
#! /bin/bash
aws ec2 stop-instances --instance-ids i-1a1234
I figured how to list all ec2 id by running :i.e.:
aws ec2 describe-instances --filters "Name=tag:Name,Values=Test: Instance 1" --query 'Reservations[].Instances[].[InstanceId] --output text
My questions are:
how can I stop/start multiple ec2.
how can I grab a specific ec2 and run a command to disable service before stopping and enable it after ec2 started.