Plan Exports API
Plan exports allow users to download data exported from the plan of a Run in a Terraform workspace. Currently, the only supported format for exporting plan data is to generate mock data for Sentinel.
Create a plan export
POST /plan-exports
This endpoint exports data from a plan in the specified format. The export process is asynchronous, and the resulting data becomes downloadable when its status is "finished"
. The data is then available for one hour before expiring. After the hour is up, a new export can be created.
Status | Response | Reason |
---|---|---|
201 | JSON API document (type: "plan-exports" ) | Successfully created a plan export |
404 | JSON API error object | Plan not found, or user unauthorized to perform action |
422 | JSON API error object | Malformed request body (missing attributes, wrong types, etc.), or a plan export of the provided data-type is already pending or downloadable for this plan |
Request Body
This POST endpoint requires a JSON object with the following properties as a request payload.
Properties without a default value are required.
Key path | Type | Default | Description |
---|---|---|---|
data.type | string | Must be "plan-exports" . | |
data.attributes.data-type | string | The format for the export. Currently, the only supported format is "sentinel-mock-bundle-v0" . | |
data.relationships.plan.data | object | A JSON API relationship object that represents the plan being exported. This object must have a type of plans , and the id of a finished Terraform plan that does not already have a downloadable export of the specified data-type (e.g: {"type": "plans", "id": "plan-8F5JFydVYAmtTjET"} ) |
Sample Payload
Sample Request
Sample Response
Show a plan export
GET /plan-exports/:id
Parameter | Description |
---|---|
id | The ID of the plan export to show. |
There is no endpoint to list plan exports. You can find IDs for plan exports in the
relationships.exports
property of a plan object.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "plan-exports" ) | The request was successful |
404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request
Sample Response
Download exported plan data
GET /plan-exports/:id/download
This endpoint generates a temporary URL to the location of the exported plan data in a .tar.gz
archive, and then redirects to that link. If using a client that can follow redirects, you can use this endpoint to save the .tar.gz
archive locally without needing to save the temporary URL.
Status | Response | Reason |
---|---|---|
302 | HTTP Redirect | Plan export found and temporary download URL generated |
404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request
Delete exported plan data
DELETE /plan-exports/:id
Plan exports expire after being available for one hour, but they can be deleted manually as well.
Status | Response | Reason |
---|---|---|
204 | No content | Plan export deleted successfully |
404 | JSON API error object | Plan export not found, or user unauthorized to perform action |
Sample Request