Setting up a local development environment is a crucial step for contributing to the Meraki Terraform Provider project. Below you'll find detailed instructions on how to prepare your development environment.
To contribute to the provider's codebase, you need to have Go installed on your system.
-
Install Go:
Use Homebrew to install Go on macOS:
brew install go
-
Configure Go Environment:
Set up your Go environment by configuring the
GOBIN
path:echo $GOBIN export GOBIN=$(go env GOPATH)/bin
Apple M1/ARM-based processor note: Add an extra environment variable to mitigate potential issues with asynchronous preemption:
export GODEBUG=asyncpreemptoff=1
After setting up Go, you need to install Terraform to work on the provider.
-
Install Terraform:
brew install terraform
Apple M1/ARM-based processor note: If necessary, upgrade Terraform specifically for ARM architecture:
arch -arm64 brew upgrade terraform
-
Clone the Provider Repository:
Clone the official repository to start working on the provider:
git clone https://github.com/core-infra-svcs/terraform-provider-meraki cd terraform-provider-meraki
-
Terraform Development Overrides:
Set up Terraform development overrides by creating a
.terraformrc
file:touch $HOME/.terraformrc vim $HOME/.terraformrc
Insert the following content:
provider_installation { dev_overrides { "core-infra-svcs/meraki" = "$(go env GOPATH)/bin" } direct {} }
-
Download Required Binaries:
Fetch the dependencies:
go mod download
Compile the provider using the Go install command:
go install
This will place the provider binary in your $GOPATH/bin
directory.
To update the documentation, run:
go generate
For acceptance tests (which may incur costs due to resource creation), run:
make testacc
This provider is managed with Go modules.
To add a new dependency, for example, github.com/author/dependency
:
go get github.com/author/dependency
go mod tidy
Commit the changes to go.mod
and go.sum
after modification.
To work on the Meraki provider, set up your environment:
-
Create Terraform Configuration Files:
For instance,
meraki_vars.auto.tfvars
andterraform.tfvars
to handle environment variables.# meraki_vars.auto.tfvars variable "MERAKI_DASHBOARD_API_KEY" { type = string sensitive = true } variable "host" { type = string default = "api.meraki.com" }
# terraform.tfvars MERAKI_DASHBOARD_API_KEY = var.MERAKI_DASHBOARD_API_KEY
-
Export Environment Variable:
Set the Meraki dashboard API key in your shell:
export MERAKI_DASHBOARD_API_KEY="your_api_key_here"
-
Run Terraform:
With the environment variable set, you can now run Terraform commands such as
terraform init
,terraform plan
, andterraform apply
.
Ensure that you manage your API key securely and do not expose it in your code or version control.
With your environment configured, you're ready to contribute to the Meraki Terraform Provider. Happy coding!