This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
Outputs need to support sensitive values in OutputSpec #107
Labels
enhancement
New feature or request
Community Note
Description
Currently, there does not appear to be a way to mark an output value as sensitive. When creating resources that generate their own sensitive values, the base Terraform module may set the output as sensitive, but in order to retrieve that value and have it stored in the workspace-outputs secret, it must be explicitly request as part of the workspace definition outputspec. The outputspec does not support a sensitive parameter, so when the HCL is rendered by the operator it can't mark the output value as sensitive, and so later versions (>0.14?) prevent such a plan from occurring.
This issue is different to #39, as it seems that the request there, while seemingly identical, is not solved by the provided fix of #80. Yes all outputs are now stored in a kubernetes secret, but we still can't access sensitive secrets.
Use case:
I want to create a simple AWS RDS instance, and have the password randomly generated and output so that my pods running in kubernetes can access the password for authentication. At present, I can output everything else that I need (endpoint, username etc.) except the password.
Recreating the issue
Given a simple RDS module that outputs a sensitive password value:
This is then used within a workspace CRD in the following example
This is then rendered in to HCL again by the operator and submitted to the Terraform Cloud API
When this is submitted to Terraform Cloud as part of the plan however, the following error is encountered when using any later terraform version (>0.14?) due to the sensitivity of the
module.operator.db_password
output.The error is as follows:
Running this terraform manually without the terraform operator produces the same error. The error is not with the way that the HCL is delivered to the Terraform Cloud workspace, but in the way that the HCL is rendered in the first place.
We can determine that the cause of the problem is due to the operators inability to render sensitive outputs correctly, because we can take this rendered terraform, update it, and submit it manually.
Adding the supported
sensitive = true
parameter directly to the terraform allows this to have a successful plan and apply operation(s) locally.Solution
Ultimately I believe that we need to support a sensitive parameter within the CRD spec (https://github.com/hashicorp/terraform-helm/blob/master/crds/app.terraform.io_workspaces_crd.yaml#L58) and all the supporting code within the operator to render the HCL correctly.
References
I believe that these are the initial attempts at solving this problem
#39
#80
Workspace CRD
https://github.com/hashicorp/terraform-helm/blob/master/crds/app.terraform.io_workspaces_crd.yaml#L58
The text was updated successfully, but these errors were encountered: