1. Packages
  2. Mysql Provider
  3. API Docs
  4. UserPassword
MySQL v3.2.9 published on Wednesday, Feb 12, 2025 by Pulumi

mysql.UserPassword

Explore with Pulumi AI

The mysql.UserPassword resource sets and manages a password 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 the provider state.

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

Example Usage

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

const jdoe = new mysql.User("jdoe", {user: "jdoe"});
const jdoeUserPassword = new mysql.UserPassword("jdoe", {
    user: jdoe.user,
    pgpKey: "keybase:joestump",
});
Copy
import pulumi
import pulumi_mysql as mysql

jdoe = mysql.User("jdoe", user="jdoe")
jdoe_user_password = mysql.UserPassword("jdoe",
    user=jdoe.user,
    pgp_key="keybase:joestump")
Copy
package main

import (
	"github.com/pulumi/pulumi-mysql/sdk/v3/go/mysql"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		jdoe, err := mysql.NewUser(ctx, "jdoe", &mysql.UserArgs{
			User: pulumi.String("jdoe"),
		})
		if err != nil {
			return err
		}
		_, err = mysql.NewUserPassword(ctx, "jdoe", &mysql.UserPasswordArgs{
			User:   jdoe.User,
			PgpKey: pulumi.String("keybase:joestump"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using MySql = Pulumi.MySql;

return await Deployment.RunAsync(() => 
{
    var jdoe = new MySql.User("jdoe", new()
    {
        UserName = "jdoe",
    });

    var jdoeUserPassword = new MySql.UserPassword("jdoe", new()
    {
        User = jdoe.UserName,
        PgpKey = "keybase:joestump",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mysql.User;
import com.pulumi.mysql.UserArgs;
import com.pulumi.mysql.UserPassword;
import com.pulumi.mysql.UserPasswordArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var jdoe = new User("jdoe", UserArgs.builder()
            .user("jdoe")
            .build());

        var jdoeUserPassword = new UserPassword("jdoeUserPassword", UserPasswordArgs.builder()
            .user(jdoe.user())
            .pgpKey("keybase:joestump")
            .build());

    }
}
Copy
resources:
  jdoe:
    type: mysql:User
    properties:
      user: jdoe
  jdoeUserPassword:
    type: mysql:UserPassword
    name: jdoe
    properties:
      user: ${jdoe.user}
      pgpKey: keybase:joestump
Copy

Create UserPassword Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new UserPassword(name: string, args: UserPasswordArgs, opts?: CustomResourceOptions);
@overload
def UserPassword(resource_name: str,
                 args: UserPasswordArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def UserPassword(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 pgp_key: Optional[str] = None,
                 user: Optional[str] = None,
                 host: Optional[str] = None)
func NewUserPassword(ctx *Context, name string, args UserPasswordArgs, opts ...ResourceOption) (*UserPassword, error)
public UserPassword(string name, UserPasswordArgs args, CustomResourceOptions? opts = null)
public UserPassword(String name, UserPasswordArgs args)
public UserPassword(String name, UserPasswordArgs args, CustomResourceOptions options)
type: mysql:UserPassword
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. UserPasswordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. UserPasswordArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. UserPasswordArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. UserPasswordArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. UserPasswordArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var userPasswordResource = new MySql.UserPassword("userPasswordResource", new()
{
    PgpKey = "string",
    User = "string",
    Host = "string",
});
Copy
example, err := mysql.NewUserPassword(ctx, "userPasswordResource", &mysql.UserPasswordArgs{
	PgpKey: pulumi.String("string"),
	User:   pulumi.String("string"),
	Host:   pulumi.String("string"),
})
Copy
var userPasswordResource = new UserPassword("userPasswordResource", UserPasswordArgs.builder()
    .pgpKey("string")
    .user("string")
    .host("string")
    .build());
Copy
user_password_resource = mysql.UserPassword("userPasswordResource",
    pgp_key="string",
    user="string",
    host="string")
Copy
const userPasswordResource = new mysql.UserPassword("userPasswordResource", {
    pgpKey: "string",
    user: "string",
    host: "string",
});
Copy
type: mysql:UserPassword
properties:
    host: string
    pgpKey: string
    user: string
Copy

UserPassword Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The UserPassword resource accepts the following input properties:

PgpKey
This property is required.
Changes to this property will trigger replacement.
string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
User
This property is required.
Changes to this property will trigger replacement.
string
The IAM user to associate with this access key.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
PgpKey
This property is required.
Changes to this property will trigger replacement.
string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
User
This property is required.
Changes to this property will trigger replacement.
string
The IAM user to associate with this access key.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
pgpKey
This property is required.
Changes to this property will trigger replacement.
String
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user
This property is required.
Changes to this property will trigger replacement.
String
The IAM user to associate with this access key.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to localhost.
pgpKey
This property is required.
Changes to this property will trigger replacement.
string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user
This property is required.
Changes to this property will trigger replacement.
string
The IAM user to associate with this access key.
host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
pgp_key
This property is required.
Changes to this property will trigger replacement.
str
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user
This property is required.
Changes to this property will trigger replacement.
str
The IAM user to associate with this access key.
host Changes to this property will trigger replacement. str
The source host of the user. Defaults to localhost.
pgpKey
This property is required.
Changes to this property will trigger replacement.
String
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user
This property is required.
Changes to this property will trigger replacement.
String
The IAM user to associate with this access key.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to localhost.

Outputs

All input properties are implicitly available as output properties. Additionally, the UserPassword resource produces the following output properties:

EncryptedPassword string
The encrypted password, base64 encoded.
Id string
The provider-assigned unique ID for this managed resource.
KeyFingerprint string
The fingerprint of the PGP key used to encrypt the password
EncryptedPassword string
The encrypted password, base64 encoded.
Id string
The provider-assigned unique ID for this managed resource.
KeyFingerprint string
The fingerprint of the PGP key used to encrypt the password
encryptedPassword String
The encrypted password, base64 encoded.
id String
The provider-assigned unique ID for this managed resource.
keyFingerprint String
The fingerprint of the PGP key used to encrypt the password
encryptedPassword string
The encrypted password, base64 encoded.
id string
The provider-assigned unique ID for this managed resource.
keyFingerprint string
The fingerprint of the PGP key used to encrypt the password
encrypted_password str
The encrypted password, base64 encoded.
id str
The provider-assigned unique ID for this managed resource.
key_fingerprint str
The fingerprint of the PGP key used to encrypt the password
encryptedPassword String
The encrypted password, base64 encoded.
id String
The provider-assigned unique ID for this managed resource.
keyFingerprint String
The fingerprint of the PGP key used to encrypt the password

Look up Existing UserPassword Resource

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

public static get(name: string, id: Input<ID>, state?: UserPasswordState, opts?: CustomResourceOptions): UserPassword
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        encrypted_password: Optional[str] = None,
        host: Optional[str] = None,
        key_fingerprint: Optional[str] = None,
        pgp_key: Optional[str] = None,
        user: Optional[str] = None) -> UserPassword
func GetUserPassword(ctx *Context, name string, id IDInput, state *UserPasswordState, opts ...ResourceOption) (*UserPassword, error)
public static UserPassword Get(string name, Input<string> id, UserPasswordState? state, CustomResourceOptions? opts = null)
public static UserPassword get(String name, Output<String> id, UserPasswordState state, CustomResourceOptions options)
resources:  _:    type: mysql:UserPassword    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
EncryptedPassword string
The encrypted password, base64 encoded.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
KeyFingerprint string
The fingerprint of the PGP key used to encrypt the password
PgpKey Changes to this property will trigger replacement. string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
User Changes to this property will trigger replacement. string
The IAM user to associate with this access key.
EncryptedPassword string
The encrypted password, base64 encoded.
Host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
KeyFingerprint string
The fingerprint of the PGP key used to encrypt the password
PgpKey Changes to this property will trigger replacement. string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
User Changes to this property will trigger replacement. string
The IAM user to associate with this access key.
encryptedPassword String
The encrypted password, base64 encoded.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to localhost.
keyFingerprint String
The fingerprint of the PGP key used to encrypt the password
pgpKey Changes to this property will trigger replacement. String
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user Changes to this property will trigger replacement. String
The IAM user to associate with this access key.
encryptedPassword string
The encrypted password, base64 encoded.
host Changes to this property will trigger replacement. string
The source host of the user. Defaults to localhost.
keyFingerprint string
The fingerprint of the PGP key used to encrypt the password
pgpKey Changes to this property will trigger replacement. string
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user Changes to this property will trigger replacement. string
The IAM user to associate with this access key.
encrypted_password str
The encrypted password, base64 encoded.
host Changes to this property will trigger replacement. str
The source host of the user. Defaults to localhost.
key_fingerprint str
The fingerprint of the PGP key used to encrypt the password
pgp_key Changes to this property will trigger replacement. str
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user Changes to this property will trigger replacement. str
The IAM user to associate with this access key.
encryptedPassword String
The encrypted password, base64 encoded.
host Changes to this property will trigger replacement. String
The source host of the user. Defaults to localhost.
keyFingerprint String
The fingerprint of the PGP key used to encrypt the password
pgpKey Changes to this property will trigger replacement. String
Either a base-64 encoded PGP public key, or a keybase username in the form keybase:some_person_that_exists.
user Changes to this property will trigger replacement. String
The IAM user to associate with this access key.

Package Details

Repository
MySQL pulumi/pulumi-mysql
License
Apache-2.0
Notes
This Pulumi package is based on the mysql Terraform Provider.