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

Предоставление доступа нескольким пользователям к нескольким базам данных #211

Open
redi2s opened this issue Sep 22, 2022 · 1 comment
Assignees

Comments

@redi2s
Copy link

redi2s commented Sep 22, 2022

Проблема: нет возможности предоставлять доступ нескольким пользователям к нескольким базам данным.

Прошу реализовать возможность в ресурсе selectel_dbaas_grant_v1 передавать в user_id массив id польователей, как в примере ниже.

variable "databases" {
  sensitive = true

  default = {
    database_1 = {
      owner_username = "owner_1"
      owner_password = "password_1"
      users = [ "user_1", "user_3" ]
    }
    database_2 = {
      owner_username = "owner_1"
      owner_password = "password_1"
      users = [ "user_1", "user_2" ]
    }
  }
}

variable "users" {
  sensitive = true

  default = {
    user_1 = {
      password = "user_1"
      username = "password_1"
    }
    user_2 = {
      password = "user_2"
      username = "password_2"
    }
    user_3 = {
      password = "user_3"
      username = "password_3"
    }
  }
}

...

resource "selectel_dbaas_database_v1" "databases" {
  project_id   = var.project_id
  region       = var.region
  datastore_id = selectel_dbaas_datastore_v1.datastore.id
  owner_id     = selectel_dbaas_user_v1.owners[each.key].id
  lc_ctype     = "ru_RU.utf8"
  lc_collate   = "ru_RU.utf8"

  for_each     = nonsensitive(var.databases)
  name         = each.key
}

resource "selectel_dbaas_user_v1" "users" {
  project_id   = var.project_id
  region       = var.region
  datastore_id = selectel_dbaas_datastore_v1.datastore.id

  for_each     = nonsensitive(var.users)
  name         = each.value.username
  password     = each.value.password
}

resource "selectel_dbaas_grant_v1" "grant" {
  project_id   = var.project_id
  region       = var.region
  datastore_id = selectel_dbaas_datastore_v1.datastore.id

  for_each     = nonsensitive(var.databases)

  database_id  = selectel_dbaas_database_v1.databases[each.key].id
  user_id      = [for user in each.value.users: selectel_dbaas_user_v1.users[user].id]
}
@istokin
Copy link

istokin commented Jul 2, 2024

+1

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