UserMapping class

The postgresql.UserMapping resource creates and manages a user mapping on a PostgreSQL server.

Usage

import * as pulumi from "@pulumi/pulumi";
import * as postgresql from "@pulumi/postgresql";

const extPostgresFdw = new postgresql.Extension("ext_postgres_fdw", {name: "postgres_fdw"});
const myserverPostgres = new postgresql.Server("myserver_postgres", {
    serverName: "myserver_postgres",
    fdwName: "postgres_fdw",
    options: {
        host: "foo",
        dbname: "foodb",
        port: "5432",
    },
}, {
    dependsOn: [extPostgresFdw],
});
const remote = new postgresql.Role("remote", {name: "remote"});
const remoteUserMapping = new postgresql.UserMapping("remote", {
    serverName: myserverPostgres.serverName,
    userName: remote.name,
    options: {
        user: "admin",
        password: "pass",
    },
});
import pulumi
import pulumi_postgresql as postgresql

ext_postgres_fdw = postgresql.Extension("ext_postgres_fdw", name="postgres_fdw")
myserver_postgres = postgresql.Server("myserver_postgres",
    server_name="myserver_postgres",
    fdw_name="postgres_fdw",
    options={
        "host": "foo",
        "dbname": "foodb",
        "port": "5432",
    },
    opts = pulumi.ResourceOptions(depends_on=[ext_postgres_fdw]))
