-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Terraform outputs sensitive information when using import block as comment #33544
Comments
Thanks, I agree we should be conservative here and not write the import id to the comment in case it's sensitive. |
This does seem to be a rather different idea of "sensitive" than how we usually think of it. Knowing an access key ID alone does not give access to anything new, but knowing it might be useful for cross-referencing with other information outside of this scope. But by that argument, all ids are sensitive because they can be used for cross-referencing. I don't mean to say that we shouldn't just delete this comment from the generated code, since the need for it seems pretty marginal anyway. But I think we should be careful to be clear about what we mean when we say "sensitive"; elsewhere in Terraform it typically means a credential granting some access to something. IAM distinguishes between the access key ID and its secret specifically so that it's possible to talk about a specific access key without disclosing its secret token. If we broaden "sensitive" to mean "anything that any individual might prefer not to disclose" then Terraform would not be able to generate any configuration at all, and so I think as part of this change (along with removing the unnecessary comment as suggested) we might wish to make sure the docs about config generation spend some words discussing the possibility that the generated files might contain information that should be edited out by the user before committing the changes, since Terraform doesn't have enough information to reliably guess what might be problematic to include in any specific situation. |
Yes, "sensitive" is not accurate here. It is sufficient that the comment is unnecessary. |
That said, this becomes a bigger problem if #33228 is implemented, as then it may be possible for an import ID to be the result of interpolating a sensitive value, in which case it is definitely inappropriate to write the literal value to the generated file. In the case described in this issue, the value written to the generated file is, by definition, already in configuration, since it must be a literal string inside the |
We currently prohibit using a sensitive map (in the sense defined by the language runtime) in resource and module That might be sufficient precedent to also prohibit using a sensitive string as the |
The import block also outputs the import ID in output as where the resource is being imported from and as the Id of the resource in the plan before apply. This means for cases like the venafi_certificate resource where the import ID contains the password for the private key that sensitive information gets exposed. This occurs even if the sensitive function is used on the value assigned to the id field of the import block. The terraform import command outputs the import ID as well. This means that there is no way to import resources such as venafi_certificate without exposing sensitive information. It would good if the ID of the import block respected the sensitive function. Here is the doco on the import ID venafi_certificate: |
I'm trying to import a random_password reading its value from onepassword_item and the id also appears in the log: |
We have hit the exactly same issue with
|
Terraform Version
Terraform Configuration Files
Will output
Debug Output
N/A
Expected Behavior
Terraform maybe should hash the value instead of plain text. While having only the AWS Access Key ID without the Secret Access Key is not as dangerous as having both, but it is still essential to treat the Access Key ID as sensitive information and take measures to protect it from unauthorized access.
Actual Behavior
terraform creates the resources and leaks the access key ids while the import blocks can be moved.
Steps to Reproduce
terraform plan -generate-config-out=generated_resources.tf
Additional Context
No response
References
https://developer.hashicorp.com/terraform/language/import/generating-configuration
The text was updated successfully, but these errors were encountered: