snowflake.GrantDatabaseRole
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as snowflake from "@pulumi/snowflake";
//#################################
//## grant database role to account role
//#################################
const databaseRoleDatabaseRole = new snowflake.DatabaseRole("databaseRoleDatabaseRole", {database: _var.database});
const parentRole = new snowflake.Role("parentRole", {});
const grantDatabaseRole = new snowflake.GrantDatabaseRole("grantDatabaseRole", {
databaseRoleName: pulumi.interpolate`"${_var.database}"."${databaseRoleDatabaseRole.name}"`,
parentRoleName: parentRole.name,
});
//#################################
//## grant database role to database role
//#################################
const databaseRoleIndex_databaseRoleDatabaseRole = new snowflake.DatabaseRole("databaseRoleIndex/databaseRoleDatabaseRole", {database: _var.database});
const parentDatabaseRole = new snowflake.DatabaseRole("parentDatabaseRole", {database: _var.database});
const index_grantDatabaseRoleGrantDatabaseRole = new snowflake.GrantDatabaseRole("index/grantDatabaseRoleGrantDatabaseRole", {
databaseRoleName: pulumi.interpolate`"${_var.database}"."${databaseRoleDatabaseRole.name}"`,
parentDatabaseRoleName: pulumi.interpolate`"${_var.database}"."${parentDatabaseRole.name}"`,
});
//#################################
//## grant database role to share
//#################################
const snowflakeIndex_grantDatabaseRoleGrantDatabaseRole = new snowflake.GrantDatabaseRole("snowflakeIndex/grantDatabaseRoleGrantDatabaseRole", {
databaseRoleName: pulumi.interpolate`"${_var.database}"."${databaseRoleDatabaseRole.name}"`,
shareName: snowflake_share.share.name,
});
import pulumi
import pulumi_snowflake as snowflake
##################################
### grant database role to account role
##################################
database_role_database_role = snowflake.DatabaseRole("databaseRoleDatabaseRole", database=var["database"])
parent_role = snowflake.Role("parentRole")
grant_database_role = snowflake.GrantDatabaseRole("grantDatabaseRole",
database_role_name=database_role_database_role.name.apply(lambda name: f"\"{var['database']}\".\"{name}\""),
parent_role_name=parent_role.name)
##################################
### grant database role to database role
##################################
database_role_index_database_role_database_role = snowflake.DatabaseRole("databaseRoleIndex/databaseRoleDatabaseRole", database=var["database"])
parent_database_role = snowflake.DatabaseRole("parentDatabaseRole", database=var["database"])
index_grant_database_role_grant_database_role = snowflake.GrantDatabaseRole("index/grantDatabaseRoleGrantDatabaseRole",
database_role_name=database_role_database_role.name.apply(lambda name: f"\"{var['database']}\".\"{name}\""),
parent_database_role_name=parent_database_role.name.apply(lambda name: f"\"{var['database']}\".\"{name}\""))
##################################
### grant database role to share
##################################
snowflake_index_grant_database_role_grant_database_role = snowflake.GrantDatabaseRole("snowflakeIndex/grantDatabaseRoleGrantDatabaseRole",
database_role_name=database_role_database_role.name.apply(lambda name: f"\"{var['database']}\".\"{name}\""),
share_name=snowflake_share["share"]["name"])
package main
import (
"fmt"
"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 {
// #################################
// ## grant database role to account role
// #################################
databaseRoleDatabaseRole, err := snowflake.NewDatabaseRole(ctx, "databaseRoleDatabaseRole", &snowflake.DatabaseRoleArgs{
Database: pulumi.Any(_var.Database),
})
if err != nil {
return err
}
parentRole, err := snowflake.NewRole(ctx, "parentRole", nil)
if err != nil {
return err
}
_, err = snowflake.NewGrantDatabaseRole(ctx, "grantDatabaseRole", &snowflake.GrantDatabaseRoleArgs{
DatabaseRoleName: databaseRoleDatabaseRole.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("\"%v\".\"%v\"", _var.Database, name), nil
}).(pulumi.StringOutput),
ParentRoleName: parentRole.Name,
})
if err != nil {
return err
}
_, err = snowflake.NewDatabaseRole(ctx, "databaseRoleIndex/databaseRoleDatabaseRole", &snowflake.DatabaseRoleArgs{
Database: pulumi.Any(_var.Database),
})
if err != nil {
return err
}
parentDatabaseRole, err := snowflake.NewDatabaseRole(ctx, "parentDatabaseRole", &snowflake.DatabaseRoleArgs{
Database: pulumi.Any(_var.Database),
})
if err != nil {
return err
}
_, err = snowflake.NewGrantDatabaseRole(ctx, "index/grantDatabaseRoleGrantDatabaseRole", &snowflake.GrantDatabaseRoleArgs{
DatabaseRoleName: databaseRoleDatabaseRole.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("\"%v\".\"%v\"", _var.Database, name), nil
}).(pulumi.StringOutput),
ParentDatabaseRoleName: parentDatabaseRole.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("\"%v\".\"%v\"", _var.Database, name), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
_, err = snowflake.NewGrantDatabaseRole(ctx, "snowflakeIndex/grantDatabaseRoleGrantDatabaseRole", &snowflake.GrantDatabaseRoleArgs{
DatabaseRoleName: databaseRoleDatabaseRole.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("\"%v\".\"%v\"", _var.Database, name), nil
}).(pulumi.StringOutput),
ShareName: pulumi.Any(snowflake_share.Share.Name),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Snowflake = Pulumi.Snowflake;
return await Deployment.RunAsync(() =>
{
//#################################
//## grant database role to account role
//#################################
var databaseRoleDatabaseRole = new Snowflake.DatabaseRole("databaseRoleDatabaseRole", new()
{
Database = @var.Database,
});
var parentRole = new Snowflake.Role("parentRole");
var grantDatabaseRole = new Snowflake.GrantDatabaseRole("grantDatabaseRole", new()
{
DatabaseRoleName = databaseRoleDatabaseRole.Name.Apply(name => $"\"{@var.Database}\".\"{name}\""),
ParentRoleName = parentRole.Name,
});
//#################################
//## grant database role to database role
//#################################
var databaseRoleIndex_databaseRoleDatabaseRole = new Snowflake.DatabaseRole("databaseRoleIndex/databaseRoleDatabaseRole", new()
{
Database = @var.Database,
});
var parentDatabaseRole = new Snowflake.DatabaseRole("parentDatabaseRole", new()
{
Database = @var.Database,
});
var index_grantDatabaseRoleGrantDatabaseRole = new Snowflake.GrantDatabaseRole("index/grantDatabaseRoleGrantDatabaseRole", new()
{
DatabaseRoleName = databaseRoleDatabaseRole.Name.Apply(name => $"\"{@var.Database}\".\"{name}\""),
ParentDatabaseRoleName = parentDatabaseRole.Name.Apply(name => $"\"{@var.Database}\".\"{name}\""),
});
//#################################
//## grant database role to share
//#################################
var snowflakeIndex_grantDatabaseRoleGrantDatabaseRole = new Snowflake.GrantDatabaseRole("snowflakeIndex/grantDatabaseRoleGrantDatabaseRole", new()
{
DatabaseRoleName = databaseRoleDatabaseRole.Name.Apply(name => $"\"{@var.Database}\".\"{name}\""),
ShareName = snowflake_share.Share.Name,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.snowflake.DatabaseRole;
import com.pulumi.snowflake.DatabaseRoleArgs;
import com.pulumi.snowflake.Role;
import com.pulumi.snowflake.GrantDatabaseRole;
import com.pulumi.snowflake.GrantDatabaseRoleArgs;
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) {
//#################################
//## grant database role to account role
//#################################
var databaseRoleDatabaseRole = new DatabaseRole("databaseRoleDatabaseRole", DatabaseRoleArgs.builder()
.database(var_.database())
.build());
var parentRole = new Role("parentRole");
var grantDatabaseRole = new GrantDatabaseRole("grantDatabaseRole", GrantDatabaseRoleArgs.builder()
.databaseRoleName(databaseRoleDatabaseRole.name().applyValue(name -> String.format("\"%s\".\"%s\"", var_.database(),name)))
.parentRoleName(parentRole.name())
.build());
//#################################
//## grant database role to database role
//#################################
var databaseRoleIndex_databaseRoleDatabaseRole = new DatabaseRole("databaseRoleIndex/databaseRoleDatabaseRole", DatabaseRoleArgs.builder()
.database(var_.database())
.build());
var parentDatabaseRole = new DatabaseRole("parentDatabaseRole", DatabaseRoleArgs.builder()
.database(var_.database())
.build());
var index_grantDatabaseRoleGrantDatabaseRole = new GrantDatabaseRole("index/grantDatabaseRoleGrantDatabaseRole", GrantDatabaseRoleArgs.builder()
.databaseRoleName(databaseRoleDatabaseRole.name().applyValue(name -> String.format("\"%s\".\"%s\"", var_.database(),name)))
.parentDatabaseRoleName(parentDatabaseRole.name().applyValue(name -> String.format("\"%s\".\"%s\"", var_.database(),name)))
.build());
//#################################
//## grant database role to share
//#################################
var snowflakeIndex_grantDatabaseRoleGrantDatabaseRole = new GrantDatabaseRole("snowflakeIndex/grantDatabaseRoleGrantDatabaseRole", GrantDatabaseRoleArgs.builder()
.databaseRoleName(databaseRoleDatabaseRole.name().applyValue(name -> String.format("\"%s\".\"%s\"", var_.database(),name)))
.shareName(snowflake_share.share().name())
.build());
}
}
resources:
##################################
### grant database role to account role
##################################
databaseRoleDatabaseRole:
type: snowflake:DatabaseRole
properties:
database: ${var.database}
parentRole:
type: snowflake:Role
grantDatabaseRole: ##################################
### grant database role to database role
##################################
type: snowflake:GrantDatabaseRole
properties:
databaseRoleName: '"${var.database}"."${databaseRoleDatabaseRole.name}"'
parentRoleName: ${parentRole.name}
databaseRoleIndex/databaseRoleDatabaseRole:
type: snowflake:DatabaseRole
properties:
database: ${var.database}
parentDatabaseRole:
type: snowflake:DatabaseRole
properties:
database: ${var.database}
index/grantDatabaseRoleGrantDatabaseRole: ##################################
### grant database role to share
##################################
type: snowflake:GrantDatabaseRole
properties:
databaseRoleName: '"${var.database}"."${databaseRoleDatabaseRole.name}"'
parentDatabaseRoleName: '"${var.database}"."${parentDatabaseRole.name}"'
snowflakeIndex/grantDatabaseRoleGrantDatabaseRole:
type: snowflake:GrantDatabaseRole
properties:
databaseRoleName: '"${var.database}"."${databaseRoleDatabaseRole.name}"'
shareName: ${snowflake_share.share.name}
Create GrantDatabaseRole Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new GrantDatabaseRole(name: string, args: GrantDatabaseRoleArgs, opts?: CustomResourceOptions);
@overload
def GrantDatabaseRole(resource_name: str,
args: GrantDatabaseRoleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def GrantDatabaseRole(resource_name: str,
opts: Optional[ResourceOptions] = None,
database_role_name: Optional[str] = None,
parent_database_role_name: Optional[str] = None,
parent_role_name: Optional[str] = None,
share_name: Optional[str] = None)
func NewGrantDatabaseRole(ctx *Context, name string, args GrantDatabaseRoleArgs, opts ...ResourceOption) (*GrantDatabaseRole, error)
public GrantDatabaseRole(string name, GrantDatabaseRoleArgs args, CustomResourceOptions? opts = null)
public GrantDatabaseRole(String name, GrantDatabaseRoleArgs args)
public GrantDatabaseRole(String name, GrantDatabaseRoleArgs args, CustomResourceOptions options)
type: snowflake:GrantDatabaseRole
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args GrantDatabaseRoleArgs
- 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 GrantDatabaseRoleArgs
- 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 GrantDatabaseRoleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args GrantDatabaseRoleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args GrantDatabaseRoleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Example
The following reference example uses placeholder values for all input properties.
var grantDatabaseRoleResource = new Snowflake.GrantDatabaseRole("grantDatabaseRoleResource", new()
{
DatabaseRoleName = "string",
ParentDatabaseRoleName = "string",
ParentRoleName = "string",
ShareName = "string",
});
example, err := snowflake.NewGrantDatabaseRole(ctx, "grantDatabaseRoleResource", &snowflake.GrantDatabaseRoleArgs{
DatabaseRoleName: pulumi.String("string"),
ParentDatabaseRoleName: pulumi.String("string"),
ParentRoleName: pulumi.String("string"),
ShareName: pulumi.String("string"),
})
var grantDatabaseRoleResource = new GrantDatabaseRole("grantDatabaseRoleResource", GrantDatabaseRoleArgs.builder()
.databaseRoleName("string")
.parentDatabaseRoleName("string")
.parentRoleName("string")
.shareName("string")
.build());
grant_database_role_resource = snowflake.GrantDatabaseRole("grantDatabaseRoleResource",
database_role_name="string",
parent_database_role_name="string",
parent_role_name="string",
share_name="string")
const grantDatabaseRoleResource = new snowflake.GrantDatabaseRole("grantDatabaseRoleResource", {
databaseRoleName: "string",
parentDatabaseRoleName: "string",
parentRoleName: "string",
shareName: "string",
});
type: snowflake:GrantDatabaseRole
properties:
databaseRoleName: string
parentDatabaseRoleName: string
parentRoleName: string
shareName: string
GrantDatabaseRole 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 GrantDatabaseRole resource accepts the following input properties:
- Database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- Parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- Parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- Database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- Parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- Parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- database
Role StringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database StringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role StringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- String
- The fully qualified name of the share on which privileges will be granted.
- database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- database_
role_ strname - The fully qualified name of the database role which will be granted to share or parent role.
- parent_
database_ strrole_ name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent_
role_ strname - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- str
- The fully qualified name of the share on which privileges will be granted.
- database
Role StringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database StringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role StringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- String
- The fully qualified name of the share on which privileges will be granted.
Outputs
All input properties are implicitly available as output properties. Additionally, the GrantDatabaseRole 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 GrantDatabaseRole Resource
Get an existing GrantDatabaseRole 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?: GrantDatabaseRoleState, opts?: CustomResourceOptions): GrantDatabaseRole
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
database_role_name: Optional[str] = None,
parent_database_role_name: Optional[str] = None,
parent_role_name: Optional[str] = None,
share_name: Optional[str] = None) -> GrantDatabaseRole
func GetGrantDatabaseRole(ctx *Context, name string, id IDInput, state *GrantDatabaseRoleState, opts ...ResourceOption) (*GrantDatabaseRole, error)
public static GrantDatabaseRole Get(string name, Input<string> id, GrantDatabaseRoleState? state, CustomResourceOptions? opts = null)
public static GrantDatabaseRole get(String name, Output<String> id, GrantDatabaseRoleState 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.
- Database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- Parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- Parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- Database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- Parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- Parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- database
Role StringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database StringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role StringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- String
- The fully qualified name of the share on which privileges will be granted.
- database
Role stringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database stringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role stringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- string
- The fully qualified name of the share on which privileges will be granted.
- database_
role_ strname - The fully qualified name of the database role which will be granted to share or parent role.
- parent_
database_ strrole_ name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent_
role_ strname - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- str
- The fully qualified name of the share on which privileges will be granted.
- database
Role StringName - The fully qualified name of the database role which will be granted to share or parent role.
- parent
Database StringRole Name - The fully qualified name of the parent database role which will create a parent-child relationship between the roles.
- parent
Role StringName - The fully qualified name of the parent account role which will create a parent-child relationship between the roles.
- String
- The fully qualified name of the share on which privileges will be granted.
Import
format is database_role_name (string) | object_type (ROLE|DATABASE ROLE|SHARE) | grantee_name (string)
$ pulumi import snowflake:index/grantDatabaseRole:GrantDatabaseRole \"test_db_role\"|ROLE|\"test_parent_role\""
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Snowflake pulumi/pulumi-snowflake
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
snowflake
Terraform Provider.