Skip to content

Commit b4eef74

Browse files
x539aFreimuthQbyantonbabenko
authored
fix: Lambda should depend on policy attachments (#327)
Co-authored-by: Andreas Freimuth <[email protected]> Co-authored-by: Anton Babenko <[email protected]>
1 parent b1ad49f commit b4eef74

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

main.tf

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,28 @@ resource "aws_lambda_function" "this" {
101101

102102
tags = var.tags
103103

104-
# Depending on the log group is necessary to allow Terraform to create the log group before AWS can.
105-
# When a lambda function is invoked, AWS creates the log group automatically if it doesn't exist yet.
106-
# Without the dependency, this can result in a race condition if the lambda function is invoked before
107-
# Terraform can create the log group.
108-
depends_on = [null_resource.archive, aws_s3_object.lambda_package, aws_cloudwatch_log_group.lambda]
104+
depends_on = [
105+
null_resource.archive,
106+
aws_s3_object.lambda_package,
107+
108+
# Depending on the log group is necessary to allow Terraform to create the log group before AWS can.
109+
# When a lambda function is invoked, AWS creates the log group automatically if it doesn't exist yet.
110+
# Without the dependency, this can result in a race condition if the lambda function is invoked before
111+
# Terraform can create the log group.
112+
aws_cloudwatch_log_group.lambda,
113+
114+
# Before the lambda is created the execution role with all its policies should be ready
115+
aws_iam_role_policy_attachment.additional_inline,
116+
aws_iam_role_policy_attachment.additional_json,
117+
aws_iam_role_policy_attachment.additional_jsons,
118+
aws_iam_role_policy_attachment.additional_many,
119+
aws_iam_role_policy_attachment.additional_one,
120+
aws_iam_role_policy_attachment.async,
121+
aws_iam_role_policy_attachment.logs,
122+
aws_iam_role_policy_attachment.dead_letter,
123+
aws_iam_role_policy_attachment.vpc,
124+
aws_iam_role_policy_attachment.tracing,
125+
]
109126
}
110127

111128
resource "aws_lambda_layer_version" "this" {

0 commit comments

Comments
 (0)