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

Double / in DynamoDB table items LockID field when using S3 bucket folder #22965

Closed
obourdon opened this issue Oct 1, 2019 · 15 comments
Closed
Labels
backend/s3 bug v0.11 Issues (primarily bugs) reported against v0.11 releases

Comments

@obourdon
Copy link

obourdon commented Oct 1, 2019

Terraform Version

0.11.14

Terraform Configuration Files

backend-test.tfvars

bucket = "s3-ACCOUNT_ID-tfstate/eu-west-1/"
dynamodb_table = "dynamodb-ACCOUNT_ID-tflock"
region = "eu-west-1"

Expected Behavior

Entries in DynamoDB table should have their LockID field looking like:

s3-ACCOUNT_ID-tfstate/eu-west-1/step1.tfstate-md5

Actual Behavior

Entries in DynamoDB table have their LockID field being:

s3-ACCOUNT_ID-tfstate/eu-west-1//step1.tfstate-md5

One could argue that we might want to remove the / at the very end of the bucket = entry in backend-test.tfvars. However, doing so will make terraform think eu-west-1 being a bucket file entry and not a directory entry and therefore further steps (this is why step1 is mentioned above) will overwrite each another

References

Having done a quick lookup in the code I guess this "error" comes from these lines of code

@teamterraform teamterraform added v0.11 Issues (primarily bugs) reported against v0.11 releases backend/s3 labels Oct 1, 2019
@teamterraform
Copy link
Contributor

Hello, to better understand this issue & make it easier to reproduce for anyone else would you mind sharing more details? e.g.

  • full output (stdout + stderr) from terraform commands you ran (minus any secrets)
  • debug log from terraform commands you ran (minus any secrets)

Thanks.

@hashibot hashibot added the bug label Oct 2, 2019
@obourdon
Copy link
Author

obourdon commented Oct 2, 2019

@teamterraform complete example can be found in this repository I created on purpose

@obourdon
Copy link
Author

obourdon commented Oct 2, 2019

Commands used and outputs also included in the repo

@obourdon
Copy link
Author

obourdon commented Oct 2, 2019

@teamterraform I confirm that changing line 398 from:

return fmt.Sprintf("%s/%s", c.bucketName, c.path)

to

return strings.ReplaceAll(fmt.Sprintf("%s/%s", c.bucketName, c.path), "//", "/")

and of course adding strings as import just works

@obourdon
Copy link
Author

obourdon commented Oct 7, 2019

@teamterraform any progress on this ?

1 similar comment
@obourdon
Copy link
Author

@teamterraform any progress on this ?

@obourdon
Copy link
Author

obourdon commented Nov 5, 2019

Any one please ??? this is an easy one

@obourdon
Copy link
Author

obourdon commented Nov 15, 2019

@ewbankkit @bflad @aeschright anybody ?

@obourdon
Copy link
Author

Any news ?

@obourdon
Copy link
Author

Anybody to integrate the fix ?

@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 30, 2019

Maybe related:

@obourdon In hashicorp/terraform-provider-aws#7584 I found I had to use
key = regexp.MustCompile(/+).ReplaceAllString(key, "/")
to treat multiple '/'s as a single '/'.
Can you see if the same applies here?
Thanks.

@obourdon
Copy link
Author

@ewbankkit I've just checked your version of terraform-provider-aws with my example but unfortunately, and as I expected, the behaviour is still the same. From what I've seen in the code and as mentioned above the fix seems to be relative to terraform core code (which I have checked to be working on my side). Thanks anyways for pointing this out

@obourdon
Copy link
Author

@teamterraform any progress on this easy one ?

@danieldreier
Copy link
Contributor

I want to apologize for the slow response time on this issue, and also let you know that I am bulk-closing all issues exclusively reported against Terraform 0.11.x, including this issue, because we are no longer investigating issues reported against Terraform 0.11.x. In most cases, when we try to reproduce issues reported against 0.11, we either can't reproduce them anymore, or the reporter has moved on, so we believe we can better support the Terraform user community by prioritizing more recent issues.

Terraform 0.12 has been available since May of 2019, and there are really significant benefits to adopting it. I know that migrating from 0.11 to versions past 0.12 can require a bit of effort, but it really is worth it, and the upgrade path is pretty well understood in the community by now. 0.14 is available and stable, and we are quickly approaching an 0.15 release.

We have made a significant effort in the last year to stay on top of bug reports; we have triaged almost all new bug reports within 1-2 weeks for 6+ months now. If you are still experiencing this problem, please submit a new bug report with a reproduction case that works on 0.14.x, link this old issue for context, and we will triage it.

@ghost
Copy link

ghost commented Feb 27, 2021

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 as resolved and limited conversation to collaborators Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend/s3 bug v0.11 Issues (primarily bugs) reported against v0.11 releases
Projects
None yet
Development

No branches or pull requests

5 participants