diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 89fc2c0e..431a58c6 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -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, @@ -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 } ############## diff --git a/main.tf b/main.tf index 70458153..9b765413 100644 --- a/main.tf +++ b/main.tf @@ -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" {