logo
Published on

Secret Manager

Authors
  • avatar
    Name
    Bowen Y
    Twitter

How to retrive the plain text of Secret in terraform?

data "aws_secretsmanager_secret_version" "secret" {
  secret_id = aws_db_instance.lodgr_db.master_user_secret[0].secret_arn
}

output "secret" {
  value = nonsensitive(data.aws_secretsmanager_secret_version.secret.secret_string)
}

ouptut >>>
secret = jsonencode(
    {
      + password = "XsAsabcdefg"
      + username = "user"
    }
)

secret-value = jsondecode(data.aws_secretsmanager_secret_version.secret.secret_string)["password"]