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

【Help me】Error: error creating DynamoDB Table: ResourceInUseException: Table already created #1

Open
tanpenggood opened this issue Dec 14, 2021 · 0 comments

Comments

@tanpenggood
Copy link

hi davidlu,

非常感谢你的分享,我正在使用你的repository学习terraform。

目前我执行make plan成功,但是执行make apply报错。你能帮我解决一下吗?

报错如下:

[root@centos7 demo-terraform-localstack]# make plan
sudo rm -rf .terraform
rm -f current.plan
rm -f *.tf.json
terraform init

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Installing hashicorp/aws v3.69.0...
- Installed hashicorp/aws v3.69.0 (signed by HashiCorp)

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform plan -out current.plan 

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  + create

Terraform will perform the following actions:

  # aws_dynamodb_table.terraform_state_lock will be created
  + resource "aws_dynamodb_table" "terraform_state_lock" {
      + arn              = (known after apply)
      + billing_mode     = "PAY_PER_REQUEST"
      + hash_key         = "LockID"
      + id               = (known after apply)
      + name             = "terraform-lock"
      + read_capacity    = 5
      + stream_arn       = (known after apply)
      + stream_label     = (known after apply)
      + stream_view_type = (known after apply)
      + tags_all         = (known after apply)
      + write_capacity   = 5

      + attribute {
          + name = "LockID"
          + type = "S"
        }

      + point_in_time_recovery {
          + enabled = (known after apply)
        }

      + server_side_encryption {
          + enabled     = (known after apply)
          + kms_key_arn = (known after apply)
        }
    }

  # aws_s3_bucket.terraform_state will be created
  + resource "aws_s3_bucket" "terraform_state" {
      + acceleration_status         = (known after apply)
      + acl                         = "private"
      + arn                         = (known after apply)
      + bucket                      = "terraform-state"
      + bucket_domain_name          = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags_all                    = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + server_side_encryption_configuration {
          + rule {
              + apply_server_side_encryption_by_default {
                  + sse_algorithm = "AES256"
                }
            }
        }

      + versioning {
          + enabled    = true
          + mfa_delete = false
        }
    }

  # aws_s3_bucket_public_access_block.terraform_state_access will be created
  + resource "aws_s3_bucket_public_access_block" "terraform_state_access" {
      + block_public_acls       = true
      + block_public_policy     = true
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = true
      + restrict_public_buckets = true
    }

Plan: 3 to add, 0 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Saved the plan to: current.plan

To perform exactly these actions, run the following command to apply:
    terraform apply "current.plan"
terraform show -no-color current.plan > txt.plan
[root@centos7 demo-terraform-localstack]# make apply
terraform apply -auto-approve  current.plan 
aws_dynamodb_table.terraform_state_lock: Creating...
aws_s3_bucket.terraform_state: Creating...
╷
│ Error: Error creating S3 bucket: BucketAlreadyOwnedByYou: Your previous request to create the named bucket succeeded and you already own it.
│       status code: 409, request id: 7XSDCUTVB020XY8JFXFVTDOJ8X99DKIDDYPD61PLB3A5QZS1GZ64, host id: MzRISOwyjmnup5A859874F966193B7/JypPGXLh0OVFGcJaaO3KW/hRAqKOpIEEp
│ 
│   with aws_s3_bucket.terraform_state,
│   on main.tf line 33, in resource "aws_s3_bucket" "terraform_state":
│   33: resource "aws_s3_bucket" "terraform_state" {
│ 
╵
╷
│ Error: error creating DynamoDB Table: ResourceInUseException: Table already created
│ 
│   with aws_dynamodb_table.terraform_state_lock,
│   on main.tf line 62, in resource "aws_dynamodb_table" "terraform_state_lock":
│   62: resource "aws_dynamodb_table" "terraform_state_lock" {
│ 
╵
make: *** [apply] Error 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant