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

Exception Aws::DynamoDB::Errors::ResourceInUseException: Attempt to change a resource which is still in use: Table is being created: terraform_locks #28

Open
alexjfisher opened this issue Jan 19, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@alexjfisher
Copy link
Contributor

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?

(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???)

@tongueroo tongueroo added the help wanted Extra attention is needed label Jan 19, 2024
@alexjfisher
Copy link
Contributor Author

At the moment, I've gone with

<%- dynamodb_table = expansion(':TYPE') == 'stack' ? "terraform_locks_#{expansion(':MOD_NAME')}" : 'terraform_locks' %>
terraform {
  backend "s3" {
    bucket         = "<%= expansion('terraform-state-:ACCOUNT-:REGION-:ENV') %>"
    key            = "<%= expansion(':PROJECT/:REGION/:APP/:ROLE/:ENV/:EXTRA/:BUILD_DIR/terraform.tfstate') %>"
    region         = "<%= expansion(':REGION') %>"
    dynamodb_table = "<%= dynamodb_table %>"
  }
}

Seems to work ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants