https://pulumi.com logo
Title
a

alert-raincoat-81485

02/22/2021, 9:57 PM
Getting an error while detaching EBS volume(s) from instance(s) on pulumi.
aws:ec2:VolumeAttachment (ebsatt1-asg03):
    error: deleting urn:pulumi:asg-ex-03::asg::aws:ec2/volumeAttachment:VolumeAttachment::ebsatt1-asg03: 1 error occurred:
    	* Failed to detach Volume (vol-*********) from Instance (i-*******): IncorrectState: Volume 'vol-*******' is in the 'available' state.
    	status code: 400, request id: 80154710-********
While checking it from the Ui, it shows the volumes are already detached from the instances, also instances are terminated. I deleted the volumes manually, but showing the same error messages while running pulumi destroy. Can someone explain the issue here?
w

witty-candle-66007

02/22/2021, 10:01 PM
The main error is because Pulumi still thinks the volume is attached and gets an error back from AWS when it tries to detach an “available” volume. I’m not sure how it got in this state, but if you do a
pulumi refresh -y
that will synchronize Pulumi state with AWS and then allow you to do the
pulumi destroy
a

alert-raincoat-81485

02/22/2021, 10:07 PM
Well EBS state
available
means the EBS volumes are already detached from the instance and it’s
available
to use/attach to other instances. It make sense while pulumi prompts an error message of “failed to detach volume” while EBS is
in-use
state.
Here *
Failed to detach Volume (vol-*********) from Instance (i-*******): IncorrectState: Volume 'vol-*******' is in the 'available' state.
status code: 400, request id: 80154710-********
it shows the volume pulumi is trying to detach is already detached an already in
available
state
w

witty-candle-66007

02/22/2021, 10:20 PM
Right. That’s because Pulumi’s state model still has the volume as attached and is telling AWS to detach it. AWS is then coming back with an error message saying it’s already detached - that’ the
status code: 400...
bit. Did you try the
pulumi refresh
? That will update Pulumi’s state to synchronize it with AWS - essentially detaching the volume in the state model. That should then allow subsequent
pulumi up
or
pulumi destroy
to proceed as expected.
b

billowy-army-68599

02/22/2021, 10:28 PM
would you mind sharing your code? my suspicion here is that it's deleting the ASG before the detach call can happen