1. Packages
  2. PostgreSQL
  3. API Docs
  4. GrantRole
PostgreSQL v3.11.0 published on Sunday, Mar 3, 2024 by Pulumi

postgresql.GrantRole

Explore with Pulumi AI

postgresql logo
PostgreSQL v3.11.0 published on Sunday, Mar 3, 2024 by Pulumi

    The postgresql.GrantRole resource creates and manages membership in a role to one or more other roles in a non-authoritative way.

    When using postgresql.GrantRole resource it is likely because the PostgreSQL role you are modifying was created outside of this provider.

    Note: This resource needs PostgreSQL version 9 or above.

    Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as postgresql from "@pulumi/postgresql";
    
    const grantRoot = new postgresql.GrantRole("grantRoot", {
        grantRole: "application",
        role: "root",
        withAdminOption: true,
    });
    
    import pulumi
    import pulumi_postgresql as postgresql
    
    grant_root = postgresql.GrantRole("grantRoot",
        grant_role="application",
        role="root",
        with_admin_option=True)
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using PostgreSql = Pulumi.PostgreSql;
    
    return await Deployment.RunAsync(() => 
    {
        var grantRoot = new PostgreSql.GrantRole("grantRoot", new()
        {
            GrantRoleName = "application",
            Role = "root",
            WithAdminOption = true,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := postgresql.NewGrantRole(ctx, "grantRoot", &postgresql.GrantRoleArgs{
    			GrantRole:       pulumi.String("application"),
    			Role:            pulumi.String("root"),
    			WithAdminOption: pulumi.Bool(true),
    		})
    		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.postgresql.GrantRole;
    import com.pulumi.postgresql.GrantRoleArgs;
    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 grantRoot = new GrantRole("grantRoot", GrantRoleArgs.builder()        
                .grantRole("application")
                .role("root")
                .withAdminOption(true)
                .build());
    
        }
    }
    
    resources:
      grantRoot:
        type: postgresql:GrantRole
        properties:
          grantRole: application
          role: root
          withAdminOption: true
    

    Note: If you use postgresql.GrantRole for a role that you also manage with a postgresql.Role resource, you need to ignore the changes of the roles attribute in the postgresql.Role resource or they will fight over what your role grants should be. e.g.:

    import * as pulumi from "@pulumi/pulumi";
    import * as postgresql from "@pulumi/postgresql";
    
    const bob = new postgresql.Role("bob", {});
    const bobAdmin = new postgresql.GrantRole("bobAdmin", {
        role: "bob",
        grantRole: "admin",
    });
    
    import pulumi
    import pulumi_postgresql as postgresql
    
    bob = postgresql.Role("bob")
    bob_admin = postgresql.GrantRole("bobAdmin",
        role="bob",
        grant_role="admin")
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using PostgreSql = Pulumi.PostgreSql;
    
    return await Deployment.RunAsync(() => 
    {
        var bob = new PostgreSql.Role("bob");
    
        var bobAdmin = new PostgreSql.GrantRole("bobAdmin", new()
        {
            Role = "bob",
            GrantRoleName = "admin",
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-postgresql/sdk/v3/go/postgresql"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := postgresql.NewRole(ctx, "bob", nil)
    		if err != nil {
    			return err
    		}
    		_, err = postgresql.NewGrantRole(ctx, "bobAdmin", &postgresql.GrantRoleArgs{
    			Role:      pulumi.String("bob"),
    			GrantRole: pulumi.String("admin"),
    		})
    		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.postgresql.Role;
    import com.pulumi.postgresql.GrantRole;
    import com.pulumi.postgresql.GrantRoleArgs;
    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 bob = new Role("bob");
    
            var bobAdmin = new GrantRole("bobAdmin", GrantRoleArgs.builder()        
                .role("bob")
                .grantRole("admin")
                .build());
    
        }
    }
    
    resources:
      bob:
        type: postgresql:Role
      bobAdmin:
        type: postgresql:GrantRole
        properties:
          role: bob
          grantRole: admin
    

    Create GrantRole Resource

    new GrantRole(name: string, args: GrantRoleArgs, opts?: CustomResourceOptions);
    @overload
    def GrantRole(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  grant_role: Optional[str] = None,
                  role: Optional[str] = None,
                  with_admin_option: Optional[bool] = None)
    @overload
    def GrantRole(resource_name: str,
                  args: GrantRoleArgs,
                  opts: Optional[ResourceOptions] = None)
    func NewGrantRole(ctx *Context, name string, args GrantRoleArgs, opts ...ResourceOption) (*GrantRole, error)
    public GrantRole(string name, GrantRoleArgs args, CustomResourceOptions? opts = null)
    public GrantRole(String name, GrantRoleArgs args)
    public GrantRole(String name, GrantRoleArgs args, CustomResourceOptions options)
    
    type: postgresql:GrantRole
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args GrantRoleArgs
    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 GrantRoleArgs
    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 GrantRoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GrantRoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GrantRoleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    GrantRole 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 GrantRole resource accepts the following input properties:

    GrantRoleName string
    The name of the role that is added to role.
    Role string
    The name of the role that is granted a new membership.
    WithAdminOption bool
    Giving ability to grant membership to others or not for role. (Default: false)
    GrantRole string
    The name of the role that is added to role.
    Role string
    The name of the role that is granted a new membership.
    WithAdminOption bool
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole String
    The name of the role that is added to role.
    role String
    The name of the role that is granted a new membership.
    withAdminOption Boolean
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole string
    The name of the role that is added to role.
    role string
    The name of the role that is granted a new membership.
    withAdminOption boolean
    Giving ability to grant membership to others or not for role. (Default: false)
    grant_role str
    The name of the role that is added to role.
    role str
    The name of the role that is granted a new membership.
    with_admin_option bool
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole String
    The name of the role that is added to role.
    role String
    The name of the role that is granted a new membership.
    withAdminOption Boolean
    Giving ability to grant membership to others or not for role. (Default: false)

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GrantRole 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 GrantRole Resource

    Get an existing GrantRole 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?: GrantRoleState, opts?: CustomResourceOptions): GrantRole
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            grant_role: Optional[str] = None,
            role: Optional[str] = None,
            with_admin_option: Optional[bool] = None) -> GrantRole
    func GetGrantRole(ctx *Context, name string, id IDInput, state *GrantRoleState, opts ...ResourceOption) (*GrantRole, error)
    public static GrantRole Get(string name, Input<string> id, GrantRoleState? state, CustomResourceOptions? opts = null)
    public static GrantRole get(String name, Output<String> id, GrantRoleState 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:
    GrantRoleName string
    The name of the role that is added to role.
    Role string
    The name of the role that is granted a new membership.
    WithAdminOption bool
    Giving ability to grant membership to others or not for role. (Default: false)
    GrantRole string
    The name of the role that is added to role.
    Role string
    The name of the role that is granted a new membership.
    WithAdminOption bool
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole String
    The name of the role that is added to role.
    role String
    The name of the role that is granted a new membership.
    withAdminOption Boolean
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole string
    The name of the role that is added to role.
    role string
    The name of the role that is granted a new membership.
    withAdminOption boolean
    Giving ability to grant membership to others or not for role. (Default: false)
    grant_role str
    The name of the role that is added to role.
    role str
    The name of the role that is granted a new membership.
    with_admin_option bool
    Giving ability to grant membership to others or not for role. (Default: false)
    grantRole String
    The name of the role that is added to role.
    role String
    The name of the role that is granted a new membership.
    withAdminOption Boolean
    Giving ability to grant membership to others or not for role. (Default: false)

    Package Details

    Repository
    PostgreSQL pulumi/pulumi-postgresql
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the postgresql Terraform Provider.
    postgresql logo
    PostgreSQL v3.11.0 published on Sunday, Mar 3, 2024 by Pulumi