Fix Terraform Kinesis Stream - ResourceInUseException
Fix AWS Kinesis stream name conflict errors in Terraform. Handle duplicate streams, import existing resources, shard count changes, and stream modes.
Troubleshooting
Fix DynamoDB ResourceInUseException in Terraform. Handle table name conflicts, import existing tables, and manage GSI and throughput changes.
A DynamoDB table with the same name already exists in the region. Import it into Terraform with terraform import, use a unique name, or delete the existing table if it's orphaned.
Error: creating DynamoDB Table (terraform-locks):
ResourceInUseException: Table already exists: terraform-locksError: creating DynamoDB Table: ResourceInUseException:
Attempt to change a resource which is still in useA table with the same name was created manually, by another Terraform workspace, or by CloudFormation.
The table is currently being updated (adding/removing GSIs, changing capacity) and can't accept another modification.
Terraform created the table but crashed before recording it in state.
# Check if table exists
aws dynamodb describe-table --table-name terraform-locks --region us-east-1
# Import into Terraform
terraform import aws_dynamodb_table.terraform_locks terraform-locks# Ensure your config matches the existing table
resource "aws_dynamodb_table" "terraform_locks" {
name = "terraform-locks"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}resource "aws_dynamodb_table" "app_data" {
name = "${var.project}-${var.environment}-data"
billing_mode = "PAY_PER_REQUEST"
hash_key = "pk"
range_key = "sk"
attribute {
name = "pk"
type = "S"
}
attribute {
name = "sk"
type = "S"
}
}# Check table status
aws dynamodb describe-table --table-name my-table \
--query 'Table.TableStatus'
# Wait until ACTIVE before retrying
aws dynamodb wait table-exists --table-name my-table
terraform applyaws dynamodb describe-table)ManagedBy = "terraform" for easy identificationResourceInUseException means a DynamoDB table with that name already exists or is being modified. Import the existing table, use unique naming conventions, or wait for in-progress operations to complete before retrying.
Fix AWS Kinesis stream name conflict errors in Terraform. Handle duplicate streams, import existing resources, shard count changes, and stream modes.
Fix AWS MSK cluster throttling errors in Terraform. Handle API rate limits, retry configuration, reduce parallelism, and manage long cluster creation times.
Fix ElastiCache cluster name conflicts in Terraform. Import existing clusters, use unique naming conventions, and handle replication group configurations.
Fix AWS Step Functions duplicate state machine errors in Terraform. Covers naming conflicts, import, definition updates, and versioning patterns.