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

non-unique ids in redshift_grant possible #43

Closed
mtesch-um opened this issue Dec 31, 2021 · 0 comments · Fixed by #51
Closed

non-unique ids in redshift_grant possible #43

mtesch-um opened this issue Dec 31, 2021 · 0 comments · Fixed by #51
Labels
bug Something isn't working

Comments

@mtesch-um
Copy link
Contributor

mtesch-um commented Dec 31, 2021

The following produces a state with two redshift_grant resources having identical id. I think makes it impossible to ever have an import for the redshift_grant resource?

Maybe it could use . or - to join the parts? (invalid name characters https://docs.aws.amazon.com/redshift/latest/dg/r_names.html)

(yeah, it's a little contrived, but imagine it were object_type = "table" instead of schema eventually someone is going to have something like that, even if it does seem like poor naming choices)

Working import for would be really helpful for the process of terraforming an existing database - to validate that the grant resource matches the existing db grants. ie terraform import redshift_grant.mygrant y.table.x

terraform {
  required_providers {
    redshift = {
      source  = "brainly/redshift"
      version = "0.5.1"
    }
  }
}

variable "redshift_host" { type = string }
variable "redshift_username" { type = string }
variable "redshift_password" {
  type      = string
  sensitive = true
}
variable "redshift_database" { type = string }

provider "redshift" {
  host            = var.redshift_host
  username        = var.redshift_username
  password        = var.redshift_password
  database        = var.redshift_database
  sslmode         = "require"
  max_connections = 0
}

resource "redshift_user" "user" {
  name      = "xuser"
}

resource "redshift_group" "y_schema" {
  name  = "y_schema"
  users = [redshift_user.user.name]
}

resource "redshift_group" "y" {
  name  = "y"
  users = [redshift_user.user.name]
}

resource "redshift_schema" "x" {
  name  = "x"
  owner = redshift_user.user.name
}

resource "redshift_schema" "schema_x" {
  name  = "schema_x"
  owner = redshift_user.user.name
}

resource "redshift_grant" "grants" {
  group       = redshift_group.y_schema.name
  schema      = redshift_schema.x.name
  object_type = "schema"
  privileges  = ["USAGE"]
  #privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "DROP", "REFERENCES"]
}

resource "redshift_grant" "grants2" {
  group       = redshift_group.y.name
  schema      = redshift_schema.schema_x.name
  object_type = "schema"
  privileges  = ["USAGE"]
  #privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "DROP", "REFERENCES"]
}
@winglot winglot added the bug Something isn't working label Feb 3, 2022
rg00d added a commit that referenced this issue Feb 9, 2022
@rg00d rg00d linked a pull request Feb 9, 2022 that will close this issue
@rg00d rg00d closed this as completed in #51 Feb 10, 2022
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

Successfully merging a pull request may close this issue.

2 participants