Skip to content

Latest commit

 

History

History
165 lines (108 loc) · 3.67 KB

DEVELOPMENT.md

File metadata and controls

165 lines (108 loc) · 3.67 KB

Local Development Environment Setup

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.

Requirements

  • Go version 1.20 or higher
  • Terraform version 1.0 or higher

Go Environment Setup

To contribute to the provider's codebase, you need to have Go installed on your system.

  1. Install Go:

    Use Homebrew to install Go on macOS:

    brew install go
  2. 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

Terraform Development Environment Setup

After setting up Go, you need to install Terraform to work on the provider.

  1. Install Terraform:

    brew install terraform

    Apple M1/ARM-based processor note: If necessary, upgrade Terraform specifically for ARM architecture:

    arch -arm64 brew upgrade terraform
  2. 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
  3. 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 {}
    }
  4. Download Required Binaries:

    Fetch the dependencies:

    go mod download

Compiling the Provider

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

Adding Dependencies

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.

Meraki Development Environment

To work on the Meraki provider, set up your environment:

  1. Create Terraform Configuration Files:

    For instance, meraki_vars.auto.tfvars and terraform.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
  2. Export Environment Variable:

    Set the Meraki dashboard API key in your shell:

    export MERAKI_DASHBOARD_API_KEY="your_api_key_here"
  3. Run Terraform:

    With the environment variable set, you can now run Terraform commands such as terraform init, terraform plan, and terraform 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!