Skip to content

Commit

Permalink
provider/triton: Add insecure_skip_tls_verify
Browse files Browse the repository at this point in the history
This commit adds an option to skip TLS verification of the Triton
endpoint, which can be useful for private or temporary installations not
using a certificate signed by a trusted root CA.

Fixes hashicorp#13722.
  • Loading branch information
jen20 committed Apr 28, 2017
1 parent 01714ec commit eaed36b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
21 changes: 17 additions & 4 deletions builtin/providers/triton/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func Provider() terraform.ResourceProvider {
Required: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{"TRITON_KEY_ID", "SDC_KEY_ID"}, ""),
},

"insecure_skip_tls_verify": {
Type: schema.TypeBool,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("TRITON_SKIP_TLS_VERIFY", ""),
},
},

ResourcesMap: map[string]*schema.Resource{
Expand All @@ -56,10 +62,11 @@ func Provider() terraform.ResourceProvider {
}

type Config struct {
Account string
KeyMaterial string
KeyID string
URL string
Account string
KeyMaterial string
KeyID string
URL string
InsecureSkipTLSVerify bool
}

func (c Config) validate() error {
Expand Down Expand Up @@ -98,6 +105,10 @@ func (c Config) getTritonClient() (*triton.Client, error) {
return nil, errwrap.Wrapf("Error Creating Triton Client: {{err}}", err)
}

if c.InsecureSkipTLSVerify {
client.InsecureSkipTLSVerify()
}

return client, nil
}

Expand All @@ -106,6 +117,8 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
Account: d.Get("account").(string),
URL: d.Get("url").(string),
KeyID: d.Get("key_id").(string),

InsecureSkipTLSVerify: d.Get("insecure_skip_tls_verify").(bool),
}

if keyMaterial, ok := d.GetOk("key_material"); ok {
Expand Down
1 change: 1 addition & 0 deletions website/source/docs/providers/triton/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ The following arguments are supported in the `provider` block:
* `key_material` - (Optional) This is the private key of an SSH key associated with the Triton account to be used. If this is not set, the private key corresponding to the fingerprint in `key_id` must be available via an SSH Agent.
* `key_id` - (Required) This is the fingerprint of the public key matching the key specified in `key_path`. It can be obtained via the command `ssh-keygen -l -E md5 -f /path/to/key`
* `url` - (Optional) This is the URL to the Triton API endpoint. It is required if using a private installation of Triton. The default is to use the Joyent public cloud us-west-1 endpoint. Valid public cloud endpoints include: `us-east-1`, `us-east-2`, `us-east-3`, `us-sw-1`, `us-west-1`, `eu-ams-1`
* `insecure_skip_tls_verify` (Optional - defaults to false) This allows skipping TLS verification of the Triton endpoint. It is useful when connecting to a temporary Triton installation such as Cloud-On-A-Laptop which does not generally use a certificate signed by a trusted root CA.

0 comments on commit eaed36b

Please sign in to comment.