terraform-aws-secrets-manager
terraform-aws-secrets-manager copied to clipboard
How to read secrets for a file.
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'. ╵
@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.