Skip to content

Latest commit

 

History

History
118 lines (83 loc) · 3.35 KB

File metadata and controls

118 lines (83 loc) · 3.35 KB
page_title clickhouse_role_assignment Resource - clickhouse
subcategory
description Use the clickhouse_role_assignment resource to assign actors (users and/or API keys) to a role. Works for both system roles and custom roles. One resource manages all actors for a given role. Use user_ids to assign users, api_key_ids to assign API keys, or both. Only one clickhouse_role_assignment per role is needed. ~> Note: This resource is in alpha. On delete, all actors are removed from the role. To look up the ID of a system role by name, use the clickhouse_role data source. To look up a user ID by email, use the clickhouse_user data source. Example Usage data "clickhouse_role" "member" { name = "Member" } data "clickhouse_user" "alice" { email = "alice@example.com" } data "clickhouse_user" "bob" { email = "bob@example.com" } data "clickhouse_api_key_id" "current" {} resource "clickhouse_role_assignment" "member" { role_id = data.clickhouse_role.member.id user_ids = [data.clickhouse_user.alice.id, data.clickhouse_user.bob.id] api_key_ids = [data.clickhouse_api_key_id.current.id] }

clickhouse_role_assignment (Resource)

Use the clickhouse_role_assignment resource to assign actors (users and/or API keys) to a role. Works for both system roles and custom roles.

One resource manages all actors for a given role. Use user_ids to assign users, api_key_ids to assign API keys, or both. Only one clickhouse_role_assignment per role is needed.

~> Note: This resource is in alpha. On delete, all actors are removed from the role.

To look up the ID of a system role by name, use the clickhouse_role data source. To look up a user ID by email, use the clickhouse_user data source.

Example Usage

data "clickhouse_role" "member" {
  name = "Member"
}

data "clickhouse_user" "alice" {
  email = "alice@example.com"
}

data "clickhouse_user" "bob" {
  email = "bob@example.com"
}

data "clickhouse_api_key_id" "current" {}

resource "clickhouse_role_assignment" "member" {
  role_id = data.clickhouse_role.member.id

  user_ids    = [data.clickhouse_user.alice.id, data.clickhouse_user.bob.id]
  api_key_ids = [data.clickhouse_api_key_id.current.id]
}

Example Usage

data "clickhouse_role" "member" {
  name = "Member"
}

data "clickhouse_user" "alice" {
  email = "alice@example.com"
}

data "clickhouse_api_key_id" "current" {}

resource "clickhouse_role_assignment" "member" {
  role_id = data.clickhouse_role.member.id

  user_ids    = [data.clickhouse_user.alice.id]
  api_key_ids = [data.clickhouse_api_key_id.current.id]
}

Schema

Required

  • role_id (String) ID of the role to assign actors to.

Optional

  • api_key_ids (Set of String) Set of API key IDs to assign to the role.
  • user_ids (Set of String) Set of user IDs to assign to the role.

Read-Only

  • id (String) Same as role_id.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

#!/bin/bash
# Role assignments can be imported by specifying the role ID.
terraform import clickhouse_role_assignment.example xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx