late-lock-17022
10/07/2021, 7:56 PMdata_volume = ebs.Volume("Ghost Data",
availability_zone=default_az,
size=10,
type="gp3",
tags={
"Name": "Ghost data"
}
)
ghost_instance = ec2.Instance("Ghost",
instance_type="t4g.small",
ami=default_ami.id,
root_block_device=ec2.InstanceRootBlockDeviceArgs(
delete_on_termination=True,
volume_type="gp3",
tags={
"Name": "Ghost root device"
}
),
availability_zone=default_az,
vpc_security_group_ids=[
security_groups.sg_web_access.id,
security_groups.sg_ssh_access.id,
security_groups.sg_all_outbound.id
],
key_name="chipnibbles-aws-keys",
tags={
"Name": "Ghost Instance"
}
)
second_disk = ec2.VolumeAttachment("Second Disk",
device_name="/dev/sdh",
volume_id=data_volume.id,
instance_id=ghost_instance.id,
force_detach=True
)
The problem I’m facing right now is when I’m trying to update the ghost_instance
pulumi fails on the Volume Attachment replacement.
View Live: <https://app.pulumi.com/Regrau/chipnibbles-infrastructure/dev/updates/26>
Type Name Status Info
pulumi:pulumi:Stack infrastructure-dev **failed** 1 error
+- └─ aws:ec2:VolumeAttachment Second Disk **replacing failed** [diff: ~instanceId]; 1 error
Diagnostics:
aws:ec2:VolumeAttachment (Second Disk):
error: 1 error occurred:
* Error attaching volume (vol-07e61ae7f6062403f) to instance (i-002f5a8d58c0bb000), message: "vol-07e61ae7f6062403f is already attached to an instance", code: "VolumeInUse"
I’m still not quite sure if the problem is with pulumi or AWS itself. I get the error code, but it seems wrong that pulumi does not detach the volume before changing the attached instance id. Why is that a limitation and are there any workarounds?
Can anybody help me out here please?
It is worth mentioning that I want to mount the second ebs volume for database storage. I’d use EFS but it would be to slow for that purpose.little-cartoon-10569
10/07/2021, 8:12 PMdeleteBeforeReplace
opt to the attachment. https://www.pulumi.com/docs/intro/concepts/resources/#deletebeforereplacelittle-cartoon-10569
10/07/2021, 8:12 PMlittle-cartoon-10569
10/07/2021, 8:14 PMlate-lock-17022
10/07/2021, 8:22 PMworried-city-86458
10/08/2021, 3:35 AMforce_detach
then? deleteBeforeReplace
should be sufficient...late-lock-17022
10/08/2021, 7:44 AM