Skip to content

Commit 1e10c28

Browse files
authored
docs: add S3 native locking docs and fix variable descriptions (#197)
- Fix s3_state_lock_enabled description (was incorrectly 'Whether to create the S3 bucket', now describes S3 native state locking) - Add deprecation note to dynamodb_enabled description with link to official Terraform docs - Add 'S3 Native State Locking' section to README with usage example showing s3_state_lock_enabled=true and dynamodb_enabled=false Ref: https://developer.hashicorp.com/terraform/language/backend/s3#s3-state-locking Ref: https://developer.hashicorp.com/terraform/language/backend/s3#enabling-dynamodb-state-locking-deprecated Closes #188 Closes #194
1 parent 27f1ddf commit 1e10c28

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,39 @@ Follow this procedure just once to create your deployment.
132132
This concludes the one-time preparation. Now you can extend and modify your
133133
Terraform configuration as usual.
134134

135+
### S3 Native State Locking (Terraform >= 1.10)
136+
137+
Starting with Terraform 1.10, S3 supports [native state locking](https://developer.hashicorp.com/terraform/language/backend/s3#s3-state-locking)
138+
via `use_lockfile = true`, removing the need for a DynamoDB table.
139+
140+
> **Note**: DynamoDB-based state locking is [deprecated](https://developer.hashicorp.com/terraform/language/backend/s3#enabling-dynamodb-state-locking-deprecated)
141+
> in Terraform 1.10+. New setups should use S3 native locking instead.
142+
143+
To use S3 native locking instead of DynamoDB:
144+
145+
```hcl
146+
module "terraform_state_backend" {
147+
source = "cloudposse/tfstate-backend/aws"
148+
149+
namespace = "eg"
150+
stage = "test"
151+
name = "terraform"
152+
attributes = ["state"]
153+
154+
# Use S3 native locking (Terraform >= 1.10)
155+
s3_state_lock_enabled = true
156+
157+
# Disable DynamoDB table (not needed with S3 native locking)
158+
dynamodb_enabled = false
159+
160+
terraform_backend_config_file_path = "."
161+
terraform_backend_config_file_name = "backend.tf"
162+
force_destroy = false
163+
}
164+
```
165+
166+
The generated `backend.tf` will use `use_lockfile = true` instead of `dynamodb_table`.
167+
135168
### Destroy
136169

137170
Follow this procedure to delete your deployment.

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ variable "bucket_enabled" {
182182
variable "s3_state_lock_enabled" {
183183
type = bool
184184
default = false
185-
description = "Whether to create the S3 bucket."
185+
description = "Whether to use S3 native state locking (use_lockfile). Requires Terraform >= 1.10. When enabled, DynamoDB is not needed for state locking. See https://developer.hashicorp.com/terraform/language/backend/s3#s3-state-locking"
186186
}
187187

188188
variable "dynamodb_enabled" {
189189
type = bool
190190
default = true
191-
description = "Whether to create the DynamoDB table."
191+
description = "Whether to create the DynamoDB table for state locking. Note: DynamoDB-based locking is deprecated in Terraform >= 1.10 in favor of S3 native locking (s3_state_lock_enabled). See https://developer.hashicorp.com/terraform/language/backend/s3#enabling-dynamodb-state-locking-deprecated"
192192
}
193193

194194
variable "dynamodb_table_name" {

0 commit comments

Comments
 (0)