Manage user mapping
This topic describes how to manage user maps with the Connect Pulumi plugin with Python and YAML.
The UserMapResource resource
The UserMapResource allows you to manage user mappings between Connect users and users in connected data sources using infrastructure as code. User maps define how usernames in one system correspond to usernames in another.
Resource type: mfcpulumiprovider:index:UserMapResource
The following table lists the input properties:
| Property | Type | Description |
|---|---|---|
connectName
|
string | The display name of the user map in Connect. |
userMapEntries
|
list of objects |
A list of the user mapping entries. Each entry must contain the following string entries:
|
Python example: User mapping
This section provides a Python example for user mapping.
import pulumi
from pulumi_mfcpulumiprovider import UserMapResource
# Create a user map resource
usermap1 = UserMapResource(
"usermap1",
connect_name="example user map",
user_map_entries=[
{"userName": "FirstName LastName", "datasourceIdOrName": "JIRA"},
{"userName": "email@email.com", "datasourceIdOrName": "Octane"}
])
YAML example: User mapping
This section provides a YAML example for user mapping.
name: yamlConnect
description: A minimal Pulumi YAML program
runtime: yaml
resources:
usermap1:
type: mfcpulumiprovider:index:UserMapResource
properties:
connectName: example user map
userMapEntries:
- userName: FirstName LastName
datasourceIdOrName: JIRA
- userName: email@email.com
datasourceIdOrName: Octane
outputs: {}
Importing existing user maps
If you have existing user maps in Connect that you want to bring under Pulumi state management, use the script below to generate an import file.
The script fetches all user maps from Connect and generates a pulumi-import.json file for use with the pulumi import command.
Temporarily, place the contents of the following script into your __main__.py file. Once you have generated the pulumi-import.json file and completed the import, remove or comment out the script to prevent it from running on every subsequent initialization (pulumi up) command.
import json
from pulumi_mfcpulumiprovider import get_all_user_maps_output
def generate_import_json(result):
"""Generate a JSON import file for all user maps."""
resources = []
for m in result.user_maps:
resource_name = f"imported-usermap-{m.connect_id}".replace(" ", "-")
resources.append({
"type": "mfcpulumiprovider:index:UserMapResource",
"name": resource_name,
"id": m.connect_id
})
with open("pulumi-import.json", "w") as f:
json.dump({"resources": resources}, f, indent=2)
print(f"Generated import file with {len(resources)} resources")
print("Run: pulumi import -f pulumi-import.json")
get_all_user_maps_output().apply(generate_import_json)
After generating pulumi-import.json, perform the import. Run: pulumi import -f pulumi-import.json

