postgresql.UserMapping
Explore with Pulumi AI
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",
})
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
})
}
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 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.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 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
Create UserMapping Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserMapping(name: string, args: UserMappingArgs, opts?: CustomResourceOptions);
@overload
def UserMapping(resource_name: str,
args: UserMappingArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserMapping(resource_name: str,
opts: Optional[ResourceOptions] = None,
server_name: Optional[str] = None,
user_name: Optional[str] = None,
options: Optional[Mapping[str, str]] = None)
func NewUserMapping(ctx *Context, name string, args UserMappingArgs, opts ...ResourceOption) (*UserMapping, error)
public UserMapping(string name, UserMappingArgs args, CustomResourceOptions? opts = null)
public UserMapping(String name, UserMappingArgs args)
public UserMapping(String name, UserMappingArgs args, CustomResourceOptions options)
type: postgresql:UserMapping
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 UserMappingArgs
- 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 UserMappingArgs
- 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 UserMappingArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserMappingArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserMappingArgs
- 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 userMappingResource = new PostgreSql.UserMapping("userMappingResource", new()
{
ServerName = "string",
UserName = "string",
Options =
{
{ "string", "string" },
},
});
example, err := postgresql.NewUserMapping(ctx, "userMappingResource", &postgresql.UserMappingArgs{
ServerName: pulumi.String("string"),
UserName: pulumi.String("string"),
Options: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var userMappingResource = new UserMapping("userMappingResource", UserMappingArgs.builder()
.serverName("string")
.userName("string")
.options(Map.of("string", "string"))
.build());
user_mapping_resource = postgresql.UserMapping("userMappingResource",
server_name="string",
user_name="string",
options={
"string": "string",
})
const userMappingResource = new postgresql.UserMapping("userMappingResource", {
serverName: "string",
userName: "string",
options: {
string: "string",
},
});
type: postgresql:UserMapping
properties:
options:
string: string
serverName: string
userName: string
UserMapping 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 UserMapping resource accepts the following input properties:
- Server
Name 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.
- User
Name 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.
- Options Dictionary<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.
- Server
Name 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.
- User
Name 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.
- Options 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.
- server
Name 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.
- user
Name 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.
- options 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.
- server
Name 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.
- user
Name 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.
- options {[key: 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.
- server_
name str - 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.
- user_
name str - 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.
- options Mapping[str, str]
- 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.
- server
Name 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.
- user
Name 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.
- options Map<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.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserMapping 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 UserMapping Resource
Get an existing UserMapping 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?: UserMappingState, opts?: CustomResourceOptions): UserMapping
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
options: Optional[Mapping[str, str]] = None,
server_name: Optional[str] = None,
user_name: Optional[str] = None) -> UserMapping
func GetUserMapping(ctx *Context, name string, id IDInput, state *UserMappingState, opts ...ResourceOption) (*UserMapping, error)
public static UserMapping Get(string name, Input<string> id, UserMappingState? state, CustomResourceOptions? opts = null)
public static UserMapping get(String name, Output<String> id, UserMappingState 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.
- Options Dictionary<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.
- Server
Name 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.
- User
Name 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.
- Options 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.
- Server
Name 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.
- User
Name 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.
- options 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.
- server
Name 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.
- user
Name 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.
- options {[key: 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.
- server
Name 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.
- user
Name 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.
- options Mapping[str, str]
- 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.
- server_
name str - 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.
- user_
name str - 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.
- options Map<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.
- server
Name 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.
- user
Name 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.
Package Details
- Repository
- PostgreSQL pulumi/pulumi-postgresql
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
postgresql
Terraform Provider.