Hi,
I am using this version of Terraform and AWS provider.
Terraform v0.15.0 on windows_amd64
hashicorp/aws v3.37.0
I have the code as below.
variable "secret-key-values" {
description = "List of Secert Key/Value"
type = map
}
resource "aws_secretsmanager_secret" "secret-key" {
for_each = var.secret-key-values
name = each.key
}
As I mentioned in this post Changing For-each to toset([for doesn't work as expected after upgrading TF v0.15, I am getting this errror and I canβt find the solution.
β var.secret-key-values has a sensitive value
β
β Sensitive values, or values derived from sensitive values, cannot be used
β as for_each arguments. If used, the sensitive value could be exposed as a
β resource instance key.
So I did a workaround to mark it as a nonsensitive data.
resource "aws_secretsmanager_secret" "secret-key" {
#for_each = toset([for k,v in var.secret-key-values : k])
for_each = nonsensitive(var.secret-key-values)
name = each.key
}
It works sometimes. but I got another error as below sometimes.
β Error: Invalid function argument
β
β on ..\modules\secerts-management\main.tf line 3, in resource "aws_secretsmanager_secret" "secret-key":
β 3: for_each = nonsensitive(var.secret-key-values)
β βββββββββββββββββ
β β var.secret-key-values is (sensitive value)
β
β Invalid value for "value" parameter: the given value is not sensitive, so
β this call is redundant.
So, Terraform auto-detect some sensitive data sometimes and sometimes, it throws an exception and says itβs not sensitive.
Itβs driving me crazy now. Am I missing something? How does Terraform detect sensitive data?