/terraform-provider-upcloud

Terraform provider for UpCloud

Primary LanguageGoMIT LicenseMIT

Terraform Provider

This provider is currently under active development. It is not production-ready yet so you are advised to chime in and help!

Requirements

  • Terraform 0.10.x
  • Go 1.8 (to build the provider plugin)
  • Go dep (to install vendor deps)

Building The Provider

Get and install the provider:

$ mkdir -p $GOPATH/src/github.com/UpCloudLtd; cd $GOPATH/src/github.com/UpCloudLtd
$ git clone git@github.com:UpCloudLtd/terraform-provider-upcloud.git
$ cd terraform-provider-upcloud
$ dep ensure

Build and symlink the provider into a folder (also make sure it exists) where Terraform looks for it:

$ cd $GOPATH/src/github.com/UpCloudLtd/terraform-provider-upcloud
$ make build
$ mkdir -p $HOME/.terraform.d/plugins
$ ln -s $GOPATH/bin/terraform-provider-upcloud $HOME/.terraform.d/plugins/terraform-provider-upcloud

Using the provider

You need to set UpCloud credentials in shell environment variable (.bashrc, .zshrc or similar) to be able to use the provider:

  • export UPCLOUD_USERNAME="Username for Upcloud API user" - Your API access enabled users username
  • export UPCLOUD_PASSWORD="Password for Upcloud API user" - Your API access enabled users password

To allow API access to your UpCloud account, you first need to enable the API permissions by visiting My Account -> User accounts in your UpCloud Control Panel. We recommend you to set up a sub-account specifically for the API usage with its own username and password, as it allows you to assign specific permissions for increased security.

Click Add user and fill in the required details, and check the “Allow API connections” checkbox to enable API for the user. You can also limit the API connections to a specific IP address or address range for additional security. Once you are done entering the user information, hit the Save button at the bottom of the page to create the new username.

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.8+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

To compile the provider, run make build. This will build the provider and put the provider binary in the $GOPATH/bin directory.

$ make build
...
$ $GOPATH/bin/terraform-provider-upcloud
...

In order to test the provider, you can simply run make test.

$ make test

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

Note: Acceptance tests create real resources, and often cost money to run.

$ make testacc