Access nested data in sops_file
masterWhen using sops_file, you can access nested data in two ways:
- Via the
datamap: Use dot-separated strings as keys to reach nested values. For example, if your JSON has adbobject with apasswordfield, access it usingdata["db.password"]. - Via the
rawstring: Use Terraform'sjsondecode()function on therawattribute to convert the decrypted content into a Terraform object, then use standard object notation (e.g.,jsondecode(data.sops_file.name.raw).db.password).
output "mapped_nested_value" {
value = data.sops_file.demo_secret.data["db.password"]
}
output "nested_json_value" {
value = jsondecode(data.sops_file.demo_secret.raw).db.password
}