pathtofile / terraform-provider-bitlaunch

BitLaunch Terraform Provider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BitLaunch Terraform Provider

This provider provides a basic way to create and manage BitLaunch VMs, which can be paid for using Bitcoin.

If you find this project useful, feel free to buy me a coffee in BTC at 16g88jxnX315CnjTDbfZ9hwuWgeSbRJdMG

Using

Get API Token

First create an account on BitLaunch.io, and add funds using either Bitcoin, Ethereum, or Litecoin.

Then under settings, Generate and save your API Token.

Create Terraform

To Use, just use the hashicorp.com/pathtofile/bitlaunch provider, proving your API Token:

terraform {
  required_providers {
    bitlaunch = {
      version = "0.4.0"
      source = "pathtofile-tf/bitlaunch"
    }
  }
}

provider "bitlaunch" {
  token = "<YOUR_API_TOKEN>"
}

Full Example

This example creates a new small Ubuntu VM, as well as a new SSH key to be used to connect to the VM.

terraform {
  required_providers {
    bitlaunch = {
      version = "0.4.0"
      source = "pathtofile-tf/bitlaunch"
    }
  }
}

variable "token" { sensitive = true }
variable "host" { default = "DigitalOcean" }

provider "bitlaunch" {
  token = var.token
}

// Data
data "bitlaunch_image" "image" {
  host         = var.host
  distro_name  = "Ubuntu"
  version_name = "20.04 (LTS) x64"
}

data "bitlaunch_region" "region" {
  host        = var.host
  region_name = "San Francisco"
  slug        = "sfo2"
}

data "bitlaunch_size" "size" {
  host      = var.host
  cpu_count = 2
  memory_mb = 2048
}

// Resources
resource "bitlaunch_sshkey" "sshkey" {
  name    = "tf_sshkeys"
  content = var.ssh_pubkey
}

resource "bitlaunch_sever" "server" {
  host     = var.host
  name     = "tf_server"
  image_id = data.bitlaunch_image.image.id
}

See the full docs on the Terraform registry page, as well as the BitLaunch API Docs, for more details. Most of the API objects have a 1:1 mapping to Terraform Resources or Data sources.

Building

Requirements

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider using the Go install command:
$ go install

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).

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

To generate or update documentation, run go generate.

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

About

BitLaunch Terraform Provider

License:Mozilla Public License 2.0


Languages

Language:Go 99.6%Language:Makefile 0.4%