Repository navigation
Description
Description
Terraform can hit a race condition while deploying the runner Lambdas and their CloudWatch log groups.
For example, in modules/runners/scale-down.tf, Terraform may create the scale-down Lambda and its scheduled EventBridge invocation before it creates the explicitly managed CloudWatch log group. If the schedule invokes the Lambda during that window, AWS automatically creates /aws/lambda/<function-name>. Terraform then attempts to create the same log group and fails because it already exists.
Expected behavior
Every Terraform-managed Lambda log group must exist before its Lambda can be created or invoked, preventing AWS from creating the log group outside Terraform. All Lambda modules should use the same dependency pattern for consistent behavior and maintainability.
Scope
- Standardize all Terraform-managed Lambda log groups in the repository, including these CloudWatch log-group/Lambda pairs:
aws_cloudwatch_log_group.ami_housekeeperinmodules/ami-housekeeper/main.tfaws_cloudwatch_log_group.syncerinmodules/runner-binaries-syncer/runner-binaries-syncer.tfaws_cloudwatch_log_group.scale_downaws_cloudwatch_log_group.scale_upaws_cloudwatch_log_group.ssm_housekeeperaws_cloudwatch_log_group.mainaws_cloudwatch_log_group.poolaws_cloudwatch_log_group.webhookinmodules/webhook/directaws_cloudwatch_log_group.dispatcherinmodules/webhook/eventbridgeaws_cloudwatch_log_group.webhookinmodules/webhook/eventbridge
- Derive each log-group name without referencing the Lambda resource, avoiding the current implicit
log group -> Lambdadependency. - Make each Lambda explicitly depend on its own log group.
- Preserve the existing function and log-group names, retention settings, encryption, and tags.
- Add or update tests to verify the dependency ordering for all affected Lambdas.
Acceptance criteria
- A fresh deployment cannot invoke a managed Lambda before Terraform has created its CloudWatch log group.
- Terraform no longer fails with a duplicate/already-existing log-group error when a Lambda is invoked during deployment.
- All Terraform-managed Lambda/log-group pairs follow the same dependency pattern.
Activity
fix(lambda): create log groups before functions (#5324)
chore(main): release 8.0.0 (#5276)