0

I want to store a webhook URL in AWS SSM parameter store and pass the value to the lambda environment variable using terraform. When I ran the terraform, the lambdas environment variable doesn't get the value from the SSM parameter store.Any idea if this is possible thru terraform without updating lambda code?

Lambda Env Variable:

WEBHOOK_URL :

data.aws_ssm_parameter.ecr_scan_notify_ssm.value

Config:

resource "aws_ssm_parameter" "ecr_scan_notify_ssm" {
    name      = "ecr_scan_notify_ssm"
    type      = "SecureString"
    value     = "not defined here"
    overwrite = false
    lifecycle {
        ignore_changes = [value,]
        }
    }

data "aws_ssm_parameter" "ecr_scan_notify_ssm" {
  name      = "ecr_scan_notify_ssm"
}

environment {
   variables = {
   WEBHOOK_URL = "data.aws_ssm_parameter.ecr_scan_notify_ssm.value"
   CHANNEL     = "test-scan"
  }
}

1 Answer 1

4

You're just passing a hard-coded string "data.aws_ssm_parameter.ecr_scan_notify_ssm.value". There is no lookup happening here. You either need to use string interpolation syntax:

WEBHOOK_URL = "${data.aws_ssm_parameter.ecr_scan_notify_ssm.value}"

Or just reference the value directly:

WEBHOOK_URL = data.aws_ssm_parameter.ecr_scan_notify_ssm.value

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.