I would like to create an AWS RDS secret via Terraform (just the username and password, no rotation or KMS):
resource "aws_secretsmanager_secret" "test-db-secret" {
name = "test-db-secret"
password = thisismypassword
}
data "aws_secretsmanager_secret" "test-db-secret"
name = "test-db-secret"
Then refer to it in my lambda function environment resource section in main.tf:
resource "aws_lambda_function" "lambda_function" {
.
.
.
.
environment {
variables = {
DB_PASS = data.aws_secretsmanager_secret.password
Obviously I am not using the Terraform secret stuff correctly because I am getting errors, it’s not creating the secret. Even if I manually create the secret via the AWS console and skip the resource block above and just use the data block along with the DB_PASS, it still doesn’t like that. Any help would be much appreciated.