Has anyone here been able to create an ec2 instanc...
# python
b
Has anyone here been able to create an ec2 instance resource using the aws.ec2 module and increase the drive using the root_block_device variable? Im getting the following error:
Copy code
AssertionError: Unexpected type. Expected 'list' got '<class 'pulumi_aws.ec2._inputs.InstanceRootBlockDeviceArgs'>'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
In pulumi I cant figure out how to convert the class to a list, Or even if I should be doing that. Im sure there's a pulumi way of doing this. Please point me in the right direction. Code:
Copy code
for i in range(5):
    server = aws.ec2.Instance(f"webserver-{i:03}",
        ami=ami.id,
        iam_instance_profile='ec2_role',
        instance_type=size,
        key_name=sshKey,
        root_block_device=[aws.ec2.InstanceRootBlockDeviceArgs(
            device_name='/dev/sda1',
            volume_size=100,
            volume_type='gp3',
            )],
        subnet_id=['subnet-xxxxxxxxxxxxxxxx'],
        tags={
            "Name": f"webserver-{i:03}",
            "Purpose": "webapp"
        },
        volume_tags={
            "Name": f"webserver-{i:03}",
            "Purpose": "webapp"
        },
        vpc_security_group_ids=[ secgrp.id ]

    )
https://www.pulumi.com/docs/reference/pkg/aws/ec2/instance/#instancerootblockdevice
a
To me it seems as it's expecting
InstanceRootBlockDeviceArgs
but you are passing a list of a single
InstanceRootBlockDeviceArgs
in the code you posted. The definition does not seem to expect a list:
Copy code
root_block_device: Optional[pulumi.Input[pulumi.InputType['InstanceRootBlockDeviceArgs']]] = None,
b
Thanks for replying and pointing me in the right direction. The issue was the subnet_id.