Skip to content
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

S3 bucket force_destroy error: MalformedXML #4168

Merged
merged 1 commit into from
Dec 8, 2015
Merged

S3 bucket force_destroy error: MalformedXML #4168

merged 1 commit into from
Dec 8, 2015

Conversation

combor
Copy link
Contributor

@combor combor commented Dec 4, 2015

While doing forced destroy and if versioning is enabled for a bucket, AWS provider is not checking whether DeleteMarkers and versions of objects are left resulting in following error:

$$: terraform destroy -force -var env=piotr -state ~/Downloads/bucket.tfstate.json -var force_destroy=true
aws_s3_bucket.terraform-state-s3: Refreshing state... (ID: piotr-state)
aws_s3_bucket.terraform-state-s3: Destroying...
Error applying plan:

1 error(s) occurred:

* aws_s3_bucket.terraform-state-s3: Error S3 Bucket force_destroy error deleting: MalformedXML: The XML you provided was not well-formed or did not validate against our published schema
        status code: 400, request id:

s3conn.ListObjects is checking only wheter there are objects (not versions) in the bucket causing s3.DeleteObjects to send empty XML which results in 400 error and MalformedXML message.

In this PR I'm using ListObjectVersions to get Versions and DeleteMarkers slice and create objectsToDelete slice that is passed to s3conn.DeleteObjects
After this change AWS provider is able to delete all versions and delete markers for versioned S3 bucket and finally properly delete versioned bucket.

AWS provider was not checking whether DeleteMarkers are left in S3
bucket causing s3.DeleteObjectsInput to send empty XML which resulted in
400 error and MalformedXML message.
mtekel added a commit to alphagov/paas-cf that referenced this pull request Dec 7, 2015
Add a pipeline to destroy environments. It currently consists of 2 jobs
- one to destroy VPC which then triggers a job to destroy S3 bucket. We
used default/recommended pipeline/task/script distribution with this
pipeline. We include taks from file, because this task repeats. Never-
theless, in this case, the pipeline needs to contain quite chunky
config definitions (params), because they can't be included in the task
itself, due to fly only expanding params in the pipeline.

In comparison with deploy pipeline, we don't use terraform's ability to
pull remote state file, due to bug encountered with `bucket.tfstate`:
hashicorp/terraform#4154

The remote state file worked with VPC, but we wanted to unify both
tasks on same code to demonstrate default concourse pipeline file
organization.

We also use fake/dummy `trigger-bucket-destroy` resource here to trigger
bucket destroy job after vpc destroy job.

The terraform bucket destroy job currently doesnt't work, due to bugs:
hashicorp/terraform#3981

and missing functionality - the old file versions are actually not
removed. @combor has risen PR to add this functionality here:
hashicorp/terraform#4168
combor pushed a commit to alphagov/paas-docker-terraform that referenced this pull request Dec 8, 2015
Due to bug in Terraform (
        hashicorp/terraform#4168 ) we have to
use our patched fork to be able to delete S3 buckets. Also, we need to
reduce size of this contaier so it is using Alipne linux now instead
Ubuntu.
@catsby
Copy link
Contributor

catsby commented Dec 8, 2015

Checks out, thanks!

@catsby catsby closed this Dec 8, 2015
@catsby catsby reopened this Dec 8, 2015
@catsby
Copy link
Contributor

catsby commented Dec 8, 2015

whoops, didn't mean to close..

catsby added a commit that referenced this pull request Dec 8, 2015
S3 bucket force_destroy error: MalformedXML
@catsby catsby merged commit 9f5f306 into hashicorp:master Dec 8, 2015
@combor combor deleted the malformed_xml_fix branch December 8, 2015 21:37
@aviflax
Copy link

aviflax commented Dec 30, 2015

Just curious, is there maybe an ETA for the next release containing this fix? Thanks! And happy new year!

@catsby
Copy link
Contributor

catsby commented Jan 4, 2016

Sorry @aviflax , we don't give ETAs really. I can say that we had meant to release before the holidays but hid a blocker, so we had to delay. I expect a release soon, hopefully this week 😄

@aviflax
Copy link

aviflax commented Jan 4, 2016 via email

@ghost
Copy link

ghost commented Apr 29, 2020

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.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants