简体   繁体   中英

AWS .NET SDK - Get list of EC2 instances for beanstalk app

Is there a way to get a list of EC2 instances created by a given Beanstalk application? I am using the C# AWS SDK.

Using the AWSSDK.ElasticBeanstalk NuGet package you can use the DescribeEnvironmentResources API to get the ID of the all of the resources created for the environment including the ECS instance ids.

using var ebClient = new AmazonElasticBeanstalkClient(RegionEndpoint.USWest2);

var environmentResources = (await ebClient.DescribeEnvironmentResourcesAsync(new DescribeEnvironmentResourcesRequest
{
    EnvironmentName = environmentName
})).EnvironmentResources;

foreach(var instance in environmentResources.Instances)
{
    Console.WriteLine(instance.Id);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM