不能在同一请求上指定网络接口和实例级私有 IP 地址

发布于 2025-01-16 05:10:03 字数 843 浏览 2 评论 0原文

我正在尝试使用 boto3 client.run_instances(**parameters) 方法创建 EC2 实例。 这是我的参数的值:

    {
   "ImageId":"ami-XXXXXXXXX",
   "InstanceType":"m4.large",
   "KeyName":"my_key",
   "UserData":"Content-Type: multipart/mixed",
   "Monitoring":{
      "Enabled":false
   },
   "MaxCount":1,
   "MinCount":1,
   "IamInstanceProfile":{
      "Name":"proxyIp-YYYYYYYY"
   },
   "NetworkInterfaces":[
      {
         "DeviceIndex":0,
         "AssociatePublicIpAddress":true,
         "Groups":[
            "sg-09999999fe111"
         ],
         "SubnetId":"subnet-06XXXXXXXXX"
      }
   ],
   "PrivateIpAddress":"AA.BB.C.DDD",
   "EbsOptimized":true
}

但是,堆栈在创建 ec2 实例时失败并出现错误:

调用 RunInstances 操作时发生错误 (InvalidParameterCombination):同一请求中可能未指定网络接口和实例级私有 IP 地址

请让我知道缺少什么。我检查了参数,看起来都很好。

I am trying to create an EC2 instance using boto3 client.run_instances(**parameters) method.
This is the value of my parameters:

    {
   "ImageId":"ami-XXXXXXXXX",
   "InstanceType":"m4.large",
   "KeyName":"my_key",
   "UserData":"Content-Type: multipart/mixed",
   "Monitoring":{
      "Enabled":false
   },
   "MaxCount":1,
   "MinCount":1,
   "IamInstanceProfile":{
      "Name":"proxyIp-YYYYYYYY"
   },
   "NetworkInterfaces":[
      {
         "DeviceIndex":0,
         "AssociatePublicIpAddress":true,
         "Groups":[
            "sg-09999999fe111"
         ],
         "SubnetId":"subnet-06XXXXXXXXX"
      }
   ],
   "PrivateIpAddress":"AA.BB.C.DDD",
   "EbsOptimized":true
}

However the stack is failing on creation of an ec2 isntance with an error :

An error occurred (InvalidParameterCombination) when calling the RunInstances operation: Network interfaces and an instance-level private IP address may not be specified on the same request

Could let me know what is missing. I have checked the parameters they all looks to be fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

莫言歌 2025-01-23 05:10:03

看起来您可以在 NetworkInterfaces 块内请求私有 IP 地址:

            "NetworkInterfaces": [
                {
                    "PrivateDnsName": "ip-10-0-0-157.us-east-2.compute.internal",
                    "PrivateIpAddress": "10.0.0.157",
                    "SourceDestCheck": true,
                    "Status": "in-use",
                    "SubnetId": "subnet-04a636d18e83cfacb",
                    "VpcId": "vpc-1234567890abcdef0",
                }
            ],

It looks like you can request a Private IP address within the NetworkInterfaces block:

            "NetworkInterfaces": [
                {
                    "PrivateDnsName": "ip-10-0-0-157.us-east-2.compute.internal",
                    "PrivateIpAddress": "10.0.0.157",
                    "SourceDestCheck": true,
                    "Status": "in-use",
                    "SubnetId": "subnet-04a636d18e83cfacb",
                    "VpcId": "vpc-1234567890abcdef0",
                }
            ],
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文