Skip to content

phoenixnap/terraform-provider-pnap

Repository files navigation


phoenixnap Bare Metal Cloud
Terraform phoenixNAP Provider

Terraform is a powerful infrastructure as code tool for provisioning and managing cloud resources programmatically. phoenixNAP's Bare Metal Cloud server platform comes with a custom-built Terraform provider pnap which allows you to easily deploy and destroy your Bare Metal Cloud servers with code.

Bare Metal CloudTerraform ProviderDevelopers PortalKnowledge BaseSupport

Requirements

Creating a Bare Metal Cloud account

You need to have a Bare Metal Cloud account in order to use the pnap Terraform provider with Bare Metal Cloud.

  1. Go to the Bare Metal Cloud signup page.
  2. Follow the prompts to set up your account.
  3. Use your credentials to log in to Bare Metal Cloud portal.

▶️ Video tutorial: How to Create a Bare Metal Cloud Account
▶️ Video tutorial: Introduction to Bare Metal Cloud

Installing Terraform locally

Follow this helpful tutorial to learn how to install Terraform on your local machine.

Building the provider

Clone the repository to: $GOPATH/src/github.com/phoenixnap/terraform-provider-pnap.

$ mkdir -p $GOPATH/src/github.com/phoenixnap; cd $GOPATH/src/github.com/phoenixnap
$ git clone git@github.com:phoenixnap/terraform-provider-pnap

Navigate to the provider directory and build the provider with make build.

$ cd $GOPATH/src/github.com/phoenixnap/terraform-provider-pnap
$ make build

Using the provider

The pnap provider will be installed on terraform init as a template of the pnap_server resource.

Terraform provider documentation

Developing the provider

If you want to work on developing the provider, you need to have Go installed on your machine. Go version 1.16.15+ is required. You will also need to properly set up a GOPATH and add $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 bin
...
$ $GOPATH/bin/terraform-provider-pnap
...

Testing provider code

You can run acceptance tests with the provider. Find the relevant test function in *_test.go (e.g., TestAccPnapServer_basic) and run it as:

TF_ACC=1 go test -v -timeout=20m -run=TestAccPnapServer_basic

If you want to see HTTP traffic, set TF_LOG=DEBUG.

TF_LOG=DEBUG TF_ACC=1 go test -v -timeout=20m -run=TestAccPnapServer_basic

Testing the provider with Terraform

Once you've built the plugin binary (see Developing the provider), you can incorporate it into your Terraform environment using the -plugin-dir option. Subsequent runs of Terraform will use the plugin from your development environment.

$ terraform init -plugin-dir $GOPATH/bin

Bare Metal Cloud community

Become part of the Bare Metal Cloud community to get updates on new features, help us improve the platform, and engage with developers and other users.

Resources

Documentation

Contact phoenixNAP

Get in touch with us if you have questions or need help with Bare Metal Cloud.

TwitterFacebookLinkedInInstagramYouTubeEmail


phoenixnap Bare Metal Cloud