Prerequisites
Prerequisites Summary
You’ll need to set up the following:
- A Terraspace project repo on Azure Repos
- The ci plugin gem
- Configure Terraspace Cloud
A Terraspace project repo on Azure
If you need a Terraspace project, you can go through one of the Getting Started Guides. For this guide, we’ll use a simple stack that creates a random_pet
resource.
Create a Azure repo and push the project to it. Here are some example commands
git init
git add .
git commit -m 'first commit'
git remote add origin git@ssh.dev.azure.com:v3/ORG/PROJECT/REPO # replace ORG, PROJECT and REPO with your own info
git push -u origin main
The ci plugin gem
Double-check and make sure terraspace_ci_azure
is in your Terraspace project’s Gemfile. It looks something like this.
Gemfile
source "https://rubygems.org"
gem "terraspace"
gem "rspec-terraspace"
gem "terraspace_plugin_azurerm"
gem "terraspace_ci_azure" # Gets VCS info from CI environment
Also, make sure that you’re using Terraspace 2.1 or above. You can check with bundle info terraspace
and should see something like:
$ bundle info terraspace
* terraspace (2.1.0)
If not, you can update terraspace with
bundle update terraspace
Or more generally, update all gem dependencies
bundle update
Note: There is no terraspace_vcs_azure
plugin yet that supports posting PR comments on Azure Repos. However, since you can connect the Azure Pipeline to other VCS providers, you could add other vcs plugins. For example, if you’re using a Azure Pipeline connected to a GitHub repo, you would use terraspace_vcs_github
. Terraspace will then grab the CI env info with terraspace_ci_azure
and a comment to the GitHub PR via terraspace_vcs_github
.
Configure Terraspace Cloud
Configure the cloud.org
and cloud.project
settings.
config/app.rb
Terraspace.configure do |config|
config.cloud.org = "boltops" # replace with your org name
config.cloud.project = "main" # replace with your project name
# Uncomment to enable cost estimation
# Make sure to set the INFRACOST_API_KEY as an env var
# Need the cost estimation plan https://app.terraspace.cloud/pricing
# config.cloud.cost.enabled = true
end
You’ll also need to export TS_TOKEN
to your environment. You want want to add it to your
~/.bash_profile
export TS_TOKEN=token-123 # Example only. Replace with your own token
For more details, see Terraspace Cloud.
Next, we’ll generate the CI structure.