【问题标题】:How to find the ip of an instance in EC2 using filter in C#如何使用 C# 中的过滤器在 EC2 中查找实例的 ip
【发布时间】:2015-11-09 21:45:04
【问题描述】:

我有几个 EC2 实例,我想找到这些实例的 IP 地址。 我正在考虑将DescribeInstancesFilter 一起使用,但找不到任何如何应用Filter 的示例。 任何帮助表示赞赏。

【问题讨论】:

    标签: c# amazon-web-services amazon-ec2 aws-sdk


    【解决方案1】:

    之前已经回答了这个问题:Listing Instances in AWS .NET SDK

    所以,除了上面链接中的例子打印的InstanceId和InstanceType,你还可以打印

    Console.WriteLine(runningInstance.PrivateIpAddress);
    Console.WriteLine(runningInstance.PublicIpAddress);
    

    如果您需要在 DescribeInstanceRequest 中添加过滤器,请查看DescribeInstanceRequest With Filter

    示例 - 如何设置过滤器:

    new DescribeInstancesRequest()
    {
        Filter = new List<Filter>()
        {
            new Filter()
            {
                Name = "instance-id",
                Value = new List<String>()
                {
                    "i-223c1a1b"
                }
            }
        }
    }
    

    因此,上述过滤器将返回具有实例 id 的特定实例的详细信息:i-223c1a1b。

    有关所有过滤器及其名称的更多详细信息,请参阅DescribeInstances Filters

    【讨论】:

    • 我参与了你应用过滤器的地方。谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-07-02
    • 2014-03-05
    • 1970-01-01
    • 2014-05-20
    • 2016-07-29
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    相关资源
    最近更新 更多