Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider: support TLS certs configured by strings. #184

Merged
merged 2 commits into from
Jan 14, 2021
Merged

Conversation

jrasell
Copy link
Member

@jrasell jrasell commented Jan 12, 2021

This change adds a number of new provider config params that allow users to configure TLS certificates via strings, alongside the pre-existing file location method.

The provider schema ConflictsWith param is used to notify users when a configuration attempts to use two keys which affect the same TLS config param. In order to successfully use this, the existing DefaultFunc default values have been moved from an empty string to nil. This is because Terraform treats an empty string var as being populated, and therefore raises a conflict error whenever a new param is set. I tested this change locally to ensure it didn't cause any compatibility issues, and didn't find any. It is reassures that the Consul provider went through the same change.

The provider doesn't have much testing around its configuration, so I will open an issue to improve this in the future. In the meantime when testing locally I used the Nomad dev tls cluster along with the Terraform code below to test. The local plugin is located within ~/.terraform.d/plugins/hashicorp.com/hashicorp/nomad/0.1/darwin_amd64/.

provider "nomad" {
  address  = "https://127.0.0.1:4646"
  ca_pem   = file("~/go/src/github.com/hashicorp/nomad/dev/tls_cluster/certs/nomad-ca.pem")
  cert_pem = file("~/go/src/github.com/hashicorp/nomad/dev/tls_cluster/certs/server.pem")
  key_pem  = file("~/go/src/github.com/hashicorp/nomad/dev/tls_cluster/certs/server-key.pem")
}

resource "nomad_namespace" "test" {
  name = "test"
}

terraform {
  required_providers {
    nomad = {
      versions = ["0.1"]
      source   = "hashicorp.com/hashicorp/nomad"
    }
  }
}

closes #181

This change adds a number of new provider config params that allow
users to configure TLS certificates via strings, alongside the
pre-existing file location method.

The provider schema ConflictsWith param is used to notify users
when a configuration attempts to use two keys which affect the
same TLS config param. In order to successfully use this, the
existing DefaultFunc default values have been moved from an empty
string to nil. This is because Terraform treats an empty string
var as being populated, and therefore raises a conflict error
whenever a new param is set. I tested this change locally to ensure
it didn't cause any compatibility issues, and didn't find any. It
is reassures that the Consul provider went through the same change.
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jrasell jrasell merged commit 5f50a07 into master Jan 14, 2021
@jrasell jrasell deleted the f-gh-181 branch January 14, 2021 08:36
jrasell added a commit that referenced this pull request Jan 14, 2021
jrasell added a commit that referenced this pull request Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for TLS Certificates as Strings
2 participants