Terraform Provider Snyk allows Terraform to manage Snyk resources.
This template repository is built on the Terraform Plugin Framework. The template repository built on the Terraform Plugin SDK can be found at terraform-provider-scaffolding. See Which SDK Should I Use? in the Terraform documentation for additional information.
Using the provider
See examples folder for instructions on how to configured the provider and resources.
Development
Requirements
Building The Provider
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
go install
Adding Dependencies
This provider uses Go modules.
Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
To generate or update documentation, run go generate
.
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
make testacc
Testing Locally
Make sure Terraform is configured to point out to the local installation of the provider by modifying ~/.terraformrc
, adjust source code location accordingly. This configuration is based on this tutorial.
➜ snyk-terraform-provider git:(main) ✗ cat ~/.terraformrc
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
provider_installation {
dev_overrides {
"registry.terraform.io/snyk-terraform-assets/snyk" = "/Users/muratcelep/git/terraform-provider-snyk"
}
# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
Releases
A new version can be released by running the following command, from the root of
the repository:
VERSION=v1.2.3 make release
In order to determine the VERSION
, we use semantic versioning.
The make target will print out a link to create a PR from a release branch.
Once this PR is merged to main
, the release is created automatically.
How this works
-
We use changie to add changes entries on each PR. These are batched
together when a version is released and added to CHANGELOG.md.
-
When we open a new PR, we kick off the
rc.yml workflow that tests the release build.
-
When we merge a release/*
PR, the
release_workflow.yml
tags the release, and runs goreleaser to build the executables and
upload them to the releases page on GitHub.
There is also a
release_manual.yml workflow that
can be triggered by manually pushing a tag.