This repository contains a Terraform provider for the Elastic Path Commerce Cloud API.
This project was based upon the Terraform Provider Scaffolding Project
Requirements
Building The Provider
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
$ go install
Environment Variables
The following environment variables are defined in Account Management, and can be used to influence behaviour.
Name |
Default |
Description |
EPCC_API_BASE_URL |
- |
The Base URL of the EPCC API |
EPCC_BETA_API_FEATURES |
- |
The value of the EP-Beta-Features header being sent to the EPCC API |
EPCC_CLIENT_ID |
- |
Client ID used for authenticating to the EPCC API |
EPCC_CLIENT_SECRET |
- |
Client Secret used for authenticating to the EPCC API |
EPCC_LOG_DIR |
(work directory) |
The directory of the http log files |
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
.
Project Layout
This project follows the terraform provider template: GitHub template repository documentation
Directory |
Description |
docs/ |
Folder that contains documentation |
examples/ |
Directory for sample resources and data sources |
component-tests/ |
Component tests for the service are located in here. |
external/ |
Any Go package that can be shared with other projects |
internal/ |
Application specific Go packages, e.g., they cannot be shared and are specific to this service |
Using the provider
You would use the epcc-terraform-provider just as any other terraform provider. See the ./examples
directory for sample resources and data sources.
See the [Core Terraform Workflow] (https://www.terraform.io/guides/core-workflow.html) page for more info on using Terraform.
Useful commands
Command |
Description |
go install |
Compile the provider. This will build the provider and put the provider binary in the $GOPATH/bin directory. |
go generate |
Generate or update documentation |
make testacc |
Runs the full suite of Acceptance tests |
Debugging the Provider
-
Run make build
-
Run the following command (assuming you've installed delve)
dlv exec --headless ./bin/terraform-provider-my-provider -- --debug
-
Connect with your Debugger
-
Find the line TF_REATTACH_PROVIDERS
in the output
-
When running terraform prefix the above to the command, for example:
TF_REATTACH_PROVIDERS='...' terraform apply
Debugging Providers
Useful Links
- AWS SDK for Go
- Extending Terraform
- AWS Terraform Provider