Merge pull request #13956 from weargoggles/patch-1

provider/nomad: Add TLS options
This commit is contained in:
Jake Champlin 2017-04-27 10:43:50 -04:00 committed by GitHub
commit e91d915154
2 changed files with 24 additions and 0 deletions

View File

@ -24,6 +24,24 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("NOMAD_REGION", ""), DefaultFunc: schema.EnvDefaultFunc("NOMAD_REGION", ""),
Description: "Region of the target Nomad agent.", 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, ConfigureFunc: providerConfigure,
@ -38,6 +56,9 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config := api.DefaultConfig() config := api.DefaultConfig()
config.Address = d.Get("address").(string) config.Address = d.Get("address").(string)
config.Region = d.Get("region").(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) client, err := api.NewClient(config)
if err != nil { if err != nil {

View File

@ -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. * `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. * `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.