I am trying to automate CloudWatch dashboard creation. As of right now, when I move from one account to another, I have to do some copy and replace of instance ID in order for the cloudshell command to run. Is there a way to filter describe-instance based on the AZ the instances are in so I can run a for loop to create Cloudwatch widgets?
You can try following:
aws ec2 describe-instances --filters Name=availability-zone,Values=us-east-1a
AWS CLI describe-instances documentation.