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 Cloud • Terraform Provider • Developers Portal • Knowledge Base • Support
- Bare Metal Cloud account
- Terraform 0.12.2+
- Go 1.16.15+ (to build the provider plugin)
You need to have a Bare Metal Cloud account in order to use the pnap Terraform provider with Bare Metal Cloud.
- Go to the Bare Metal Cloud signup page.
- Follow the prompts to set up your account.
- Use your credentials to log in to Bare Metal Cloud portal.
Follow this helpful tutorial to learn how to install Terraform on your local machine.
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 [email protected]: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
The pnap provider will be installed on terraform init
as a template of the pnap_server
resource.
Terraform provider documentation
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
...
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
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
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.
- Follow @phoenixNAP on Twitter
- Join the official Slack channel
- Sign up for our Developers Monthly newsletter
Get in touch with us if you have questions or need help with Bare Metal Cloud.