The following construct below fails for me during the plan stage with the following error:
2024-08-01T14:27:14.7200965Z Error: Value for unconfigurable attribute
2024-08-01T14:27:14.7201322Z 2024-08-01T14:27:14.7201613Z with
data.aws_lambda_function.rds_sqlserver_secret_rotation_lambda,
2024-08-01T14:27:14.7202700Z on rds-sql-staging.tf line 82, in data
“aws_lambda_function” “rds_sqlserver_secret_rotation_lambda”:
2024-08-01T14:27:14.7203011Z 82: data “aws_lambda_function”
“rds_sqlserver_secret_rotation_lambda” { 2024-08-01T14:27:14.7203154Z
2024-08-01T14:27:14.7203417Z Can’t configure a value for
“environment”: its value will be decided 2024-08-01T14:27:14.7204096Z
automatically based on the result of applying this configuration.
An attempt is made below to add an enviroment variable to a newly created or previously existing Lamnda function via this configuration. There must be a preferred approach as the construct below is failing.
module "rds_sqlserver" {
...outputs secret_rotation_lambda_function_arn = function name
}
data "aws_lambda_function" "rds_sqlserver_secret_rotation_lambda" {
function_name = module.rds_sqlserver.secret_rotation_lambda_function_arn
environment {
variables = {
foo = "bar"
}
}
}