-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_spot_instance_request failure causes dependent resources to block further use of terraform #15672
Comments
Hi @matthewfranglen, thanks for raising this issue. It looks like there are several issues coming together here. Firstly, there's an open issue on the Terraform Plugin SDK which is causing state to be written even when there's an error. Secondly, when Lastly, if the Spot request doesn't launch an instance, there will be no value for resource "aws_ec2_tag" "my_tag" {
count = aws_spot_instance_request.my_request.spot_instance_id == "" ? 0 : 1
resource_id = aws_spot_instance_request.my_request.spot_instance_id
key = "Name"
value = "my-instance"
} |
I've created #15674 to address the states |
Thanks for the tip about using count. I'll give that a go. Please let me know if I can be of any more help. |
The count approach doesn't really work out unfortunately. This error occurs for both apply and delete:
As a workaround it's easier to just fix the state with |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.13.4
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
terraform state list
should not containaws_spot_instance_request.my_request
terraform destroy
should not fail with an error.terraform apply
should not fail with an error.Actual Behavior
When creating the spot instance the apply fails with the error:
Once this error has occurred subsequent use of the
terraform apply
andterraform destroy
commands fail with the error:Error: "resource_id": required field is not set
This error is produced for the
resource "aws_ec2_tag" "my_tag"
.The failure means that destroy and apply cannot complete.
The resource for the spot instance has been created and can be viewed with
terraform state list
.Running
terraform state rm aws_spot_instance_request.my_request
will fix the state and allow apply and destroy to work.Steps to Reproduce
2a. Perform
terraform state list
, see resource for spot instance request.2b. Perform
terraform destroy
, see error.2c. Perform
terraform apply
, see error.Important Factoids
References
The text was updated successfully, but these errors were encountered: