Package @pulumi/mysql

var mysql = require("@pulumi/mysql");
import * as mysql from "@pulumi/mysql";

Modules ▾

class Database

extends CustomResource

The mysql_database resource creates and manages a database on a MySQL server.

Caution: The mysql_database resource can completely delete your database just as easily as it can create it. To avoid costly accidents, consider setting prevent_destroy on your database resources as an extra safety measure.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const app = new mysql.Database("app", {});

constructor

new Database(name: string, args?: DatabaseArgs, opts?: pulumi.CustomResourceOptions)

Create a Database resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: DatabaseState, opts?: pulumi.CustomResourceOptions): Database

Get an existing Database resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property defaultCharacterSet

public defaultCharacterSet: pulumi.Output<string | undefined>;

The default character set to use when a table is created without specifying an explicit character set. Defaults to “utf8”.

property defaultCollation

public defaultCollation: pulumi.Output<string | undefined>;

The default collation to use when a table is created without specifying an explicit collation. Defaults to utf8_general_ci. Each character set has its own set of collations, so changing the character set requires also changing the collation.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property name

public name: pulumi.Output<string>;

The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

class Grant

extends CustomResource

The mysql_grant resource creates and manages privileges given to a user on a MySQL server.

Granting Privileges to a User

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const jdoeUser = new mysql.User("jdoe", {
    host: "example.com",
    password: "password",
    user: "jdoe",
});
const jdoeGrant = new mysql.Grant("jdoe", {
    database: "app",
    host: jdoeUser.host,
    privileges: [
        "SELECT",
        "UPDATE",
    ],
    user: jdoeUser.user,
});

Granting Privileges to a Role

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const developerRole = new mysql.Role("developer", {});
const developerGrant = new mysql.Grant("developer", {
    database: "app",
    privileges: [
        "SELECT",
        "UPDATE",
    ],
    role: developerRole.name,
});

Adding a Role to a User

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const developerRole = new mysql.Role("developer", {});
const jdoe = new mysql.User("jdoe", {
    host: "example.com",
    password: "password",
    user: "jdoe",
});
const developerGrant = new mysql.Grant("developer", {
    database: "app",
    host: jdoe.host,
    roles: [developerRole.name],
    user: jdoe.user,
});

constructor

new Grant(name: string, args: GrantArgs, opts?: pulumi.CustomResourceOptions)

Create a Grant resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: GrantState, opts?: pulumi.CustomResourceOptions): Grant

Get an existing Grant resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property database

public database: pulumi.Output<string>;

The database to grant privileges on.

property grant

public grant: pulumi.Output<boolean | undefined>;

Whether to also give the user privileges to grant the same privileges to other users.

property host

public host: pulumi.Output<string | undefined>;

The source host of the user. Defaults to “localhost”. Conflicts with role.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property privileges

public privileges: pulumi.Output<string[] | undefined>;

A list of privileges to grant to the user. Refer to a list of privileges (such as here) for applicable privileges. Conflicts with roles.

property role

public role: pulumi.Output<string | undefined>;

The role to grant privileges to. Conflicts with user and host.

property roles

public roles: pulumi.Output<string[] | undefined>;

A list of rols to grant to the user. Conflicts with privileges.

property table

public table: pulumi.Output<string | undefined>;

Which table to grant privileges on. Defaults to *, which is all tables.

property tlsOption

public tlsOption: pulumi.Output<string | undefined>;

An TLS-Option for the GRANT statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a GRANT ... REQUIRE SSL statement. See the MYSQL GRANT documentation for more. Ignored if MySQL version is under 5.7.0.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

property user

public user: pulumi.Output<string | undefined>;

The name of the user. Conflicts with role.

class Provider

extends ProviderResource

The provider type for the mysql package. By default, resources use package-wide configuration settings, however an explicit Provider instance may be created and passed during resource construction to achieve fine-grained programmatic control over provider settings. See the documentation for more information.

constructor

new Provider(name: string, args: ProviderArgs, opts?: pulumi.ResourceOptions)

Create a Provider resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

class Role

extends CustomResource

The mysql_role resource creates and manages a user on a MySQL server.

Note: MySQL introduced roles in version 8. They do not work on MySQL 5 and lower.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const developer = new mysql.Role("developer", {});

constructor

new Role(name: string, args?: RoleArgs, opts?: pulumi.CustomResourceOptions)

Create a Role resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: RoleState, opts?: pulumi.CustomResourceOptions): Role

Get an existing Role resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property name

public name: pulumi.Output<string>;

The name of the role.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

class User

extends CustomResource

The mysql_user resource creates and manages a user on a MySQL server.

Note: The password for the user is provided in plain text, and is obscured by an unsalted hash in the state Read more about sensitive data in state. Care is required when using this resource, to avoid disclosing the password.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const jdoe = new mysql.User("jdoe", {
    host: "example.com",
    plaintextPassword: "password",
    user: "jdoe",
});

Example Usage with an Authentication Plugin

import * as pulumi from "@pulumi/pulumi";
import * as mysql from "@pulumi/mysql";

const nologin = new mysql.User("nologin", {
    authPlugin: "mysql_no_login",
    host: "example.com",
    user: "nologin",
});

constructor

new User(name: string, args: UserArgs, opts?: pulumi.CustomResourceOptions)

Create a User resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: UserState, opts?: pulumi.CustomResourceOptions): User

Get an existing User resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property authPlugin

public authPlugin: pulumi.Output<string | undefined>;

Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.

property host

public host: pulumi.Output<string | undefined>;

The source host of the user. Defaults to “localhost”.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property password

public password: pulumi.Output<string | undefined>;

Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

property plaintextPassword

public plaintextPassword: pulumi.Output<string | undefined>;

The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.

property tlsOption

public tlsOption: pulumi.Output<string | undefined>;

An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

property user

public user: pulumi.Output<string>;

The name of the user.

class UserPassword

extends CustomResource

The mysql_user_password resource sets and manages a passwordd for a given user on a MySQL server.

NOTE on MySQL Passwords: This resource conflicts with the password argument for mysql_user. This resource uses PGP encryption to avoid storing unencrypted passwords in Terraform state.

NOTE on How Passwords are Created: This resource automatically generates a random password. The password will be a random UUID.

constructor

new UserPassword(name: string, args: UserPasswordArgs, opts?: pulumi.CustomResourceOptions)

Create a UserPassword resource with the given unique name, arguments, and options.

  • name The unique name of the resource.
  • args The arguments to use to populate this resource's properties.
  • opts A bag of options that control this resource's behavior.

method get

public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: UserPasswordState, opts?: pulumi.CustomResourceOptions): UserPassword

Get an existing UserPassword resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

method getProvider

getProvider(moduleMember: string): ProviderResource | undefined

method isInstance

static isInstance(obj: any): boolean

Returns true if the given object is an instance of CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

property encryptedPassword

public encryptedPassword: pulumi.Output<string>;

The encrypted password, base64 encoded.

property host

public host: pulumi.Output<string | undefined>;

The source host of the user. Defaults to localhost.

property id

id: Output<ID>;

id is the provider-assigned unique ID for this managed resource. It is set during deployments and may be missing (undefined) during planning phases.

property keyFingerprint

public keyFingerprint: pulumi.Output<string>;

The fingerprint of the PGP key used to encrypt the password

property pgpKey

public pgpKey: pulumi.Output<string>;

Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.

property urn

urn: Output<URN>;

urn is the stable logical URN used to distinctly address a resource, both before and after deployments.

property user

public user: pulumi.Output<string>;

The IAM user to associate with this access key.

function getEnv

getEnv(vars: string[]): string | undefined

function getEnvBoolean

getEnvBoolean(vars: string[]): boolean | undefined

function getEnvNumber

getEnvNumber(vars: string[]): number | undefined

function getVersion

getVersion(): string

interface DatabaseArgs

The set of arguments for constructing a Database resource.

property defaultCharacterSet

defaultCharacterSet?: pulumi.Input<string>;

The default character set to use when a table is created without specifying an explicit character set. Defaults to “utf8”.

property defaultCollation

defaultCollation?: pulumi.Input<string>;

The default collation to use when a table is created without specifying an explicit collation. Defaults to utf8_general_ci. Each character set has its own set of collations, so changing the character set requires also changing the collation.

property name

name?: pulumi.Input<string>;

The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.

interface DatabaseState

Input properties used for looking up and filtering Database resources.

property defaultCharacterSet

defaultCharacterSet?: pulumi.Input<string>;

The default character set to use when a table is created without specifying an explicit character set. Defaults to “utf8”.

property defaultCollation

defaultCollation?: pulumi.Input<string>;

The default collation to use when a table is created without specifying an explicit collation. Defaults to utf8_general_ci. Each character set has its own set of collations, so changing the character set requires also changing the collation.

property name

name?: pulumi.Input<string>;

The name of the database. This must be unique within a given MySQL server and may or may not be case-sensitive depending on the operating system on which the MySQL server is running.

interface GrantArgs

The set of arguments for constructing a Grant resource.

property database

database: pulumi.Input<string>;

The database to grant privileges on.

property grant

grant?: pulumi.Input<boolean>;

Whether to also give the user privileges to grant the same privileges to other users.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to “localhost”. Conflicts with role.

property privileges

privileges?: pulumi.Input<pulumi.Input<string>[]>;

A list of privileges to grant to the user. Refer to a list of privileges (such as here) for applicable privileges. Conflicts with roles.

property role

role?: pulumi.Input<string>;

The role to grant privileges to. Conflicts with user and host.

property roles

roles?: pulumi.Input<pulumi.Input<string>[]>;

A list of rols to grant to the user. Conflicts with privileges.

property table

table?: pulumi.Input<string>;

Which table to grant privileges on. Defaults to *, which is all tables.

property tlsOption

tlsOption?: pulumi.Input<string>;

An TLS-Option for the GRANT statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a GRANT ... REQUIRE SSL statement. See the MYSQL GRANT documentation for more. Ignored if MySQL version is under 5.7.0.

property user

user?: pulumi.Input<string>;

The name of the user. Conflicts with role.

interface GrantState

Input properties used for looking up and filtering Grant resources.

property database

database?: pulumi.Input<string>;

The database to grant privileges on.

property grant

grant?: pulumi.Input<boolean>;

Whether to also give the user privileges to grant the same privileges to other users.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to “localhost”. Conflicts with role.

property privileges

privileges?: pulumi.Input<pulumi.Input<string>[]>;

A list of privileges to grant to the user. Refer to a list of privileges (such as here) for applicable privileges. Conflicts with roles.

property role

role?: pulumi.Input<string>;

The role to grant privileges to. Conflicts with user and host.

property roles

roles?: pulumi.Input<pulumi.Input<string>[]>;

A list of rols to grant to the user. Conflicts with privileges.

property table

table?: pulumi.Input<string>;

Which table to grant privileges on. Defaults to *, which is all tables.

property tlsOption

tlsOption?: pulumi.Input<string>;

An TLS-Option for the GRANT statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a GRANT ... REQUIRE SSL statement. See the MYSQL GRANT documentation for more. Ignored if MySQL version is under 5.7.0.

property user

user?: pulumi.Input<string>;

The name of the user. Conflicts with role.

interface ProviderArgs

The set of arguments for constructing a Provider resource.

property endpoint

endpoint: pulumi.Input<string>;

property password

password?: pulumi.Input<string>;

property tls

property username

username: pulumi.Input<string>;

interface RoleArgs

The set of arguments for constructing a Role resource.

property name

name?: pulumi.Input<string>;

The name of the role.

interface RoleState

Input properties used for looking up and filtering Role resources.

property name

name?: pulumi.Input<string>;

The name of the role.

interface UserArgs

The set of arguments for constructing a User resource.

property authPlugin

authPlugin?: pulumi.Input<string>;

Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to “localhost”.

property password

password?: pulumi.Input<string>;

Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

property plaintextPassword

plaintextPassword?: pulumi.Input<string>;

The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.

property tlsOption

tlsOption?: pulumi.Input<string>;

An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.

property user

user: pulumi.Input<string>;

The name of the user.

interface UserPasswordArgs

The set of arguments for constructing a UserPassword resource.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to localhost.

property pgpKey

pgpKey: pulumi.Input<string>;

Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.

property user

user: pulumi.Input<string>;

The IAM user to associate with this access key.

interface UserPasswordState

Input properties used for looking up and filtering UserPassword resources.

property encryptedPassword

encryptedPassword?: pulumi.Input<string>;

The encrypted password, base64 encoded.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to localhost.

property keyFingerprint

keyFingerprint?: pulumi.Input<string>;

The fingerprint of the PGP key used to encrypt the password

property pgpKey

pgpKey?: pulumi.Input<string>;

Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.

property user

user?: pulumi.Input<string>;

The IAM user to associate with this access key.

interface UserState

Input properties used for looking up and filtering User resources.

property authPlugin

authPlugin?: pulumi.Input<string>;

Use an [authentication plugin][ref-auth-plugins] to authenticate the user instead of using password authentication. Description of the fields allowed in the block below. Conflicts with password and plaintext_password.

property host

host?: pulumi.Input<string>;

The source host of the user. Defaults to “localhost”.

property password

password?: pulumi.Input<string>;

Deprecated alias of plaintext_password, whose value is stored as plaintext in state. Prefer to use plaintext_password instead, which stores the password as an unsalted hash. Conflicts with auth_plugin.

property plaintextPassword

plaintextPassword?: pulumi.Input<string>;

The password for the user. This must be provided in plain text, so the data source for it must be secured. An unsalted hash of the provided password is stored in state. Conflicts with auth_plugin.

property tlsOption

tlsOption?: pulumi.Input<string>;

An TLS-Option for the CREATE USER or ALTER USER statement. The value is suffixed to REQUIRE. A value of ‘SSL’ will generate a CREATE USER ... REQUIRE SSL statement. See the MYSQL CREATE USER documentation for more. Ignored if MySQL version is under 5.7.0.

property user

user?: pulumi.Input<string>;

The name of the user.