tls.tf missing resource instance key
jkzlau opened this issue · 0 comments
jkzlau commented
Hi there,
In attempt to perform terraform apply/plan, an error message indicating that a missing reference is in the code, particular as follow:
Error: Missing resource instance key
on tls.tf line 124, in resource "google_storage_bucket_object" "vault-private-key":
124: content = data.google_kms_secret_ciphertext.vault-tls-key-encrypted.ciphertext
Because data.google_kms_secret_ciphertext.vault-tls-key-encrypted has "count"
set, its attributes must be accessed on specific instances.
For example, to correlate with indices of a referring resource, use:
data.google_kms_secret_ciphertext.vault-tls-key-encrypted[count.index]
The line is referencing the ciphertext call that doesn't look to have been assigned
# Encrypt server key with GCP KMS
data "google_kms_secret_ciphertext" "vault-tls-key-encrypted" {
count = local.manage_tls_count
crypto_key = google_kms_crypto_key.vault-init.self_link
plaintext = tls_private_key.vault-server[0].private_key_pem
}
resource "google_storage_bucket_object" "vault-private-key" {
count = local.manage_tls_count
name = var.vault_tls_key_filename
content = data.google_kms_secret_ciphertext.vault-tls-key-encrypted.ciphertext
bucket = local.vault_tls_bucket
depends_on = [google_storage_bucket.vault]
lifecycle {
ignore_changes = [
content,
]
}
}
As this looks to be a 0.12+ requirement, is there anyway around this?
Thanks for the work!