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

How to read secrets for a file. #32

Open
judeaugustinej opened this issue Mar 10, 2023 · 1 comment
Open

How to read secrets for a file. #32

judeaugustinej opened this issue Mar 10, 2023 · 1 comment

Comments

@judeaugustinej
Copy link

main.tf

terraform {
required_providers {
sops = {
source = "carlpett/sops"
version = "~> 0.5"
}
}
}

module "secrets-manager-2" {

source = "git::https://github.com/lgallard/terraform-aws-secrets-manager.git?ref=0.6.2"
secrets = jsondecode(file("${path.module}/secrets/mongo-secret"))
}

i have directory called,
cat secrets/mongo-secret
{
secret-kv-1 = {
description = "This is a key/value secret"
secret_key_value = {
key1 = "value1"
key2 = "value2"
}
recovery_window_in_days = 7
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnableAllPermissions",
"Effect": "Allow",
"Principal": {
"AWS": ""
},
"Action": "secretsmanager:GetSecretValue",
"Resource": "
"
}
]
}
POLICY
},
secret-kv-2 = {
description = "Another key/value secret"
secret_key_value = {
username = "user"
password = "topsecret"
}
tags = {
app = "web"
}
recovery_window_in_days = 7
policy = null
},
}

when i run plan,

│ Error: Error in function call

│ on main.tf line 13, in module "secrets-manager-2":
│ 13: secrets = jsondecode(file("${path.module}/secrets/mongo-secret"))
│ ├────────────────
│ │ while calling jsondecode(str)
│ │ path.module is "."

│ Call to function "jsondecode" failed: invalid character 's'.

@lgallard
Copy link
Owner

@judeaugustinej it seems an issue in the way you are using the module or the content or your file. Let me know if you were able to overcame it.

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

2 participants