Package @pulumi/mysql
This provider is a derived work of the Terraform Provider distributed under MPL 2.0. If you encounter a bug or missing feature, first check the
pulumi/pulumi-mysqlrepo; however, if that doesn’t turn up anything, please consult the sourceterraform-providers/terraform-provider-mysqlrepo.
var mysql = require("@pulumi/mysql");
import * as mysql from "@pulumi/mysql";Modules
Resources
Others
- DatabaseArgs
- DatabaseState
- getEnv
- getEnvBoolean
- getEnvNumber
- getVersion
- GrantArgs
- GrantState
- ProviderArgs
- RoleArgs
- RoleState
- UserArgs
- UserPasswordArgs
- UserPasswordState
- UserState
Resources
Resource Database
class Database extends CustomResourceThe mysql..Database resource creates and manages a database on a MySQL
server.
Caution: The
mysql..Databaseresource can completely delete your database just as easily as it can create it. To avoid costly accidents, consider settingpreventDestroyon 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.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA 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): DatabaseGet 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 | undefinedmethod isInstance
public static isInstance(obj: any): obj is DatabaseReturns true if the given object is an instance of Database. 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
utf8GeneralCi. 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.
Resource Grant
class Grant extends CustomResourceThe 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",
plaintextPassword: "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 jdoe = new mysql.User("jdoe", {
host: "example.com",
plaintextPassword: "password",
user: "jdoe",
});
const developerRole = new mysql.Role("developer", {});
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.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA 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): GrantGet 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 | undefinedmethod isInstance
public static isInstance(obj: any): obj is GrantReturns true if the given object is an instance of Grant. 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.
Resource Provider
class Provider extends ProviderResourceThe 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.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA bag of options that control this resource's behavior.
method getProvider
getProvider(moduleMember: string): ProviderResource | undefinedmethod isInstance
public static isInstance(obj: any): obj is ProviderReturns true if the given object is an instance of Provider. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.
method register
static register(provider: ProviderResource | undefined): Promise<string | undefined>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.
Resource Role
class Role extends CustomResourceThe 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.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA 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): RoleGet 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 | undefinedmethod isInstance
public static isInstance(obj: any): obj is RoleReturns true if the given object is an instance of Role. 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.
Resource User
class User extends CustomResourceThe 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: "mysqlNoLogin",
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.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA 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): UserGet 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 | undefinedmethod isInstance
public static isInstance(obj: any): obj is UserReturns true if the given object is an instance of User. 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 plaintextPassword.
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 plaintextPassword, whose value is stored as plaintext in state. Prefer to use plaintextPassword instead, which stores the password as an unsalted hash. Conflicts with authPlugin.
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 authPlugin.
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.
Resource UserPassword
class UserPassword extends CustomResourceconstructor
new UserPassword(name: string, args: UserPasswordArgs, opts?: pulumi.CustomResourceOptions)Create a UserPassword resource with the given unique name, arguments, and options.
nameThe unique name of the resource.argsThe arguments to use to populate this resource's properties.optsA 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): UserPasswordGet 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 | undefinedmethod isInstance
public static isInstance(obj: any): obj is UserPasswordReturns true if the given object is an instance of UserPassword. 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.
Others
interface DatabaseArgs
interface DatabaseArgsThe 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
utf8GeneralCi. 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
interface DatabaseStateInput 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
utf8GeneralCi. 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.
function getEnv
getEnv(vars: string[]): string | undefinedfunction getEnvBoolean
getEnvBoolean(vars: string[]): boolean | undefinedfunction getEnvNumber
getEnvNumber(vars: string[]): number | undefinedfunction getVersion
getVersion(): stringinterface GrantArgs
interface GrantArgsThe 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
interface GrantStateInput 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
interface ProviderArgsThe set of arguments for constructing a Provider resource.
property authenticationPlugin
authenticationPlugin?: pulumi.Input<string>;property endpoint
endpoint?: pulumi.Input<string>;property maxConnLifetimeSec
maxConnLifetimeSec?: pulumi.Input<number>;property maxOpenConns
maxOpenConns?: pulumi.Input<number>;property password
password?: pulumi.Input<string>;property proxy
proxy?: pulumi.Input<string>;property tls
tls?: pulumi.Input<string>;property username
username?: pulumi.Input<string>;interface RoleArgs
interface RoleArgsThe set of arguments for constructing a Role resource.
property name
name?: pulumi.Input<string>;The name of the role.
interface RoleState
interface RoleStateInput properties used for looking up and filtering Role resources.
property name
name?: pulumi.Input<string>;The name of the role.
interface UserArgs
interface UserArgsThe 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 plaintextPassword.
property host
host?: pulumi.Input<string>;The source host of the user. Defaults to “localhost”.
property password
password?: pulumi.Input<string>;Deprecated alias of plaintextPassword, whose value is stored as plaintext in state. Prefer to use plaintextPassword instead, which stores the password as an unsalted hash. Conflicts with authPlugin.
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 authPlugin.
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
interface UserPasswordArgsThe 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
interface UserPasswordStateInput 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
interface UserStateInput 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 plaintextPassword.
property host
host?: pulumi.Input<string>;The source host of the user. Defaults to “localhost”.
property password
password?: pulumi.Input<string>;Deprecated alias of plaintextPassword, whose value is stored as plaintext in state. Prefer to use plaintextPassword instead, which stores the password as an unsalted hash. Conflicts with authPlugin.
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 authPlugin.
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.