Manage data sources
This topic describes how to manage data sources with the Connect Pulumi plugin with Python and YAML.
The DatasourceResource resource
The DatasourceResource resource allows you to manage Connect data source configurations using infrastructure as code.
Resource type: mfcpulumiprovider:index:DatasourceResource
Required Inputs
| Property | Type | Description |
|---|---|---|
connectName
|
string | The display name of the datasource in Connect. |
product
|
string | The product type (connector name) of the datasource (e.g.,Micro Focus ALM). |
datasourceProperties
|
map (string - string) | Non-secret connection properties (e.g., server address, port, project). |
secretDatasourceProperties
|
map (string - string) | Secret connection properties (e.g., passwords). These are stored securely. |
Note:The required keys for datasourceProperties and secretDatasourceProperties vary by connector. For the full list of required and optional properties for each connector, refer to the Readme of the corresponding connector. For details, see Connector Readmes.
Python example: data sources
This section provides a Python example for managing data sources.
import pulumi
import pulumi_mfcpulumiprovider as mfcpulumiprovider
datasource = mfcpulumiprovider.DatasourceResource(
"myDatasource",
connect_name="aqm-ds",
product="Micro Focus ALM",
datasource_properties={
"COMMENTS_SINCE_DATE": "",
"Default Project": "<project>",
"Domain": "DEFAULT",
"HTTPTimeout": "300000",
"Inject Comment Header Into Comment Text": "false",
"Port": "8080",
"Protocol": "http",
"Server": "<server>",
"Skip locking": "false",
"userName": "<username>",
},
secret_datasource_properties={
"password": "<password>",
}
)
YAML example: data sources
This section provides a YAML example for managing data sources.
name: pulumiConnect
description: Minimal Pulumi YAML program for mfcpulumiprovider
runtime: yaml
resources:
myDatasource:
type: mfcpulumiprovider:index:DatasourceResource
properties:
connectName: aqm-ds
product: Micro Focus ALM
datasourceProperties:
Default Project: <project>
Domain: DEFAULT
Port: "8080"
Protocol: http
Server: <server>
userName: <username>
secretDatasourceProperties:
password: <password>
outputs: { }
Importing existing data sources
If you have existing data sources in Connect that you want to bring under Pulumi state management, use the following script to generate an import file.
The script fetches all data sources from Connect, filters out invalid ones, 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_datasource, get_all_datasources
result = get_all_datasources()
resources = []
for ds in result.datasources:
resource_name = f"imported-datasources-{ds.connect_name}".replace(" ", "-").lower()
try:
get_datasource(datasource_id=ds.connect_id)
except Exception as e:
print(f"Skipping datasource {ds.connect_name}: {e}")
continue
resources.append({
"type": "mfcpulumiprovider:index:DatasourceResource",
"name": resource_name,
"id": ds.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)} valid resources")
print("Run: pulumi import -f pulumi-import.json")
After generating the pulumi-import.json file, perform the import. Run: pulumi import -f pulumi-import.json

