Skip to content

Commit

Permalink
Merge pull request #13956 from weargoggles/patch-1
Browse files Browse the repository at this point in the history
provider/nomad: Add TLS options
  • Loading branch information
grubernaut authored Apr 27, 2017
2 parents bfc1008 + 5d40be3 commit e91d915
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions builtin/providers/nomad/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("NOMAD_REGION", ""),
Description: "Region of the target Nomad agent.",
},
"ca_file": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("NOMAD_CACERT", ""),
Description: "A path to a PEM-encoded certificate authority used to verify the remote agent's certificate.",
},
"cert_file": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("NOMAD_CLIENT_CERT", ""),
Description: "A path to a PEM-encoded certificate provided to the remote agent; requires use of key_file.",
},
"key_file": &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("NOMAD_CLIENT_KEY", ""),
Description: "A path to a PEM-encoded private key, required if cert_file is specified.",
},
},

ConfigureFunc: providerConfigure,
Expand All @@ -38,6 +56,9 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := api.DefaultConfig()
config.Address = d.Get("address").(string)
config.Region = d.Get("region").(string)
config.TLSConfig.CACert = d.Get("ca_file").(string)
config.TLSConfig.ClientCert = d.Get("cert_file").(string)
config.TLSConfig.ClientKey = d.Get("key_file").(string)

client, err := api.NewClient(config)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions website/source/docs/providers/nomad/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ The following arguments are supported:

* `address` - (Optional) The HTTP(S) API address of the Nomad agent to use. Defaults to `http://127.0.0.1:4646`. The `NOMAD_ADDR` environment variable can also be used.
* `region` - (Optional) The Nomad region to target. The `NOMAD_REGION` environment variable can also be used.
* `ca_file` - (Optional) A path to a PEM-encoded certificate authority used to verify the remote agent's certificate. The `NOMAD_CACERT` environment variable can also be used.
* `cert_file` - (Optional) A path to a PEM-encoded certificate provided to the remote agent; requires use of `key_file`. The `NOMAD_CLIENT_CERT` environment variable can also be used.
* `key_file`- (Optional) A path to a PEM-encoded private key, required if `cert_file` is specified. The `NOMAD_CLIENT_KEY` environment variable can also be used.

0 comments on commit e91d915

Please sign in to comment.