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

Grant same privileges on multiple schemas #108

Closed
Olaktal opened this issue Jan 26, 2023 · 3 comments
Closed

Grant same privileges on multiple schemas #108

Olaktal opened this issue Jan 26, 2023 · 3 comments

Comments

@Olaktal
Copy link

Olaktal commented Jan 26, 2023

Hello

We need to give rights ("select" or more) on multiple schemas.
For now it looks like a lot like

resource "redshift_grant" "readonly_schema1" {
  group       = redshift_group.readonlygroup.name
  schema      = "schema1"
  object_type = "table"
  privileges  = ["select"]
}

resource "redshift_grant" "readonly_schema2" {
  group       = redshift_group.readonlygroup.name
  schema      = "schema2"
  object_type = "table"
  privileges  = ["select"]
}

It a real mess between since we need A LOT of redshift_grant due to our huge amount of groups x schema.
Would it be possible to declare a list of schema instead of a single schema ?
It would look like as follow.

resource "redshift_grant" "readonly" {
  group       = redshift_group.readonlygroup.name
  schemas      = ["schema1", "schema2"]
  object_type = "table"
  privileges  = ["select"]
}

Don't you have yourself the same problem ?

Vincent

@Olaktal Olaktal changed the title Grant same privileges on multiple schema Grant same privileges on multiple schemas Jan 26, 2023
@winglot
Copy link
Member

winglot commented Jan 27, 2023

I don't see this being an issue as this is what for_each loops are for, eg:

resource "redshift_grant" "readonly" {
  for_each = toset(["schema1", "schema2"])

  group       = redshift_group.readonlygroup.name
  schema      = each.key
  object_type = "table"
  privileges  = ["select"]
}

@mtesch-um
Copy link
Contributor

mtesch-um commented Jan 27, 2023

We noticed the same thing -- one thing that helped us was to use the -parallelism=40 flag for terraform to speed things up a bit.

@Olaktal
Copy link
Author

Olaktal commented Jan 30, 2023

You are right @winglot, it works 👌
Thanks for your quick answer !

@Olaktal Olaktal closed this as completed Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants