terraform-provider-aws: Cognito domain doesn't delete during destroy

Terraform Version

Terraform v0.10.8 AWS provider 1.21.0

Affected Resource(s)

aws_cognito_user_pool_domain

Terraform Configuration Files

Below is an excerpt from terraform file to create aws_cognito_user_pool_domain .

# Pool domain
resource "aws_cognito_user_pool_domain" "domain" {
  domain       = "${var.userpooldomain}"
  user_pool_id = "${aws_cognito_user_pool.pool.id}"
}

Debug Output

Panic Output

Expected Behavior

domain should be deleted by terraform apply, when the resource is marked for destroy.

Actual Behavior

Domain isn’t deleted and throws error message

aws_cognito_user_pool_domain.domain: InvalidParameter: 1 validation error(s) found.

  • minimum field size of 1, DeleteUserPoolDomainInput.UserPoolId.

Steps to Reproduce

  1. Change the module name
  2. Run terraform plan and apply(Module name is changed and existing pool is deleted and a new user pool(with new name) is created.
  3. Modify any change for the new user pool
  4. terraform plan
  5. terraform apply

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 57
  • Comments: 18 (3 by maintainers)

Most upvoted comments

Similar workaround here as @haruharuharuby , but I’d recommend using the terraform state rm command, rather than manually messing with your state file directly.

eg.

terraform state rm aws_cognito_user_pool_domain.my_domain

For the record, I’m using TF v0.12.8, and aws provider v2.43.0

+1 for now i solved this using a custom script, leveraging the aws cli, to delete the domain, on destroy and update.

opened #14732 to address this.

I saw same issue. I fix this my work around.

  • terraform refresh
  • remove “aws_cognito_user_pool_domain” block in .tfstate
  • terraform apply

this is my environment -> % terraform version Terraform v0.11.13

  • provider.aws v2.41.0

+1