Automate Temporary Access with PagerDuty Schedules
This is a guide for manually setting up a script to integrate an on-call schedule in PagerDuty with StrongDM. However, a first-party integration with PagerDuty is now available and is the recommended option for most use cases. See the PagerDuty Integration section for details.
If you use PagerDuty, then you already have on-call schedules mapped out for critical roles. But when someone is on-call, they may need more resource access than they would at other times. This is where StrongDM temporary grants come in. You can integrate your PagerDuty on-call schedule with StrongDM to automatically grant StrongDM users access to additional resources during their on-call shifts. This Python example shows a simple way of managing the process.
Requirements
To get this script working in your environment, you'll need the following:
A StrongDM API key with Resources > List, Grants > Read, and Grants > Write permissions.
A StrongDM resource name
A PagerDuty API token with read-only rights
The schedule ID of a PagerDuty schedule you wish to use as the basis of the temporary grants (If your schedule is
https://example.pagerduty.com/schedules/A123BCDthe last portion of the path,A123BCD, is the ID.
Setup
In order for this automation to work, your users will need to be identified by the same email addresses in PagerDuty and in StrongDM.
The script has two major portions:
First, look up who is on call for a specific schedule over a certain time period
Second, parse these assignments with the StrongDM SDK to grant temporary access to a datasource or server.
Two API calls are necessary to PagerDuty:
Get the list of who is on call will give a list of users and user IDs, but not email addresses.
Conduct specific user lookups to get us the email addresses of the person(s) who are on call.
To set up your PagerDuty automation, add this script to your crontab to run on a regular schedule. Modify the UNTIL calculation to match the interval you are running it at. For instance, if you're running it weekly, that line would look like this:
The Python Script
Last updated
Was this helpful?

