Oso Cloud supports multiple environments so that you can test changes to your policy/facts without impacting your users. This guide will cover the basics of working with environments in Oso Cloud.
Before going through this guide, make sure you follow the Oso Cloud Quickstart to get your Oso API Key(s).
Each environment in Oso Cloud uses a different API key, which you can access (and reset!) from the web interface.
To access a different environment using the Oso Cloud CLI, you can change the
OSO_AUTH variable in your shell session:
$ export OSO_AUTH=<dev_api_key> $ oso-cloud policy == Policy: policy.polar == ... your development policy... ... $ export OSO_AUTH=<staging_api_key> $ oso-cloud policy == Policy: policy.polar == ... your staging policy... ...
In addition to allowing you to backup and restore data within a single environment, Oso Cloud's backup API allows you to restore data from a backup created in a different environment. This can be very useful for testing changes to your policy file, or for seeding one environment with data from another.
Let's walk through a quick example of how this works. We'll assume that we have two environments,
First, we'll create a backup of our staging environment:
$ export OSO_AUTH=<staging_api_key> $ oso-cloud backups add created-from-staging Creating backup created-from-staging: Created backup: Name: "created-from-staging" - Key: <BACKUP_KEY>
You can verify that this worked by running:
$ oso-cloud backups list == Backups == Name: "created-from-staging" - Key: <BACKUP_KEY>
Next, we'll switch environments and run the
$ export OSO_AUTH=<dev_api_key> $ oso-cloud backups restore <BACKUP_KEY> Restoring backup <BACKUP_KEY>: Success
That's it! The policy and facts for both the
development environments now match.
Talk to an Oso Engineer
Our team is happy to help you get started with Oso. If you'd like to learn more about using Oso in your app or have any questions about this guide, schedule a 1x1 with an Oso engineer.