I’ve decided to create a snap for Hashicorp’s Terraform, with the intention of migrating this to the Snapcrafter GitHub Organisation and ultimately upstream. Unfortunately the upstream name terraform
is already in use by a snap (owned by @nhandler), which was last updated over a year ago and two major versions behind the current 0.13.x releases.
$ snap info terraform
name: terraform
summary: build, change, and version infrastructure safely and efficiently
publisher: Nathan Handler (nhandler)
store-url: https://snapcraft.io/terraform
contact: https://github.com/hashicorp/terraform/issues
license: MPL-2.0
description: |
Terraform is a tool for building, changing, and versioning infrastructure
safely and efficiently. Terraform can manage existing and popular service
providers as well as custom in-house solutions.
snap-id: 8vbHYTd6VDLMIlISfzZDxzCRUFeSdBqT
channels:
latest/stable: v0.11.11 2019-01-14 (216) 29MB -
latest/candidate: v0.11.11 2019-01-14 (216) 29MB -
latest/beta: v0.11.11 2019-01-14 (216) 29MB -
latest/edge: v0.11.11 2019-01-14 (216) 29MB -
By moving this to Snapcrafters, there would be greater visibilty and community involvement to keep the version current, as well as providing a certain level of assurance to users of the snap that it would be maintained more frequently by a trusted source (next best thing after upstream).
I’ve based the snapcraft.yaml on the vault
snap being maintained by Snapcrafters.
Initial testing on my end seems to show the snap is functioning as intended, I am able to sucessfully create and destroy infrastructure in the cloud (tested with GCP). Plugins and Modules get initialised with no problem in my testing.
I’m interested to see the results testing this snap yields for other users.
Install instructions:
Due to the snap terraform
being taken I have had to append my username to the snap, terraform-nightmayr
. If the snap is accepted into Snapcrafters and as a result the use of the upstream name is transferred to this snap, the GitHub repo will be updated to reflect this.
Edge channel (devmode snap):
sudo snap install terraform-nightmayr --edge
Beta channel (strict confinement snap):
sudo snap install terraform-nightmayr --beta
Usage instructions:
From the terminal run within a directory containing a terraform project:
terraform-nightmayr.terraform init
terraform-nightmayr.terraform plan
terraform-nightmayr.terraform apply
terraform-nightmayr.terraform destroy
terraform-nightmayr.terraform -help
(for a list of possible commands to run)
Additional info:
GitHub Repo: https://github.com/Nightmayr-snaps/terraform
Store listing (currently unlisted): https://snapcraft.io/terraform-nightmayr
snapcraft.yaml:
name: terraform-nightmayr
base: core18
adopt-info: terraform
summary: Build, change, and version infrastructure safely and efficiently
description: |
Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently.
Terraform can manage existing and popular service providers as well as custom in-house solutions.
grade: stable
confinement: strict
license: MPL-2.0
apps:
terraform:
command: bin/terraform
plugs:
- home
- network
- network-bind
parts:
terraform:
source: https://github.com/hashicorp/terraform.git
plugin: go
go-importpath: github.com/hashicorp/terraform
go-buildtags:
- terraform
override-pull: |
snapcraftctl pull
last_committed_tag="$(git tag | grep v0.13 | sort | tail -1)"
last_released_tag="$(snap info terraform-nightmayr | awk '$1 == "latest/beta:" { print $2 }')"
# If the latest tag from the upstream project has not been released to
# beta, build that tag instead of master.
if [ "${last_committed_tag}" != "${last_released_tag}" ]; then
git checkout "${last_committed_tag}"
cd ../src
git checkout "${last_committed_tag}"
fi
snapcraftctl set-version `echo ${last_committed_tag} | sed "s/v//g"`