/terraform-provider-commercelayer

A Terraform provider for Commercelayer

Primary LanguageGoMozilla Public License 2.0MPL-2.0

Commercelayer Terraform Provider

The Commercelayer terraform provider allows you to configure your Commercelayer shops with infrastructure-as-code principles. See the terraform registry documentation for more information

Currently supported resources

Currently, the checked resources are supported. Support for additional resources will come when they are required in projects, or contributed.

  • Address
  • Adyen payment gateway
  • Avalara tax calculator
  • Bing Geocoder
  • Braintree payment gateway
  • Checkout.com payment gateway
  • Customer group
  • Delivery lead times
  • External payment gateway
  • External tax calculator
  • Google Geocoder
  • Inventory model
  • Inventory return location
  • Inventory stock location
  • Klarna payment gateway
  • Manual payment gateway
  • Manual tax calculator
  • Market
  • Merchant
  • Paypal payment gateway
  • Payment method
  • Price list
  • Shipping category
  • Shipping method
  • Shipping zone
  • Stock location
  • Stripe payment gateway
  • Taxjar tax calculator
  • Tax categories
  • Tax rules
  • Webhook

Usage

Add the provider to your terraform project

terraform {
  required_providers {
    commercelayer = {
      version = ">= 0.0.1"
      source  = "incentro-dc/commercelayer"
    }
  }
}

provider "commercelayer" {
  client_id     = "<client_id>"
  client_secret = "<client_secret>"
  api_endpoint  = "<api_endpoint>"
  auth_endpoint = "<auth_endpoint"
}

Development

Requirements

In order to build from the source code, you must have the following set up in your development environment.

There is also a dependency on another internal project, which provides the SDK used.

Running

Build the binary with make. Note that this will also import any required dependencies and generate any code or documentation necessary.

make build

This will produce the project binary. Note that by default the go build process will check your environment and build the binary (using the project name) accordingly. If you want to change this check out the build options go help build.

Now you can run the binary

./terraform-provider-commercelayer

This will however only tell you that the project needs to run as a plugin to terraform. To this end we can also provide a parameter to the binary to tell it to run in development mode

./terraform-provider-commercelayer -debug

This will provide an environment variable that can be loaded when initializing and running terraform

export TF_REATTACH_PROVIDERS='<provider data>'
terraform init
terraform apply

Testing and cleaning

Run the tests to check for any issues

go test ./...

Run formatting to clean up the code (you might need to run this several times to make sure all issues have been handled)

go fmt ./...

Make sure to also clean up the mod file

go mod tidy

Examples

See the examples folder for some examples of terraform code