🌌Spacelift
CI/CD Automation
Last updated
CI/CD Automation
Last updated
You can integrate Resourcely with Spacelift to automatically evaluate your Terraform plans and policies on every pull request, and provide feedback directly within your pull/merge request. To set up Resourcely with Spacelift, you must perform the following steps:
Verifying Prerequisites
Storing the Resourcely API Token
Storing the Github Personal Access Token
Integrate Resourcely CLI into your Plan Hooks
This document assumes that you have a pre-existing Spacelift account configured. If you do not, you can follow their Getting Started steps here: https://docs.spacelift.io/getting-started
The Resourcely CLI needs access to a Resourcely API key at build time so it can report findings in your Terraform plans. Spacelift allows you to store these secrets in each stack as an Environment.
In the Spacelift console navigate to the Stack you want to integrate with Resourcely.
Click 'Edit'.
With 'Environment Variable' selected, type RESOURCELY_API_TOKEN
as the key.
Paste the API Token generated from the Resourcely portal as the value.
Click "Secret" to save this variable as a secret (this will prevent it from being exposed in stdout).
We need a GitHub Personal Access Token in order for Resourcely to map your Pull Request URL when your guardrails are evaluated. For details on how to generate a Personal Access Token, you can view the following docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
In the Spacelift console navigate to the Stack you want to integrate with Resourcely.
Click 'Edit'.
With 'Environment Variable' selected, type GH_TOKEN
as the key.
Paste the Personal Access Token generated from GitHub as the value.
Click "Secret" to save this variable as a secret (this will prevent it from being exposed in stdout).
Spacelift allows you to specify Hooks that you can run at different stages of your pipeline. We setup the Resourcely CLI to run after the Plan runs, which allows us to evaluate our guardrails against your planned changes. Use the following steps to setup your Post-Plan flow with Resourcely:
These instructions assume that your Spacelift stack name exactly matches the environment name configured in .resourcely.yaml
.
If it does not, you will need to customize how RESOURCELY_EVALUATE_ENVIRONMENT
is set in the script below.
See #advanced-resourcely-cli-usagefor more information.
In your desired Stack, navigate to Hooks
Click 'Planning'
Navigate to 'After'
Individually paste the following commands:
Now Resourcely should be integrated into your Terraform flow, and we will alert your PRs with any violations to the Guardrails you've configured.