AWS CloudShell - List instances by ARN prefix

547 Views Asked by At

In AWS Backup, I have created a resource assignment to a backup-plan, which targets all EC2 instances.

The ARN prefix looks like this:

arn:aws:ec2:*:*:instance/*

How can I list all instances that match an ARN prefix? Either in AWS Cloudshell or with the aws cli?

1

There are 1 best solutions below

2
Varad Karpe On

I think you can try using ec2's describe-instances cli command and run it over all AWS regions :

for region in `aws ec2 describe-regions --output text | cut -f3`
do
     echo -e "\nListing Instances in region:'$region'..."
     aws ec2 describe-instances --region $region
done