bobtfish / terraform-provider-nsone

A terraform provider to manage zones/records/feeds in nsone
Apache License 2.0
17 stars 10 forks source link

Synopsis

This is an experimental provider which allows Terraform to create and update DNS zones, records, monitoring jobs, data sources and feeds, and other resources with the NSONE API.

Example use

provider "nsone" {
  api_key = "xxxxxxx" # Or set NSONE_APIKEY environment variable
}

resource "nsone_datasource" "api" {
  name = "terraform test"
  sourcetype = "nsone_v1"
}

resource "nsone_datafeed" "exampledc1" {
  name = "exampledc1"
  source_id = "${nsone_datasource.api.id}"
  config {
    label = "exampledc1"
  }
}

resource "nsone_datafeed" "exampledc2" {
  name = "exampledc2"
  source_id = "${nsone_datasource.api.id}"
  config {
    label = "exampledc2"
  }
}

resource "nsone_zone" "example" {
  zone = "mycompany.com"
  ttl = 60
}

resource "nsone_record" "www" {
  zone = "${nsone_zone.example.zone}"
  domain = "www.${nsone_zone.example.zone}"
  type = "A"
  answers {
    answer = "1.1.1.1"
    meta {
      field = "up"
      feed = "${nsone_datafeed.exampledc1.id}"
    }
    region = "useast"
  }
  answers {
    answer = "2.2.2.2"
    meta {
      feed = "${nsone_datafeed.exampledc2.id}"
      field = "up"
    }
    region = "uswest"
  }
  regions {
    name = "useast"
    georegion = "US-EAST"
  }
  regions {
    name = "uswest"
    georegion = "US-WEST"
  }
  filters {
    filter = "up"
  }
  filters {
    filter = "select_first_n"
    config {
      N = 1
    }
  }
}

resource "nsone_record" "star" {
  link = "www.${nsone_zone.example.zone}"
}

resource "nsone_zone" "co_uk" {
  zone = "mycompany.co.uk"
  link = "${nsone_zone.example.zone}"
}

resource "nsone_monitoringjob" "useast" {
  name = "useast"
  active = true
  regions = [ "lga" ]
  job_type = "tcp"
  frequency = 60
  rapid_recheck = true
  policy = "all"
  config {
    send = "HEAD / HTTP/1.0\r\n\r\n"
    port = 80
    host = "1.1.1.1"
  }
}

See the examples/ folder in the repository for more detailed examples.

Installing

make install

Should do the right thing assuming that you have terraform already installed, and this code is placed in the right place in your $GOPATH.

Supported features

Create and manage DNS zones

* Normal primary zones supported
* Linked zones supported
* Secondary (slave) zones supported

Manage records in your zones

* A, MX, ALIAS and CNAME record types are supported.
* Other record types MAY work, but are untested.
* Supports NSONE's Linked Records
* Supports multiple answers, each of which can be connected to data feeds
* Add filter chains to records, with config
* Add regions to answers, and the record. Some (not all!) region metadata types are supported.

Data sources

* Can create datasources with arbitrary config
* This *should* work for all datasource types, but only nsone_v1 and nsone_monitoring are tested

Data feeds

* Create data feeds connected to a data source with a label

NSONE monitoring

* Create and manage monitoring jobs.
* Connect monitoring notifications to data feeds and use monitors to control record up/down status.

Users / Account management / API keys

Unsupported features

Zones

Records

NSONE monitoring

Resources provided

nsone_zone

Creates a DNS zone in NSONE.

Inputs

Outputs

nsone_record

Creates a DNS record and optional traffic management config in NSONE.

Inputs

Outputs

nsone_datasource

NSONE Data Sources are conduits for pushing updates to DNS record/answer metadata through individual data feeds to NSONE's platform.

Inputs

Outputs

nsone_datafeed

Multiple data feeds may be associated with an NSONE Data Source -- for example, feeds keyed to individual servers, monitoring jobs, etc.

Inputs

Outputs

nsone_monitoringjob

NSONE's Monitoring jobs enable up/down monitoring of your different service endpoints, and can feed directly into DNS records to drive DNS failover.

Inputs

Outputs

nsone_user

Inputs

N.B. This also has all the inputs from the nsone_team resource, which you can use instead of assigning to key to one or more teams.

Outputs

nsone_apikey

Inputs

N.B. This also has all the inputs from the nsone_team resource, which you can use instead of assigning to key to one or more teams.

Outputs

nsone_team

Permissions are all optional -- by default, a user is granted an unspecified permission.

Inputs

Outputs

Support / contributions

I'm planning to continue developing and supporting this code for my use-cases, and I'll do my best to respond to issues and pull requests (and I'm happy to take patches to improve the code or add missing feaures!).

Also, please be warned that I am not a competent Go programmer, so please expect to find hideous / insane / non-idiomatic code if you look at the source. I'd be extremely happy to accept patches or suggestions from anyone more experience than me:)

Please feel free to contact me via github issues or Twitter or irc in #terraform (t0m) if you have any issues with, or would like advice on using this code.

Copyright

Copyright (c) Tomas Doran 2015

LICENSE

Apache2 - see the included LICENSE file for more information