Skip to content

Commit

Permalink
fix: Lambda should depend on policy attachments (#327)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreas Freimuth <andreas.freimuth@qbeyond.de>
Co-authored-by: Anton Babenko <anton@antonbabenko.com>
  • Loading branch information
3 people committed Sep 1, 2022
1 parent b1ad49f commit b4eef74
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,28 @@ resource "aws_lambda_function" "this" {

tags = var.tags

# 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_object.lambda_package, aws_cloudwatch_log_group.lambda]
depends_on = [
null_resource.archive,
aws_s3_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.
aws_cloudwatch_log_group.lambda,

# Before the lambda is created the execution role with all its policies should be ready
aws_iam_role_policy_attachment.additional_inline,
aws_iam_role_policy_attachment.additional_json,
aws_iam_role_policy_attachment.additional_jsons,
aws_iam_role_policy_attachment.additional_many,
aws_iam_role_policy_attachment.additional_one,
aws_iam_role_policy_attachment.async,
aws_iam_role_policy_attachment.logs,
aws_iam_role_policy_attachment.dead_letter,
aws_iam_role_policy_attachment.vpc,
aws_iam_role_policy_attachment.tracing,
]
}

resource "aws_lambda_layer_version" "this" {
Expand Down

0 comments on commit b4eef74

Please sign in to comment.