Import Resources

Last modified on July 15, 2024

This document explains how to import multiple resources into StrongDM using the sdm admin resources CLI command. It also explains how to update resources.

Get the JSON Template

StrongDM supports many resource types, and each has its own import format. To get a JSON import template for a specific resource type, follow these steps.

  1. First view all resource types supported by StrongDM and note the name of your resource:

    sdm admin resources add
    
  2. After finding the name of your resource type, you can then use the --template option to get a JSON import template for the resource type specified. Using the following command saves the import.json template file to your machine:

    sdm admin resources add <RESOURCE_TYPE> --template > import.json
    

    If you wish to view the template file in the terminal instead, run the same command but without import.json, as in the following example:

    sdm admin resources add postgres --template
    

    Running that example returns the following JSON:

    [
        {
     	   "bindInterface": "127.0.0.1",
     	   "database": "",
     	   "hostname": "",
     	   "name": "datasource name",
     	   "overrideDatabase": "true",
     	   "password": "",
     	   "port": "",
     	   "portOverride": "",
     	   "subdomain": "",
     	   "tags": {
     	   	"key": "value"
     	   },
     	   "type": "postgres",
     	   "username": ""
        }
    ]                                
    
  3. Open the import.json file in a text editor to edit the values before importing the file back into StrongDM.

Example Import JSON

You can have multiple resource entries when importing. For example, the following JSON adds both a PostgreSQL and a MySQL resource. Notice that each resource type has different fields.

[
    {
        "type": "postgres",
        "name": "postgres datasource",
        "hostname": "",
        "port": "",
        "username": "",
        "password": "",
        "database": "",
        "schema": "",
        "overrideDatabase": "true",
        "portOverride": ""
    },
    {
        "type": "mysql",
        "name": "mysql datasource",
        "hostname": "",
        "port": "",
        "username": "",
        "password": "",
        "database": "",
        "portOverride": ""
    }
]

The portOverride field is only required if you are using port overrides. You can also find out more information about each field by running the sdm admin resources add <TYPE> or sdm admin resources add <TYPE> --help.

Run the Import

Once you have created your JSON file, you can easily import it into StrongDM.

sdm admin resources add --file import.json

Update Resources

To get the current resource state in JSON format, run sdm admin resources list -j -e > export.json. Once you have the state, you can modify the JSON and update the resources by running sdm admin resources update --file export.json.

Top