boltops-tools / boltops-tools/terraspace_plugin_aws
Exception Aws::DynamoDB::Errors::ResourceInUseException: Attempt to change a resource which is still in use: Table is being created: terraform_locks
- Dominant language
- Ruby
- Stars
- 1
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I think there is a race condition during `terraspace all up` if batch 1 contains more than 1 stack and the environment has never been used before so doesn't contain a `terraform_locks` dynamodb table.
All stacks try to create the table simultaneously resulting in some failing.
```
[2024-01-19T11:11:32 #20464 terraspace up s3_buckets]: Creating dynamodb table: terraform_locks
[2024-01-19T11:11:33 #20464 terraspace up s3_buckets]: Exception Aws::DynamoDB::Errors::ResourceInUseException: Attempt to change a resource which is still in use: Table is being created: terraform_locks
```
This is with plugin version `0.6.1`
Would it be appropriate to interpolate the stack name into the table name here somehow?
https://github.com/boltops-tools/terraspace_plugin_aws/blob/b2d749bbff8fecfe9296bf2640786b069f4a2825/lib/templates/ruby/project/config/terraform/backend.rb.tt#L9
(I was thinking perhaps append `_:MOD_NAME`, but maybe that causes issues if the stack name contains incompatible characters and is also maybe problematic when `:MOD_NAME` is a module and not a stack???)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with lib/templates/ruby/project/config/terraform/backend.rb.tt at the linked line, then trace how terraspace all up creates the terraform_locks DynamoDB table for multiple stacks in a new environment. Reproduce the first-run batch scenario and verify that concurrent stacks no longer fail with ResourceInUseException while retaining valid lock-table naming.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, ruby, terraform
- Domain
- cloud, databases, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100