-
Notifications
You must be signed in to change notification settings - Fork 64
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
ns1_apikey.key is always empty #340
Comments
Hi @norman-zon 👋 There are a couple of examples here using outputs as well: https://support.hashicorp.com/hc/en-us/articles/5175257151891-How-to-output-sensitive-data-with-Terraform If you really want to see the key output on creation you can do this: resource "ns1_apikey" "ns1-mykey" {
name = "tf test key"
}
output "token_value" {
value = nonsensitive(ns1_apikey.ns1-mykey.key)
} |
My goal is to use it directly in terraform, for example to write it to a vault secret. resource "vault_generic_secret" "example" {
path = "secret/foo"
data_json = jsonencode(
tomap({
"api_key" = ns1_apikey.ns1-mykey.key,
})
)
} This works for the first apply, on creation, but on the second apply would be set to Can the |
I see! As you've noted the key is not present on subsequent API calls, but given that the key will not change, you could ignore it on the change on the vault resource if this is acceptable: resource "ns1_apikey" "ns1-mykey" {
name = "tf test key"
}
resource "vault_generic_secret" "example" {
path = "secret/foo"
data_json = jsonencode(
tomap({
"api_key" = ns1_apikey.ns1-mykey.key,
})
)
lifecycle {
ignore_changes = [data_json]
}
} |
That would work. But IMHO it defeats the purpose of having the key in terraform. I completely understand where you come from hiding the key in the UI after creation, but for IAC this seems to be an unhelpful approach. |
OK, I will open a ticket internally and work on this 👍 |
@norman-zon Could you please try version |
Yes! That works. Thank you very much for the quick fix. |
Per docs ns1_apikey.key should be exported.
terraform state show
:Does not list it.
Trying to access it from another resource with
ns1_apikey.ns1-mykey
does not fail, but is an empty string.How am I supposed to access the API key itself?
The text was updated successfully, but these errors were encountered: