$ go get github.com/nicgrayson/terraform-provider-marathon
Use a tfvar file or set the ENV variable
$ export TF_VAR_marathon_url="http://marthon.domain.tld:8080"
variable "marathon_url" {}
provider "marathon" {
url = "${var.marathon_url}"
}
If Marathon endpoint requires basic auth (with TLS, hopefully), optionally include username and password:
$ export TF_VAR_marathon_url="https://marthon.domain.tld:8443"
$ export TF_VAR_marathon_user="username"
$ export TF_VAR_marathon_password="password"
variable "marathon_url" {}
variable "marathon_user" {}
variable "marathon_password" {}
provider "marathon" {
url = "${var.marathon_url}"
basic_auth_user = "${var.marathon_user}"
basic_auth_password = "${var.marathon_password}"
}
To use Marathon from a DCOS cluster you need to get a token and include the framework path in the Marathon URL:
export TF_VAR_marathon_url="http://dcos.domain.tld/service/marathon"
export TF_VAR_dcos_token="<authentication-token>"
variable "marathon_url" {}
variable "dcos_token" {}
provider "marathon" {
url = "${var.marathon_url}"
dcos_token = "${var.dcos_token}"
}
If you have an additional Marathon instance called marathon-alice set marathon_url to http://dcos.domain.tld/service/marathon-alice
. Refer to the go-marathon documentation to get details about custom paths in Marathon URLs.
resource "marathon_app" "hello-world" {
app_id= "/hello-world"
cmd = "echo 'hello'; sleep 10000"
cpus = 0.01
instances = 1
mem = 16
ports = [0]
}
resource "marathon_app" "docker-hello-world" {
app_id = "/docker-hello-world"
container {
docker {
image = "hello-world"
}
}
cpus = 0.01
instances = 1
mem = 16
ports = [0]
}
$ go install
$ export MARATHON_URL="http://marthon.domain.tld:8080"
$ ./test.sh
This project uses godep to manage dependencies. If you're using Golang 1.6+, to build, nothing needs done. Please refer to https://devcenter.heroku.com/articles/go-dependencies-via-godep for help with updating and restoring godeps.