1. Packages
  2. Postgresql Provider
  3. API Docs
  4. GrantRole
PostgreSQL v3.13.0 published on Monday, Oct 28, 2024 by Pulumi

postgresql.GrantRole

Explore with Pulumi AI

postgresql logo
PostgreSQL v3.13.0 published on Monday, Oct 28, 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("grant_root", {
        role: "root",
        grantRole: "application",
        withAdminOption: true,
    });
    
    import pulumi
    import pulumi_postgresql as postgresql
    
    grant_root = postgresql.GrantRole("grant_root",
        role="root",
        grant_role="application",
        with_admin_option=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, "grant_root", &postgresql.GrantRoleArgs{
    			Role:            pulumi.String("root"),
    			GrantRole:       pulumi.String("application"),
    			WithAdminOption: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using PostgreSql = Pulumi.PostgreSql;
    
    return await Deployment.RunAsync(() => 
    {
        var grantRoot = new PostgreSql.GrantRole("grant_root", new()
        {
            Role = "root",
            GrantRoleName = "application",
            WithAdminOption = true,
        });
    
    });
    
    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()
                .role("root")
                .grantRole("application")
                .withAdminOption(true)
                .build());
    
        }
    }
    
    resources:
      grantRoot:
        type: postgresql:GrantRole
        name: grant_root
        properties:
          role: root
          grantRole: application
          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", {name: "bob"});
    const bobAdmin = new postgresql.GrantRole("bob_admin", {
        role: "bob",
        grantRole: "admin",
    });
    
    import pulumi
    import pulumi_postgresql as postgresql
    
    bob = postgresql.Role("bob", name="bob")
    bob_admin = postgresql.GrantRole("bob_admin",
        role="bob",
        grant_role="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", &postgresql.RoleArgs{
    			Name: pulumi.String("bob"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = postgresql.NewGrantRole(ctx, "bob_admin", &postgresql.GrantRoleArgs{
    			Role:      pulumi.String("bob"),
    			GrantRole: pulumi.String("admin"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using PostgreSql = Pulumi.PostgreSql;
    
    return await Deployment.RunAsync(() => 
    {
        var bob = new PostgreSql.Role("bob", new()
        {
            Name = "bob",
        });
    
        var bobAdmin = new PostgreSql.GrantRole("bob_admin", new()
        {
            Role = "bob",
            GrantRoleName = "admin",
        });
    
    });
    
    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.RoleArgs;
    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", RoleArgs.builder()
                .name("bob")
                .build());
    
            var bobAdmin = new GrantRole("bobAdmin", GrantRoleArgs.builder()
                .role("bob")
                .grantRole("admin")
                .build());
    
        }
    }
    
    resources:
      bob:
        type: postgresql:Role
        properties:
          name: bob
      bobAdmin:
        type: postgresql:GrantRole
        name: bob_admin
        properties:
          role: bob
          grantRole: admin
    

    Create GrantRole Resource

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

    Constructor syntax

    new GrantRole(name: string, args: GrantRoleArgs, opts?: CustomResourceOptions);
    @overload
    def GrantRole(resource_name: str,
                  args: GrantRoleArgs,
                  opts: Optional[ResourceOptions] = None)
    
    @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)
    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.
    
    

    Parameters

    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.

    Constructor example

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

    var grantRoleResource = new PostgreSql.GrantRole("grantRoleResource", new()
    {
        GrantRoleName = "string",
        Role = "string",
        WithAdminOption = false,
    });
    
    example, err := postgresql.NewGrantRole(ctx, "grantRoleResource", &postgresql.GrantRoleArgs{
    	GrantRole:       pulumi.String("string"),
    	Role:            pulumi.String("string"),
    	WithAdminOption: pulumi.Bool(false),
    })
    
    var grantRoleResource = new GrantRole("grantRoleResource", GrantRoleArgs.builder()
        .grantRole("string")
        .role("string")
        .withAdminOption(false)
        .build());
    
    grant_role_resource = postgresql.GrantRole("grantRoleResource",
        grant_role="string",
        role="string",
        with_admin_option=False)
    
    const grantRoleResource = new postgresql.GrantRole("grantRoleResource", {
        grantRole: "string",
        role: "string",
        withAdminOption: false,
    });
    
    type: postgresql:GrantRole
    properties:
        grantRole: string
        role: string
        withAdminOption: false
    

    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

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

    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.13.0 published on Monday, Oct 28, 2024 by Pulumi