terraform-provider-postgresql icon indicating copy to clipboard operation
terraform-provider-postgresql copied to clipboard

Root resource was present, but now absent.

Open ryancausey opened this issue 4 years ago • 3 comments

Terraform Version

Terraform v1.0.11

Affected Resource(s)

  • postgresql_grant_role

Terraform Configuration Files

# Create a django DB user for each jurisdiction
resource "postgresql_role" "django_database_user" {
  for_each = local.jurisdictions

  name     = "${each.key}dbuser"
  login    = true
  password = local.temp_password
}

# Because the RDS master user isn't a true PostgreSQL superuser, we have to grant each
# created user to the master user so the master user can perform actions on their
# behalf.
resource "postgresql_grant_role" "grant_users_to_rds_master" {
  for_each = local.jurisdictions

  role       = local.db_secret_map["username"]
  grant_role = postgresql_role.django_database_user[each.key].name
}

Debug Output

╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to
│ postgresql_grant_role.grant_users_to_rds_master["vistaca"], provider
│ "provider[\"registry.terraform.io/cyrilgdn/postgresql\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
╵

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

The resource should have applied without error.

Actual Behavior

The error above indicating an issue with this provider was output.

Steps to Reproduce

  1. terraform apply

Important Factoids

AWS RDS PostgreSQL

References

N/A

ryancausey avatar Nov 20 '21 19:11 ryancausey

I got this same but in a different context.

I had applied:

resource "postgresql_extension" "my_extension" {
  name = "unaccent"
}

and everything worked well. I then noticed I forgot to name the resource appropriately.

So I then applied this:

resource "postgresql_extension" "unaccent_extension" {
  name = "unaccent"
}

It correctly destroyed the old resource but then failed to create the new one:

postgresql_extension.my_extension: Destroying... [id=underwriting.unaccent]
postgresql_extension.unaccent_extension: Creating...
postgresql_extension.my_extension: Destruction complete after 2s
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to postgresql_extension.unaccent_extension, provider "provider[\"registry.terraform.io/cyrilgdn/postgresql\"]" produced an unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
Releasing state lock. This may take a few moments...

ekeric13 avatar Jul 21 '22 17:07 ekeric13

Seeing the same issue for grant role with provider v1.17.1. I see that the issue is pretty old, any plans to fix it?

ameyp avatar Oct 19 '22 14:10 ameyp

Also run into this issue today 😞

Version: 1.21.0

scanarjo avatar Oct 27 '23 12:10 scanarjo