Skip to content
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

SOPS json issue with complex types #3127

Open
giulianozor opened this issue May 9, 2024 · 0 comments
Open

SOPS json issue with complex types #3127

giulianozor opened this issue May 9, 2024 · 0 comments

Comments

@giulianozor
Copy link

giulianozor commented May 9, 2024

Hello,
I`m trying to convert my input block variables to json encrypted with sops.

sops 3.8.1 (latest)
terragrunt version 0.57.8
Terraform v1.8.1

terragrunt.hcl:

include {
  path = find_in_parent_folders()
}

locals {
  v = read_terragrunt_config(find_in_parent_folders("common.hcl"))
  src = local.v.inputs.tg_github_base)
  ref = "?ref=1.0.0" : ""
  template = "/templates/test/"
  secrets = jsondecode(sops_decrypt_file("secrets.json"))
}

terraform {
  source = "${local.src}${local.template}${local.ref}"
}

inputs = merge(local.secrets, {})

original input:

secrets = [
    { name = "sec1",              value = "abc" },
    { name = "sec2",              value = "cde" },
    { name = "sec3",             value = <<-EOF
      {
        "a1":"xxx",
        "a2":"yyy"
        }
EOF
   }]

plaintext json

"secrets": [
		{ "name": "sec1",              "value": "abc" },
		{ "name": "sec2",              "value": "cde" },
                { "name": "sec3",             "value": "{\"a1\":\"xxx\",\"a2\":\"yyy\"}"]
	

This produces a different sec3 value in TF_VAR_secrets.
If I try to use a plain json (without stringifying the sec3 value), I get an error because the types in secrets are different.
Is there a way to get the same value as the original variable (<<--EOF ... EOF) ?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant