-
Notifications
You must be signed in to change notification settings - Fork 50
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
Support gossip encryption key as separate output to hcp_consul_cluster resurce #114
Comments
Hi @lkysow! Thanks for adding this issue. I'll bring this to our cloud Consul team and see if we can get this on their board. |
Also having |
Is there a mechanism during the apply to retrieve the gossip key from the config file output, to share with other terrraform resources during the same run? From the feedback of @apparentlymart in this JSON-related HashiCorp discuss thread, I'd like to marshal the output with
locals {
raw_config = base64decode(jsondecode(hcp_consul_cluster.server.consul_config_file))
gossip_key = local.raw_config.encrypt
}
output "consul_gossip_key" {
value = local.gossip_key
} From testing and prior art, I understand that
The resolution I can come up with is using It appears we are capturing the config output here in a data source, generated in L186:
...and passing along the terraform-provider-hcp/internal/provider/data_source_consul_cluster.go Lines 241 to 243 in f6ef4b6
If the config is already stored as a JSON object from the lookup, I guess/assume the work needed to unpack the keys and values from the object would be to either add additional error conditions to I'm happy to raise my ✋ and contribute to a PR if this work is being blocked by other workstreams. I'm not an expert in golang by any means, but I'd be willing to learn 😺 - At minimum, I think offering both |
After digging around, here's an example of pulling the gossip key, looks like I may have swapped my json/base64 decoding. Oops! gossip_encryption_key = jsondecode(base64decode(hcp_consul_cluster.main.consul_config_file))["encrypt"] Examples like this would beneficial in the API docs for the provider, as there were none when initially investigating. cc @trujillo-adam for 👀 |
Oh hmm yes this is an unfortunate case where Terraform had not quite enough information to return a useful error message. 😖
This is, I think, a good motivation for what this issue seems to have originally requested: if the needed information were exposed directly as an attribute of type string then Terraform's type checker could immediately know the type without first waiting to see what value this JSON string will take, and thus avoid the confusion caused by trying to decode a dynamically-generated JSON string here. |
Description
It would be helpful for the gossip encryption key to be a separate output from the
hcp_consul_cluster
resource. Currently it must be parsed from theconsul_config_file
output.New or Affected Resource(s)
hcp_consul_cluster
Potential Terraform Configuration
Community Note
The text was updated successfully, but these errors were encountered: