为ebs卷添加2个块设备映射时出现错误。我正在使用aws-cdk,python。
这是代码
from aws_cdk import core
from aws_cdk import aws_ec2 as _ec2
#Webserver 01
webserver = _ec2.Instance(
self,
"webserver01Id",
instance_type = _ec2.InstanceType(instance_type_identifier="t2.micro"),
instance_name = "webserver001",
machine_image = _amzn_linux_ami,
vpc=vpc,
vpc_subnets = _ec2.SubnetSelection(subnet_type=_ec2.SubnetType.PUBLIC),
user_data = _ec2.UserData.custom(_user_data),
block_devices= {"block_device_mappings": [
{"device_name ": '/dev/sda1', "volume": _ec2.BlockDeviceVolume.ebs(50)},
{"device_name": '/dev/sdm', "volume": _ec2.BlockDeviceVolume.ebs(100)}
]
}
)
这是我遇到的错误。
jsii.errors.JSIIError:预期的数组类型,得到了{“ $ jsii.map”:{“ block_device_mappings”:[{“ $ jsii.map”:{“ device_name”:“ / dev / sda1”,“ volume “:{” $ jsii.byref“:” @ aws-cdk/aws-ec2.BlockDeviceVolume@10012“}}},{” $ jsii.map“:{” device_name“:” / dev / sdm“,” volume “:{” $ jsii.byref“:” @ aws-cdk/aws-ec2.BlockDeviceVolume@10013“}}}]}} 子流程退出,错误1