1. Packages
  2. Snowflake
  3. API Docs
  4. DatabaseGrant
Snowflake v0.50.2 published on Friday, Mar 8, 2024 by Pulumi

snowflake.DatabaseGrant

Explore with Pulumi AI

snowflake logo
Snowflake v0.50.2 published on Friday, Mar 8, 2024 by Pulumi

    Deprecation This resource is deprecated and will be removed in a future major version release. Please use snowflake.GrantPrivilegesToAccountRole instead.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Snowflake = Pulumi.Snowflake;
    
    return await Deployment.RunAsync(() => 
    {
        var grant = new Snowflake.DatabaseGrant("grant", new()
        {
            DatabaseName = "database",
            Privilege = "USAGE",
            Roles = new[]
            {
                "role1",
                "role2",
            },
            Shares = new[]
            {
                "share1",
                "share2",
            },
            WithGrantOption = false,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-snowflake/sdk/go/snowflake"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := snowflake.NewDatabaseGrant(ctx, "grant", &snowflake.DatabaseGrantArgs{
    			DatabaseName: pulumi.String("database"),
    			Privilege:    pulumi.String("USAGE"),
    			Roles: pulumi.StringArray{
    				pulumi.String("role1"),
    				pulumi.String("role2"),
    			},
    			Shares: pulumi.StringArray{
    				pulumi.String("share1"),
    				pulumi.String("share2"),
    			},
    			WithGrantOption: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.snowflake.DatabaseGrant;
    import com.pulumi.snowflake.DatabaseGrantArgs;
    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 grant = new DatabaseGrant("grant", DatabaseGrantArgs.builder()        
                .databaseName("database")
                .privilege("USAGE")
                .roles(            
                    "role1",
                    "role2")
                .shares(            
                    "share1",
                    "share2")
                .withGrantOption(false)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_snowflake as snowflake
    
    grant = snowflake.DatabaseGrant("grant",
        database_name="database",
        privilege="USAGE",
        roles=[
            "role1",
            "role2",
        ],
        shares=[
            "share1",
            "share2",
        ],
        with_grant_option=False)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as snowflake from "@pulumi/snowflake";
    
    const grant = new snowflake.DatabaseGrant("grant", {
        databaseName: "database",
        privilege: "USAGE",
        roles: [
            "role1",
            "role2",
        ],
        shares: [
            "share1",
            "share2",
        ],
        withGrantOption: false,
    });
    
    resources:
      grant:
        type: snowflake:DatabaseGrant
        properties:
          databaseName: database
          privilege: USAGE
          roles:
            - role1
            - role2
          shares:
            - share1
            - share2
          withGrantOption: false
    

    Create DatabaseGrant Resource

    new DatabaseGrant(name: string, args: DatabaseGrantArgs, opts?: CustomResourceOptions);
    @overload
    def DatabaseGrant(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      database_name: Optional[str] = None,
                      enable_multiple_grants: Optional[bool] = None,
                      privilege: Optional[str] = None,
                      revert_ownership_to_role_name: Optional[str] = None,
                      roles: Optional[Sequence[str]] = None,
                      shares: Optional[Sequence[str]] = None,
                      with_grant_option: Optional[bool] = None)
    @overload
    def DatabaseGrant(resource_name: str,
                      args: DatabaseGrantArgs,
                      opts: Optional[ResourceOptions] = None)
    func NewDatabaseGrant(ctx *Context, name string, args DatabaseGrantArgs, opts ...ResourceOption) (*DatabaseGrant, error)
    public DatabaseGrant(string name, DatabaseGrantArgs args, CustomResourceOptions? opts = null)
    public DatabaseGrant(String name, DatabaseGrantArgs args)
    public DatabaseGrant(String name, DatabaseGrantArgs args, CustomResourceOptions options)
    
    type: snowflake:DatabaseGrant
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args DatabaseGrantArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args DatabaseGrantArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args DatabaseGrantArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DatabaseGrantArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DatabaseGrantArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    DatabaseGrant Resource Properties

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

    Inputs

    The DatabaseGrant resource accepts the following input properties:

    DatabaseName string
    The name of the database on which to grant privileges.
    EnableMultipleGrants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    Privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    RevertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    Roles List<string>
    Grants privilege to these roles.
    Shares List<string>
    Grants privilege to these shares.
    WithGrantOption bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    DatabaseName string
    The name of the database on which to grant privileges.
    EnableMultipleGrants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    Privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    RevertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    Roles []string
    Grants privilege to these roles.
    Shares []string
    Grants privilege to these shares.
    WithGrantOption bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName String
    The name of the database on which to grant privileges.
    enableMultipleGrants Boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege String
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName String
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles List<String>
    Grants privilege to these roles.
    shares List<String>
    Grants privilege to these shares.
    withGrantOption Boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName string
    The name of the database on which to grant privileges.
    enableMultipleGrants boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles string[]
    Grants privilege to these roles.
    shares string[]
    Grants privilege to these shares.
    withGrantOption boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    database_name str
    The name of the database on which to grant privileges.
    enable_multiple_grants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege str
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revert_ownership_to_role_name str
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles Sequence[str]
    Grants privilege to these roles.
    shares Sequence[str]
    Grants privilege to these shares.
    with_grant_option bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName String
    The name of the database on which to grant privileges.
    enableMultipleGrants Boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege String
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName String
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles List<String>
    Grants privilege to these roles.
    shares List<String>
    Grants privilege to these shares.
    withGrantOption Boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing DatabaseGrant Resource

    Get an existing DatabaseGrant 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?: DatabaseGrantState, opts?: CustomResourceOptions): DatabaseGrant
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            database_name: Optional[str] = None,
            enable_multiple_grants: Optional[bool] = None,
            privilege: Optional[str] = None,
            revert_ownership_to_role_name: Optional[str] = None,
            roles: Optional[Sequence[str]] = None,
            shares: Optional[Sequence[str]] = None,
            with_grant_option: Optional[bool] = None) -> DatabaseGrant
    func GetDatabaseGrant(ctx *Context, name string, id IDInput, state *DatabaseGrantState, opts ...ResourceOption) (*DatabaseGrant, error)
    public static DatabaseGrant Get(string name, Input<string> id, DatabaseGrantState? state, CustomResourceOptions? opts = null)
    public static DatabaseGrant get(String name, Output<String> id, DatabaseGrantState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    DatabaseName string
    The name of the database on which to grant privileges.
    EnableMultipleGrants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    Privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    RevertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    Roles List<string>
    Grants privilege to these roles.
    Shares List<string>
    Grants privilege to these shares.
    WithGrantOption bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    DatabaseName string
    The name of the database on which to grant privileges.
    EnableMultipleGrants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    Privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    RevertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    Roles []string
    Grants privilege to these roles.
    Shares []string
    Grants privilege to these shares.
    WithGrantOption bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName String
    The name of the database on which to grant privileges.
    enableMultipleGrants Boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege String
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName String
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles List<String>
    Grants privilege to these roles.
    shares List<String>
    Grants privilege to these shares.
    withGrantOption Boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName string
    The name of the database on which to grant privileges.
    enableMultipleGrants boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege string
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName string
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles string[]
    Grants privilege to these roles.
    shares string[]
    Grants privilege to these shares.
    withGrantOption boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    database_name str
    The name of the database on which to grant privileges.
    enable_multiple_grants bool
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege str
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revert_ownership_to_role_name str
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles Sequence[str]
    Grants privilege to these roles.
    shares Sequence[str]
    Grants privilege to these shares.
    with_grant_option bool
    When this is set to true, allows the recipient role to grant the privileges to other roles.
    databaseName String
    The name of the database on which to grant privileges.
    enableMultipleGrants Boolean
    When this is set to true, multiple grants of the same type can be created. This will cause Terraform to not revoke grants applied to roles and objects outside Terraform.
    privilege String
    The privilege to grant on the database. To grant all privileges, use the value ALL PRIVILEGES.
    revertOwnershipToRoleName String
    The name of the role to revert ownership to on destroy. Has no effect unless privilege is set to OWNERSHIP
    roles List<String>
    Grants privilege to these roles.
    shares List<String>
    Grants privilege to these shares.
    withGrantOption Boolean
    When this is set to true, allows the recipient role to grant the privileges to other roles.

    Import

    format is database_name|privilege|with_grant_option|roles|shares

    $ pulumi import snowflake:index/databaseGrant:DatabaseGrant example "MY_DATABASE|USAGE|false|role1,role2|share1,share2"
    

    Package Details

    Repository
    Snowflake pulumi/pulumi-snowflake
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the snowflake Terraform Provider.
    snowflake logo
    Snowflake v0.50.2 published on Friday, Mar 8, 2024 by Pulumi