{{ ossHeader }}
Thank you for taking your time to contribute to our Terraform provider! This guide will provide you information to start your own development and testing. Happy coding 💃
If you've found a bug or have a suggestion, please open an issue in our project.
If you want to submit a change, please submit a pull request to our project. Use the normal Github pull request process.
To make development easier, we provide a Makefile to do common development tasks. If you're on Windows, you can get make
by installing Windows Subsystem for Linux (WSL).
Install golangci-lint to be able to run make lint
.
To develop and test the Terraform provider locally,
-
Clone the repository
-
Enter the repository directory
-
Build the provider by running the Go
install
command at the root of theterraform-provider-momento
repo:go install .
This will build the provider and put the provider binary in the
$GOPATH/bin
directory. -
Create a
.terraformrc
file in your$HOME
directory that contains following configuration:provider_installation { dev_overrides { "momentohq/momento" = "<path to where Go installs your binaries>" } direct {} }
Typically the path will be a place like
~/go/bin
or/Users/username/go/bin
. This override means your Terraform commands will use the provider you built instead of downloading one from the Terraform Registry. -
To test out the provider, you can create a
main.tf
file with the following contents:terraform { required_providers { momento = { source = "momentohq/momento" } } } provider "momento" {} resource "momento_cache" "example" { name = "example" }
Remember to provide the optional
api_key
argument in theprovider
block, or set theMOMENTO_API_KEY
environment variable before running the provider.To test locally, skip
terraform init
and just useterraform apply
. Terraform provides this warning otherwise: "Skip terraform init when using provider development overrides. It is not necessary and may error unexpectedly."When done, you can clean up resources using
terraform destroy
.
You can use either of these commands to run the acceptance tests locally:
make testacc
TF_ACC=1 go test -v -cover ./internal/provider/
Just make sure the MOMENTO_API_KEY
environment variable is set.
{{ ossFooter }}