gpt4 book ai didi

json - 云形成 - 设备索引不能为空

转载 作者:行者123 更新时间:2023-12-03 07:32:21 25 4
gpt4 key购买 nike

我一直在尝试让两个实例加入域,其中一个是 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"
]
]
}
}
}
}
}
}

最佳答案

您已在网络接口(interface)中创建了 json 格式。所以,正在考虑第二个。请尝试下面的代码片段。

{
"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"
]
]
}
}
}
}
}
}

它将解决问题

关于json - 云形成 - 设备索引不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50197548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com