Skip to content

Latest commit

 

History

History
126 lines (91 loc) · 3.4 KB

database_user.md

File metadata and controls

126 lines (91 loc) · 3.4 KB
page_title subcategory description
twc_database_user Resource - Timeweb Cloud
Resource for describing needed database user and provides actual information about its status

twc_database_user (Resource)

Resource for describing needed database user and provides actual information about its status

Примеры использования

# Select any preset from location = "ru-1", 8 Gb disk space with price between 100 and 500 RUB for MySQL
data "twc_database_preset" "example-db-preset" {
  location = "ru-1"

  type = "mysql"

  disk = 8 * 1024

  price_filter {
    from = 100
    to   = 500
  }
}

# Create example cluster of MySQL
resource "twc_database_cluster" "example-mysql-8" {
  name = "example_mysql_8"

  type = "mysql"

  preset_id = data.twc_database_preset.example-db-preset.id
}

# Create example instance in previously created cluster
resource "twc_database_instance" "example-mysql-8-instance" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  name = "example"
}

# Create other example instance in previously created cluster
resource "twc_database_instance" "example-mysql-8-other-instance" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  name = "otherexample"
}

# Create some other example instance in previously created cluster
resource "twc_database_instance" "example-mysql-8-some-other-instance" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  name = "someotherexample"
}

# Create user with access across all cluster instances
resource "twc_database_user" "example-mysql-8-user" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  login      = "admin"
  password   = "examplepassword1"
  privileges = ["SELECT", "INSERT", "UPDATE", "DELETE", "ALTER", "REFERENCES", "CREATE", "DROP", "INDEX"]
}

# Create user with privileges to one cluster instance
resource "twc_database_user" "example-mysql-8-user" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  login    = "otheruser"
  password = "examplepassword1"

  instance {
    instance_id = twc_database_instance.example-mysql-8-instance.id
    privileges  = ["SELECT", "INSERT", "UPDATE", "DELETE"]
  }
}

# Create other user with privileges to multiple cluster instances
resource "twc_database_user" "example-mysql-8-user" {
  cluster_id = twc_database_cluster.example-mysql-8.id

  login    = "someotheruser"
  password = "examplepassword1"

  instance {
    instance_id = twc_database_instance.example-mysql-8-instance.id
    privileges  = ["SELECT", "INSERT", "UPDATE", "DELETE"]
  }

  instance {
    instance_id = twc_database_instance.example-mysql-8-other-instance.id
    privileges  = ["SELECT", "INSERT", "UPDATE", "DELETE"]
  }
}

Schema

Required

  • cluster_id (Number) Database cluster ID for which user be created
  • login (String) Login for user
  • password (String, Sensitive) Password for user

Optional

  • description (String) Description for user
  • host (String) Allowed host for login as this user
  • instance (Block List) Privileges of user by instance (see below for nested schema)
  • privileges (List of String) Privileges of user

Read-Only

  • id (String) The ID of this resource.

Nested Schema for instance

Optional:

  • instance_id (Number) Database instance ID for which user has privileges
  • privileges (List of String) Privileges of user