Bash Scripting with Prism
Using the Prismatic CLI in Bash Scripts
Multiple prism
commands can be strung together to manage prismatic resources.
For example, to create an instance you need to know the ID of the integration, and the ID of the customer you want to deploy an instance to.
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
If you would like to use prism
on a headless (no GUI) server for CI/CD or scripting purposes, you will need to log in on a system that has 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 in to prism
with prism login
, get your refresh token with prism me:token --type refresh
.
Take note of your token, and the API endpoint that you are currently using (see that with prism me
).
Now, on our headless CI/CD system, set an environment variable PRISM_REFRESH_TOKEN
with the value you found.
If you use
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: If you are using PowerShell on a Windows machine, you can set an environment variable with this syntax:
$ENV:PRISMATIC_URL=https://app.eu-west-1.prismatic.io
If you use GitHub, consider using Prismatic's integration and component GitHub actions