0
votes

I am getting error while adding 2 block device mappings for ebs volumes. I am using aws-cdk, python.

Here is the code

    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)}
            ]
        } 
    )

Here is the error I am getting.

jsii.errors.JSIIError: Expected array type, got {"$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"}}}]}} Subprocess exited with error 1

1

1 Answers

0
votes

Latest version of CDK API 1.63.0 for the aws_ec2.Instance class states that block_devices should be a list of aws_ec2.BlockDevice instances link here rather than a dict.