Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/labd/terraform-provider-commercetools

Terraform provider for commercetools
https://github.com/labd/terraform-provider-commercetools

commercetools terraform terraform-provider

Last synced: about 2 hours ago
JSON representation

Terraform provider for commercetools

Awesome Lists containing this project

README

        

# commercetools Terraform Provider

[![Test status](https://github.com/labd/terraform-provider-commercetools/workflows/Run%20Tests/badge.svg)](https://github.com/labd/terraform-provider-commercetools/actions?query=workflow%3A%22Run+Tests%22)
[![codecov](https://codecov.io/gh/LabD/terraform-provider-commercetools/branch/master/graph/badge.svg)](https://codecov.io/gh/LabD/terraform-provider-commercetools)
[![Go Report Card](https://goreportcard.com/badge/github.com/labd/terraform-provider-commercetools)](https://goreportcard.com/report/github.com/labd/terraform-provider-commercetools)

The Terraform commercetools provider allows you to configure
your [commercetools](https://commercetools.com/) project with
infrastructure-as-code principles.

# Commercial support

Need support implementing this terraform provider in your organization? Or are you missing features
that need to be added, then we are able to offer support. Please contact us at [email protected]

# Quick start

[Read our documentation](https://registry.terraform.io/providers/labd/commercetools/latest/docs)
and check out the [examples](https://registry.terraform.io/providers/labd/commercetools/latest/docs/guides/extensions).

## Usage

The provider is distributed via the Terraform registry. To use it you need to configure
the [`required_provider`](https://www.terraform.io/language/providers/requirements#requiring-providers) block. For example:

```hcl
terraform {
required_providers {
commercetools = {
source = "labd/commercetools"

# It's recommended to pin the version, e.g.:
# version = "~> 1.4.0"
}
}
}
```

# Binaries

Packages of the releases are available at
https://github.com/labd/terraform-provider-commercetools/releases See the
[terraform documentation](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins)
for more information about installing third-party providers.

# Contributing

## Requirements

- [Go](https://golang.org/doc/install) >= 1.20
- [Task](https://taskfile.dev/installation/)
- [Changie](https://github.com/miniscruff/changie)

## Building the provider

Clone repository to: `$GOPATH/src/github.com/labd/terraform-provider-commercetools`

```sh
$ mkdir -p $GOPATH/src/github.com/labd; cd $GOPATH/src/github.com/labd
$ git clone [email protected]:labd/terraform-provider-commercetools
```

Enter the provider directory and build the provider

```sh
$ cd $GOPATH/src/github.com/labd/terraform-provider-commercetools
$ task build-local
```

A build is created `terraform-provider-commercetools_99.0.0` in the root directory and added to plugin folder available
locally:

```sh
~/.terraform.d/plugins/local/labd/commercetools/99.0.0/${OS_ARCH}/terraform-provider-commercetools_v99.0.0
```

Use version `99.0.0` in the provider to test your changes locally

```hcl
terraform {
required_providers {
commercetools = {
source = "labd/commercetools"
version = "99.0.0"
}
}
}
```

## Adding new resources

When commercetools releases new features which include new resources these need to be implemented
in terraform as new resources too. This provider is currently undergoing a migration path to
move from [terraform-plugin-sdk](https://github.com/hashicorp/terraform-plugin-sdk/) to the new
[terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework/). All new
resources therefore need to be written using the terraform-plugin-framework module. See the
`subscription` component as example.

## Debugging / Troubleshooting

There are two environment settings for troubleshooting:

- `TF_LOG=INFO` enables debug output for Terraform.
- `CTP_DEBUG=1` enables debug output for the Commercetools GO SDK this provider uses.

Note this generates a lot of output!

## Releasing

When creating a PR with changes, please include a changie file in the `changelogs/unreleased` folder. This file can be
interactively generated by running `changie new` in the root of the project. Pick a suitable category for the change. We
recommend `Fixed` or `Added` for most cases. See the [changie configuration](./.changie.yaml) for the full list of
categories.

Once a new version is released all the unreleased changelog files will be merged and added to the general CHANGELOG.md file.

## Testing

### Running the unit tests

```sh
$ task test
```

### Running the unit tests with coverage

```sh
$ task coverage
```

### Running an Acceptance Test

In order to run the full suite of Acceptance tests, run `task testacc`.

**NOTE:** Acceptance tests create real resources.

Prior to running the tests provider configuration details such as access keys
must be made available as environment variables.

Since we need to be able to create commercetools resources, we need the
commercetools API credentials. So in order for the acceptance tests to run
correctly please provide all the following:

```sh
export CTP_CLIENT_ID=...
export CTP_CLIENT_SECRET=...
export CTP_PROJECT_KEY=...
export CTP_SCOPES=...
```

For convenience, place a `testenv.sh` in your `local` folder (which is
included in .gitignore) where you can store these environment variables.

Tests can then be started by running

```sh
$ source local/testenv.sh
$ task testacc
```

## Authors

This project is developed by [Lab Digital](https://www.labdigital.nl). We
welcome additional contributors. Please see our
[GitHub repository](https://github.com/labd/terraform-provider-commercetools)
for more information.