I have a cyclic dependency problem with terraform. I have a user pool user_pool
which invokes a lambda user_signup_lambda
as a trigger when a user signs up. This lambda also needs the user pool's Id as an environment variable.
My terraform looks like this
resource "aws_lambda_function" "user_signup_lambda" {
function_name = "user_signup_lambda"
filename = var.file_name
source_code_hash = filebase64sha256(var.file_name)
handler = var.handler
runtime = var.runtime
memory_size = var.memory_size
timeout = var.timeout
role = var.iam_role_arn
environment {
variables = aws_cognito_user_pool.user_pool.id
}
}
resource "aws_cognito_user_pool" "user_pool" {
name = "some-user-pool"
....other config
lambda_config {
post_confirmation = module.user_signup_lambda.arn
}
This results in the following error:
Error: Cycle: module.user_signup_lambda.var.environment_variables, module.user_signup_lambda.aws_lambda_function.lambda_function, module.user_signup_lambda.output.arn, aws_cognito_user_pool.user_pool
Is there anyway around this other than hardcoding the user pool id?
userPoolId
in it that you can read from there instead. docs.aws.amazon.com/cognito/latest/developerguide/… has an example Lambda function and an example event input. – Clothboundapply
though. – Clothbound