Skip to content

labd/terraform-provider-amplience

Repository files navigation

Amplience Terraform Provider

Terraform provider for Amplience.

The intention of this provider is to cover the Amplience dynamic content management APIs, so that one can manage an entire Amplience configuration through Terraform.

One provider can manage the resource of one HubID

Currently supported resources

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

  • Administration
  • Content Items
  • Content Repositories
  • Content Types
  • Editions
  • Events
  • Extensions
  • Folders
  • Hubs
  • Localization
  • Integrations
  • Publishing Jobs
  • SFCC
  • SFMC
  • Search Indexes
  • Search Indexes - Analyics
  • Slots
  • Snapshots
  • Webhooks
  • Workflows
  • Hierarchy Node

Installation

Terraform registry

Terraform 0.13 added support for automatically downloading providers from the terraform registry. Simply add the following to your terraform project to use the latest release

terraform {
  required_providers {
    amplience = {
      source = "labd/amplience"
    }
  }
}

Binaries

Packages of the releases are available at https://github.com/labd/terraform-provider-amplience/releases See the terraform documentation for more information about installing third-party providers.

Getting started

Read our documentation.

Contributing

Building the provider

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

Then run

make build

Update amplience-go-sdk

The amplience-go-sdk always uses the latest (master) version. To update to the latest version:

make update-sdk

Generating Documentation

This provider uses the tfplugindocs tool to automatically generate documentation based on the descriptions of the resources and fields. Install the most recent release of the tool by downloading a binary from the tfplugindocs repository. And running

make docs

In order to ensure up to date documentation make sure to update the description fields of any and all resources upon creation or editing.

Testing local changes

As of terraform 0.13 testing local changes requires a little effort. You can run

make build-local

To build the provider with a very high version number and copy it to your terraform plugins folder (default is for Mac, change OS_ARCH if running Linux or change path if running Windows) If you set your provider source as labd/amplience and the version to your built version it should use the local provider. See also the Terraform 0.13 upgrade guide

Debugging / Troubleshooting

There is currently one environment settings for troubleshooting:

  • TF_LOG=1 enables debug output for Terraform.

Note this generates a lot of output!

Testing

Running the unit tests

$ make test

Running an Acceptance Test

In order to run the full suite of Acceptance tests, run make 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 Amplience resources, we need the Amplience API credentials. So in order for the acceptance tests to run correctly please provide all of the following:

export AMPLIENCE_CLIENT_ID=...
export AMPLIENCE_CLIENT_SECRET=...
export AMPLIENCE_HUB_ID=...

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

$ source local/testenv.sh
$ make testacc

Releasing

When pushing a new tag prefixed with v a GitHub action will automatically use Goreleaser to build and release the build.

git tag <release> -m "Release <release>" # please use semantic version, so always vX.Y.Z
git push --follow-tags

TODO List

  • Unit/acceptance tests should be expanded
  • It would be nice to have a Mock Amplience server to run (non-acceptance) tests against
  • The above tests can then be made to run on push through a Github Action

Authors

This project is developed by Lab Digital. We welcome additional contributors. Please see our GitHub repository for more information.