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

redshift_grant fails on apply stage for external schemas #73

Open
svdimchenko opened this issue Jun 9, 2022 · 2 comments
Open

redshift_grant fails on apply stage for external schemas #73

svdimchenko opened this issue Jun 9, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@svdimchenko
Copy link

svdimchenko commented Jun 9, 2022

I get the following error when try to create redshift grant for external schema:

│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to redshift_grant.user, provider "provider[\"registry.terraform.io/brainly/redshift\"]" 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.

Terraform plan seems like following:

  # redshift_grant.service_accounts["id"] will be created
  + resource "redshift_grant" "service_accounts" {
      + id          = (known after apply)
      + object_type = "schema"
      + privileges  = [
          + "usage",
        ]
      + schema      = "<schema_name>"
      + user        = "<user_name>"
    }

At the same time grant for regular schema apply works properly.
Also if I run following SQL query, grant applies without any error:

GRANT USAGE ON SCHEMA <external_schema_name> TO <user>;
@svdimchenko svdimchenko changed the title Add support for GRANT redshift_grant fails on apply stage for external schemas Jun 9, 2022
@winglot winglot added the bug Something isn't working label Jan 17, 2023
@dkravetz
Copy link

I am currently facing the same problem when trying to grant USAGE and CREATE to a user in the public schema.

This is the resource block that's failing:

resource "redshift_grant" "public_schema" {
  user        = "my_redshift_user"
  object_type = "schema"
  privileges  = ["usage", "create"]
  schema      = "public"
}

and this is the outcome of my apply:

   # module.redshift.module.redshift_config.redshift_grant.public_schema will be created
  + resource "redshift_grant" "public_schema" {
      + id          = (known after apply)
      + object_type = "schema"
      + privileges  = [
          + "create",
          + "usage",
        ]
      + schema      = "public"
      + user        = "my_redshift_user"
    }

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

Do you want to perform these actions?
  OpenTofu will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.redshift.module.redshift_config.redshift_grant.public_schema: Creating...
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [10s elapsed]
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [20s elapsed]
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [30s elapsed]
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [40s elapsed]
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [50s elapsed]
module.redshift.module.redshift_config.redshift_grant.public_schema: Still creating... [1m0s elapsed]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.redshift.module.redshift_config.redshift_grant.public_schema, provider
│ "provider[\"registry.opentofu.org/brainly/redshift\"]" produced an unexpected new value: Root object was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

I am running OpenTofu v1.8.4 and Redshift's provider v1.1.0. Any help would be much appreciated

@dkravetz
Copy link

Welp, turns out that in my case, another engineer accidentally dropped the public schema. When setting TF_LOG to DEBUG I could see the failing query, and running it through QueryEditor I got the useful message "schema public does not exist` 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants