GrantRole class
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)
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 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
})
}
pulumi {
required_providers {
postgresql = {
source = "pulumi/postgresql"
}
}
}
resource "postgresql_grantrole" "grant_root" {
role = "root"
grant_role = "application"
with_admin_option = 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.ArrayList;
import java.util.Arrays;
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")
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 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
})
}
pulumi {
required_providers {
postgresql = {
source = "pulumi/postgresql"
}
}
}
resource "postgresql_role" "bob" {
name = "bob"
}
resource "postgresql_grantrole" "bob_admin" {
role = "bob"
grant_role = "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.ArrayList;
import java.util.Arrays;
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
Constructors
- GrantRole(String name, {GrantRoleArgs? args, CustomResourceOptions? options})
-
Creates a new GrantRole.
nameThe Pulumi resource name.argsArguments used to configure this GrantRole. The set of arguments for GrantRole.optionsResource options controlling this resource's behavior.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
grantRole
↔ Output<
String> -
The name of the role that is added to
role.latefinal - hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
role
↔ Output<
String> -
The name of the role that is granted a new membership.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
withAdminOption
↔ Output<
bool?> -
Giving ability to grant membership to others or not for
role. (Default: false)latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited