I'd like to attach an EC2 volume to an EC2 instance I'm creating, but can't figure out how to do it:
const vol = new ec2.Volume(this, 'vol', {
availabilityZone: 'ap-southeast-2a',
size: Size.gibibytes(100),
});
const instance = new ec2.Instance(this, 'my-instance', {
instanceName: 'my-instance',
vpc: vpc,
// how to attach 'vol' as a block device here?
blockDevices: [{ deviceName: '/dev/sdf', volume: { ebsDevice: { deleteOnTermination: false, volumeSize: 1 } } }],
//... more props
});
This code works, though vol is not attached as a block device. How can I achieve this?