BK NATANI
BK NATANI

Reputation: 9

Is there is any way to get all instances in ec2 across all regions php SDK

is there is any way to get all instances across all regions in aws ec2 rest API or SDK?

I need all instances in ec2 all regions ('us-east-1','us-west-1','us-west-2','ca-central-1','eu-west-1','eu-central-1','eu-west-2','ap-northeast-1','ap-southeast-1','ap-southeast-2','ap-south-1','sa-east-1')

Upvotes: 0

Views: 148

Answers (1)

Jyothish
Jyothish

Reputation: 1133

Create a list with regions and iterate through it.

region = ["us-east-1", "us-west-2"]
for i in region:
    ec2_client = boto3.client('ec2',region_name=i)
    response = ec2_client.describe_instances()

Upvotes: 1

Related Questions