Open heuristics222 opened 3 years ago
I found a workaround (Python)
volume = ec2.Volume(self, 'serverVolume',
removal_policy=cdk.RemovalPolicy.RETAIN,
...
)
instance = ec2.Instance(self, 'serverInstance',
instance_type=ec2.InstanceType('t3a.small'),
...
)
instance.node.default_child.volumes = [
ec2.CfnInstance.VolumeProperty(
device='/dev/sda1',
volume_id=volume.volume_id,
)
]
Thanks for the feature request and work-around! I'm a bit surprised this is a gap in the Instance construct, but so it is.
I've tagged this as P1, which means it should be on our near-term roadmap.
We welcome community contributions! If you are able, we encourage you to contribute. If you decide to contribute, please start an engineering discussion in this issue to ensure there is a commonly understood design before submitting code. This will minimize the number of review cycles and get your code merged faster.
This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.
Still relevant
ec2.Instance only currently supports attaching volumes with type BlockDeviceVolume. See https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.Instance.html#blockdevices and https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-ec2.BlockDevice.html
Use Case
CloudFormation supports attaching Volumes created separately from the Instance. It would be nice to have the same support for the L2 CDK classes.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html#cfn-ec2-instance-volumes
Proposed Solution
I believe this would involve adding a new property,
volumes
to Instance of a type that maps a device name to Volume. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-mount-point.htmlOther
This is a :rocket: Feature Request