Skip to main content

Bash Scripting with Prism

Using the Prismatic CLI in Bash scripts

Multiple prism commands can be combined to manage Prismatic resources. For example, to create an instance you need the integration ID and the customer ID for deployment. You can use customers:list, integrations:list, and instances:create commands together to create a new instance.

# Get the Customer ID
CUSTOMER_ID=$(
prism customers:list \
--columns id \
--filter 'Name=^FTL Rockets$' \
--no-header)

# Get the Integration ID
INTEGRATION_ID=$(
prism integrations:list \
--columns id \
--filter 'name=^Acme$' \
--no-header)

# Get the integration's latest version ID
VERSION_ID=$(
prism integrations:versions ${INTEGRATION_ID} \
--columns id \
--latest-available \
--no-header)

# Create the instance
prism instances:create \
--customer ${CUSTOMER_ID} \
--integration ${VERSION_ID} \
--name 'Acme ERP' \
--description 'Sync data with Acme ERP'

Headless prism usage for CI/CD pipelines

To use prism on a headless (no GUI) server for CI/CD or scripting purposes, you must log in on a system with a web browser and then transfer your "refresh token" to the headless system. Refresh tokens do not expire and are used to generate short-lived access tokens for Prismatic's API.

After logging into prism with prism login, retrieve your refresh token with prism me:token --type refresh. Note your token and the API endpoint you are currently using (view this with prism me).

Now, on your headless CI/CD system, set an environment variable PRISM_REFRESH_TOKEN with the retrieved value:

export PRISM_REFRESH_TOKEN=my-refresh-token

If you're working with regions other than the default US commercial region, you can also specify an endpoint:

export PRISM_REFRESH_TOKEN=my-refresh-token
export PRISMATIC_URL=https://app.eu-west-1.prismatic.io

If your app uses a white-labeled domain (like integrations.my-company.com), you can use that endpoint instead for PRISMATIC_URL.

Note: For PowerShell on Windows, you can set an environment variable using this syntax:

$ENV:PRISMATIC_URL="https://app.eu-west-1.prismatic.io"
Use GitHub Actions

If you use GitHub, consider using Prismatic's integration and component GitHub actions.