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

Bugfix additional policy documents #276

Merged
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 iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc" {
####################################

resource "aws_iam_policy" "additional_json" {
count = var.lambda_policy_json != null ? 1 : 0
count = var.lambda_attach_policy_json ? 1 : 0

description = "Managed by Terraform Next.js"
policy = var.lambda_policy_json
Expand All @@ -92,7 +92,7 @@ resource "aws_iam_policy" "additional_json" {
}

resource "aws_iam_role_policy_attachment" "additional_json" {
for_each = var.lambda_policy_json != null ? local.lambdas : {}
for_each = var.lambda_attach_policy_json ? local.lambdas : {}

role = aws_iam_role.lambda[each.key].name
policy_arn = aws_iam_policy.additional_json[0].arn
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ variable "lambda_policy_json" {
default = null
}

variable "lambda_attach_policy_json" {
description = "Whether to deploy additional lambda JSON policies. If false, lambda_policy_json will not be attached to the lambda function. (Necessary since policy strings are only known after apply when using Terraforms data.aws_iam_policy_document)"
type = bool
default = false
}

variable "lambda_role_permissions_boundary" {
type = string
# https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html
Expand Down