I am trying to configure a shared EBS volume for an autoscaling group in AWS.
I cannot figure out how to get the external volume attached to instances using CDK constructs.
const sharedVolume = new ec2.Volume(this, 'shared-volume', {
availabilityZone: 'us-east-1b',
size: cdk.Size.gibibytes(100),
volumeName: 'shared-host-volume',
volumeType: EbsDeviceVolumeType.IO2,
enableMultiAttach: true
});
const launchTemplate = new ec2.LaunchTemplate(this, 'web-launch-template', {
associatePublicIpAddress: true,
launchTemplateName: 'web-host-template',
role: role,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, InstanceSize.MEDIUM),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
userData: ec2.UserData.forLinux(),
keyPair: keyPair,
securityGroup: this.props.applicationSecurityGroup,
blockDevices: [ ]
});
const scalingGroup = new asg.AutoScalingGroup(this, 'web-scaling-group', {
autoScalingGroupName: 'web-scaling-group',
vpc: props.vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC
},
desiredCapacity: 1,
maxCapacity: 2,
minCapacity: 0,
launchTemplate: launchTemplate,
});
The blockDevices array on the LaunchTemplate expects a type of BlockDeviceVolume.
What I need is an external Volume with Multi-Attach enabled so I can allow at least 2 instances to attach to this device.