remote = postgresql.Role("remote", name="remote")
remote_user_mapping = postgresql.UserMapping("remote",
    server_name=myserver_postgres.server_name,
    user_name=remote.name,
    options={
        "user": "admin",
        "password": "pass",
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using PostgreSql = Pulumi.PostgreSql;

return await Deployment.RunAsync(() =>
{
    var extPostgresFdw = new PostgreSql.Extension("ext_postgres_fdw", new()
    {
        Name = "postgres_fdw",
    });

    var myserverPostgres = new PostgreSql.Server("myserver_postgres", new()
    {
        ServerName = "myserver_postgres",
        FdwName = "postgres_fdw",
        Options =
        {
            { "host", "foo" },
            { "dbname", "foodb" },
            { "port", "5432" },
        },
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            extPostgresFdw,
        },
    });

    var remote = new PostgreSql.Role("remote", new()
    {
        Name = "remote",
    });

    var remoteUserMapping = new PostgreSql.UserMapping("remote", new()
    {
        ServerName = myserverPostgres.ServerName,
        UserName = remote.Name,
        Options =
        {
            { "user", "admin" },
            { "password", "pass" },
        },
    });

});
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 {
		extPostgresFdw, err := postgresql.NewExtension(ctx, "ext_postgres_fdw", &postgresql.ExtensionArgs{
			Name: pulumi.String("postgres_fdw"),
		})
		if err != nil {
			return err
		}
		myserverPostgres, err := postgresql.NewServer(ctx, "myserver_postgres", &postgresql.ServerArgs{
			ServerName: pulumi.String("myserver_postgres"),
			FdwName:    pulumi.String("postgres_fdw"),
			Options: pulumi.StringMap{
				"host":   pulumi.String("foo"),
				"dbname": pulumi.String("foodb"),
				"port":   pulumi.String("5432"),
			},
		}, pulumi.DependsOn([]pulumi.Resource{
			extPostgresFdw,
		}))
		if err != nil {
			return err
		}
		remote, err := postgresql.NewRole(ctx, "remote", &postgresql.RoleArgs{
			Name: pulumi.String("remote"),
		})
		if err != nil {
			return err
		}
		_, err = postgresql.NewUserMapping(ctx, "remote", &postgresql.UserMappingArgs{
			ServerName: myserverPostgres.ServerName,
			UserName:   remote.Name,
			Options: pulumi.StringMap{
				"user":     pulumi.String("admin"),
				"password": pulumi.String("pass"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    postgresql = {
      source = "pulumi/postgresql"
    }
  }
}

resource "postgresql_extension" "ext_postgres_fdw" {
  name = "postgres_fdw"
}
resource "postgresql_server" "myserver_postgres" {
  depends_on  = [postgresql_extension.ext_postgres_fdw]
  server_name = "myserver_postgres"
  fdw_name    = "postgres_fdw"
  options = {
    "host"   = "foo"
    "dbname" = "foodb"
    "port"   = "5432"
  }
}
resource "postgresql_role" "remote" {
  name = "remote"
}
resource "postgresql_usermapping" "remote" {
  server_name = postgresql_server.myserver_postgres.server_name
  user_name   = postgresql_role.remote.name
  options = {
    "user"     = "admin"
    "password" = "pass"
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.postgresql.Extension;
import com.pulumi.postgresql.ExtensionArgs;
import com.pulumi.postgresql.Server;
import com.pulumi.postgresql.ServerArgs;
import com.pulumi.postgresql.Role;
import com.pulumi.postgresql.RoleArgs;
import com.pulumi.postgresql.UserMapping;
import com.pulumi.postgresql.UserMappingArgs;
import com.pulumi.resources.CustomResourceOptions;
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 extPostgresFdw = new Extension("extPostgresFdw", ExtensionArgs.builder()
            .name("postgres_fdw")
            .build());

        var myserverPostgres = new Server("myserverPostgres", ServerArgs.builder()
            .serverName("myserver_postgres")
            .fdwName("postgres_fdw")
            .options(Map.ofEntries(
                Map.entry("host", "foo"),
                Map.entry("dbname", "foodb"),
                Map.entry("port", "5432")
            ))
            .build(), CustomResourceOptions.builder()
                .dependsOn(extPostgresFdw)
                .build());

        var remote = new Role("remote", RoleArgs.builder()
            .name("remote")
            .build());

        var remoteUserMapping = new UserMapping("remoteUserMapping", UserMappingArgs.builder()
            .serverName(myserverPostgres.serverName())
            .userName(remote.name())
            .options(Map.ofEntries(
                Map.entry("user", "admin"),
                Map.entry("password", "pass")
            ))
            .build());

    }
}
resources:
  extPostgresFdw:
    type: postgresql:Extension
    name: ext_postgres_fdw
    properties:
      name: postgres_fdw
  myserverPostgres:
    type: postgresql:Server
    name: myserver_postgres
    properties:
      serverName: myserver_postgres
      fdwName: postgres_fdw
      options:
        host: foo
        dbname: foodb
        port: '5432'
    options:
      dependsOn:
        - ${extPostgresFdw}
  remote:
    type: postgresql:Role
    properties:
      name: remote
  remoteUserMapping:
    type: postgresql:UserMapping
    name: remote
    properties:
      serverName: ${myserverPostgres.serverName}
      userName: ${remote.name}
      options:
        user: admin
        password: pass

Constructors

UserMapping(String name, {UserMappingArgs? args, CustomResourceOptions? options})
Creates a new UserMapping. name The Pulumi resource name. args Arguments used to configure this UserMapping. The set of arguments for UserMapping. options Resource options controlling this resource's behavior.

Properties

childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
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
options ↔ Output<Map<String, String>?>
This clause specifies the options of the user mapping. The options typically define the actual user name and password of the mapping. Option names must be unique. The allowed option names and values are specific to the server's foreign-data wrapper.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverName ↔ Output<String>
The name of an existing server for which the user mapping is to be created. Changing this value will force the creation of a new resource as this value can only be set when the user mapping is created.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
userName ↔ Output<String>
The name of an existing user that is mapped to foreign server. CURRENT_ROLE, CURRENT_USER, and USER match the name of the current user. When PUBLIC is specified, a so-called public mapping is created that is used when no user-specific mapping is applicable. Changing this value will force the creation of a new resource as this value can only be set when the user mapping is created.
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

Static Methods

get(String name, Input<String> id, {UserMappingState? state}) → UserMapping
Gets an existing UserMapping resource's state with the given name and id.