Terraform: Doc Improvement - Can the same DynamoDB table lock multiple state files for the S3 backend?

Created on 15 Jun 2017  ยท  6Comments  ยท  Source: hashicorp/terraform

Terraform Version

N/A

Terraform Configuration Files

N/A

Debug Output

N/A

Panic Output

N/A

Expected Behavior

https://www.terraform.io/docs/backends/types/s3.html#dynamodb_table

The documentation should specify whether the same DynamoDB table can be used by multiple AWS providers to lock multiple state files. e.g., can I create one DynamoDB table in my account, call it terraform-lock, and specify it as the dynamodb_table parameter in every AWS provider I create?

Actual Behavior

The documentation does not make it clear whether one DynamoDB table can lock all state files stored in that AWS account, or whether each state file needs its own one-row DynamoDB table.

The answer probably seems obvious to the person who wrote the module, but it's not obvious to the end-user.

Steps to Reproduce

N/A (Read the documentation? :smile:)

Important Factoids

N/A

References

N/A

backens3 documentation

Most helpful comment

For anyone looking for the answer, it's yes: the same DynamoDB table can lock as many S3 remote state files as you want. It creates a separate row in the table for each state file.

I haven't tested this for different state buckets, only for different state files stored in the same bucket.

It would still be nice to see this information added to the documentation.

All 6 comments

Same question here. Can I manage multiple state files via the same DynamoDB table, by giving each TF config a separate key?

Would also be interested in seeing an update for this.

For anyone looking for the answer, it's yes: the same DynamoDB table can lock as many S3 remote state files as you want. It creates a separate row in the table for each state file.

I haven't tested this for different state buckets, only for different state files stored in the same bucket.

It would still be nice to see this information added to the documentation.

To extend @geekofalltrades's answer, you can use the same DDB table for different state file buckets: the lock key in the DDB table is prefixed with the bucket name.

The linked PR should have closed this issue, so I'll do so now. Thanks!

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.

Was this page helpful?
0 / 5 - 0 ratings