cab105 / terraform-provider-exoscale

Exoscale specific provider for hashicorp/terraform
0 stars 15 forks source link

Building

Set GOPATH to this directory, and then run make

Ensure that the PATH is set to include the resulting bin directory, and then you can run the terraform command that will produce the exoscale plugin.

Once built, you can install the terraform-provider-exoscale plugin by copying the resulting binary file into the location where the remaining Terraform program and plugins reside.

Terraform Usage

What follows below is the usage instructions for fully utilizing the Exoscale resource plugin. Additional documentation can be found in the examples directory.

Provider requirements

provider "exoscale" {
    token = ""
    secret = ""
}

You are required to provide at least the OAuth API token and secret key in order to make use of the remaining Terraform resources.

You can specify the environment variables for these using EXOSCALE_API_SECRET or EXOSCALE_API_KEY. You can also use the cloudstack environment variables CLOUDSTACK_(API|SECRET)_KEY.

SSH Resource

Declare an ssh key that will be used for any current/future instances

resource "exoscale_ssh" "keylabel" {
    name = "keyname"
    key = "keycontents"
}

Anti-Affinity Groups

Define an affinity group that can be used to group various instances together

resource "exoscale_affinity" "affinitylabel" {
    name = "affinity name"
}

Security Groups

Provide a named grouping of firewall rules that would be applicable for each instance.

resource "exoscale_securitygroup" "sglabel" {
    name = "sgname"
    ingressRules = {
      cidr = "0.0.0.0/0"
      protocol = "TCP"
      port = 22
    }
    egressRules = {
      cider = "192.168.1.0/24"
      protocol = "TCP"
      port = 22
    }
    egressRules = {
      cidr = "192.168.1.0/24"
      protocol = "ICMP"
      icmptype = 0
      icmpcode = 0
    }
}

Compute Instances

Define a new compute resource.

resource "exoscale_compute" "computelabel" {
    name = "testname"
    template = "ubuntu-16.04"
    zone = "ch-gva-2"
    size = "Micro"
    diskSize = 10
    keypair = "terraformKey"
    affinitygroups = ["terraformag"]
    securitygroups = ["sshgroup"]
    userdata = ""
}

DNS

If the user has an active DNS subscription with Exoscale, allow them the ability to manage their DNS information.

resource "exoscale_dns" "testdomain" {
    name = "testdomain.ch"
    record = {
        name = "test1"
        type = "A"
        content = "192.168.1.1"
    }
    record = {
        name = "test2"
        type = "CNAME"
        content = "test1"
    }
}

S3

There are two resources that define the S3 interaction: buckets for the creation/management of the bucket name, and objects for the contents of said buckets.

resource "exoscale_s3bucket" "testbucket" {
    bucket = "tftest"
    acl = "private"
}
resource "exoscale_s3object" "testobj" {
    bucket = "tftest"
    acl = "private"
    key "test/path.txt"
    type = "text/plain"
    content = "hello world"
}

resource "exoscale_s3object" "testobj" {
    bucket = "tftest"
    acl = "private"
    key "test/path2.txt"
    type = "text/plain"
    source = "/tmp/test.txt"
}

While content and source are mutually exclusive, one of them is required for the operation to succeed.

TODO List/Missing features

Security Groups

S3 Support