Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make lambda function depend on the Cloudwatch log group #133

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module "lambda_function" {
source_path = "${path.module}/../fixtures/python3.8-app1"

store_on_s3 = true
s3_bucket = module.s3_bucket.this_s3_bucket_id
s3_bucket = module.s3_bucket.s3_bucket_id

layers = [
module.lambda_layer_local.this_lambda_layer_arn,
Expand Down Expand Up @@ -183,7 +183,7 @@ module "lambda_layer_s3" {
source_path = "${path.module}/../fixtures/python3.8-app1"

store_on_s3 = true
s3_bucket = module.s3_bucket.this_s3_bucket_id
s3_bucket = module.s3_bucket.s3_bucket_id
}

##############
Expand Down
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ resource "aws_lambda_function" "this" {

tags = var.tags

depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package]
# Depending on the log group is necessary to allow Terraform to create the log group before AWS can.
# When a lambda function is invoked, AWS creates the log group automatically if it doesn't exist yet.
# Without the dependency, this can result in a race condition if the lambda function is invoked before
# Terraform can create the log group.
depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package, aws_cloudwatch_log_group.lambda]
}

resource "aws_lambda_layer_version" "this" {
Expand Down