【问题标题】:Cloud formation - Device index cannot be empty云的形成-设备索引不能为空
【发布时间】:2018-10-16 06:38:23
【问题描述】:

我一直在尝试让两个实例加入域,一个成为 dc。该代码来自其中一个模板,但是它不允许我在修改后运行它。 当 DC01 实例启动时,我收到错误 DeviceIndex 不能为空。 这是 DC01 的代码

 {
    "Resources": {
        "DC1": {
            "Type": "AWS::EC2::Instance",
            "Properties": {
                "BlockDeviceMappings": [
                    {
                        "DeviceName": "/dev/sda1",
                        "Ebs": {
                            "VolumeSize": "40"
                        }
                    }
                ],
                "ImageId": {
                    "Ref": "BaseAmiId"
                },
                "InstanceType": "t2.micro",
                "KeyName": {
                    "Ref": "KeyName"
                },
                "NetworkInterfaces": [
                    {
                        "AssociatePublicIpAddress": "false",
                        "DeleteOnTermination": "true",
                        "DeviceIndex": "0",
                        "GroupSet": [
                            {
                                "Ref": "PrivateSecurityGroup"
                            }
                        ],
                        "PrivateIpAddress": "10.1.3.100"
                    },
                    {
                        "SubnetId": {
                            "Ref": "PrivateSubnetAZ1"
                        }
                    }
                ],
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": "DC1"
                    }
                ],
                "UserData": {
                    "Fn::Base64": {
                        "Fn::Join": [
                            "",
                            [
                                "<script>\n",
                                "cfn-init.exe -v -c config -s ",
                                {
                                    "Ref": "AWS::StackId"
                                },
                                " -r DC1",
                                " --region ",
                                {
                                    "Ref": "AWS::Region"
                                },
                                "\n",
                                "</script>\n"
                            ]
                        ]
                    }
                }
            }
        }
    }
}

【问题讨论】:

    标签: json amazon-web-services amazon-ec2 amazon-cloudformation


    【解决方案1】:

    您已经在网络接口中创建了 json 格式。所以,它正在考虑第二个。请尝试以下代码 sn-p。

    {
        "Resources": {
            "DC1": {
                "Type": "AWS::EC2::Instance",
                "Properties": {
                    "BlockDeviceMappings": [
                        {
                            "DeviceName": "/dev/sda1",
                            "Ebs": {
                                "VolumeSize": "40"
                            }
                        }
                    ],
                    "ImageId": {
                        "Ref": "BaseAmiId"
                    },
                    "InstanceType": "t2.micro",
                    "KeyName": {
                        "Ref": "KeyName"
                    },
                    "NetworkInterfaces": [
                        {
                            "SubnetId": {
                                "Ref": "PrivateSubnetAZ1"
                            },
                            "AssociatePublicIpAddress": "false",
                            "DeleteOnTermination": "true",
                            "DeviceIndex": "0",
                            "GroupSet": [
                                {
                                    "Ref": "PrivateSecurityGroup"
                                }
                            ],
                            "PrivateIpAddress": "10.1.3.100"
                        }
                    ],
                    "Tags": [
                        {
                            "Key": "Name",
                            "Value": "DC1"
                        }
                    ],
                    "UserData": {
                        "Fn::Base64": {
                            "Fn::Join": [
                                "",
                                [
                                    "<script>\n",
                                    "cfn-init.exe -v -c config -s ",
                                    {
                                        "Ref": "AWS::StackId"
                                    },
                                    " -r DC1",
                                    " --region ",
                                    {
                                        "Ref": "AWS::Region"
                                    },
                                    "\n",
                                    "</script>\n"
                                ]
                            ]
                        }
                    }
                }
            }
        }
    }
    

    解决问题

    【讨论】:

      猜你喜欢
      • 2022-10-03
      • 2019-08-01
      • 1970-01-01
      • 2017-05-08
      • 2023-03-06
      • 2015-03-02
      • 2020-05-01
      • 2018-02-21
      • 2020-01-11
      相关资源
      最近更新 更多