Show / Hide Table of Contents

Class Grant

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

Granting Privileges to a User

using Pulumi;
using MySql = Pulumi.MySql;

class MyStack : Stack
{
public MyStack()
{
    var jdoeUser = new MySql.User("jdoeUser", new MySql.UserArgs
    {
        Host = "example.com",
        PlaintextPassword = "password",
        User = "jdoe",
    });
    var jdoeGrant = new MySql.Grant("jdoeGrant", new MySql.GrantArgs
    {
        Database = "app",
        Host = jdoeUser.Host,
        Privileges = 
        {
            "SELECT",
            "UPDATE",
        },
        User = jdoeUser.UserName,
    });
}

}

Granting Privileges to a Role

using Pulumi;
using MySql = Pulumi.MySql;

class MyStack : Stack
{
public MyStack()
{
    var developerRole = new MySql.Role("developerRole", new MySql.RoleArgs
    {
    });
    var developerGrant = new MySql.Grant("developerGrant", new MySql.GrantArgs
    {
        Database = "app",
        Privileges = 
        {
            "SELECT",
            "UPDATE",
        },
        Role = developerRole.Name,
    });
}

}

Adding a Role to a User

using Pulumi;
using MySql = Pulumi.MySql;

class MyStack : Stack
{
public MyStack()
{
    var jdoe = new MySql.User("jdoe", new MySql.UserArgs
    {
        Host = "example.com",
        PlaintextPassword = "password",
        User = "jdoe",
    });
    var developerRole = new MySql.Role("developerRole", new MySql.RoleArgs
    {
    });
    var developerGrant = new MySql.Grant("developerGrant", new MySql.GrantArgs
    {
        Database = "app",
        Host = jdoe.Host,
        Roles = 
        {
            developerRole.Name,
        },
        User = jdoe.UserName,
    });
}

}
Inheritance
System.Object
Resource
CustomResource
Grant
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.MySql
Assembly: Pulumi.MySql.dll
Syntax
public class Grant : CustomResource

Constructors

View Source

Grant(String, GrantArgs, CustomResourceOptions)

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

Declaration
public Grant(string name, GrantArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

GrantArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Database

The database to grant privileges on.

Declaration
public Output<string> Database { get; }
Property Value
Type Description
Output<System.String>
View Source

GrantName

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

Declaration
public Output<bool?> GrantName { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Host

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

Declaration
public Output<string> Host { get; }
Property Value
Type Description
Output<System.String>
View Source

Privileges

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

Declaration
public Output<ImmutableArray<string>> Privileges { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

Role

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

Declaration
public Output<string> Role { get; }
Property Value
Type Description
Output<System.String>
View Source

Roles

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

Declaration
public Output<ImmutableArray<string>> Roles { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

Table

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

Declaration
public Output<string> Table { get; }
Property Value
Type Description
Output<System.String>
View Source

TlsOption

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.

Declaration
public Output<string> TlsOption { get; }
Property Value
Type Description
Output<System.String>
View Source

User

The name of the user. Conflicts with role.

Declaration
public Output<string> User { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, GrantState, CustomResourceOptions)

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

Declaration
public static Grant Get(string name, Input<string> id, GrantState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

GrantState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Grant
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.