lgallard / terraform-aws-secrets-manager

Terraform module to create Amazon Secrets Manager resources.
Apache License 2.0
63 stars 50 forks source link

How to read secrets for a file. #32

Open judeaugustinej opened 1 year ago

judeaugustinej commented 1 year ago

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 commented 11 months ago

@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.