Skip to content

Commit

Permalink
Fix policy attachments for managed policies
Browse files Browse the repository at this point in the history
  • Loading branch information
Ewande committed Aug 6, 2020
1 parent 47917ce commit c635d16
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,21 @@ resource "aws_iam_policy_attachment" "additional_json" {
# ARN of additional policy
###########################

resource "aws_iam_policy_attachment" "additional_one" {
resource "aws_iam_role_policy_attachment" "additional_one" {
count = local.create_role && var.attach_policy ? 1 : 0

name = var.function_name
roles = [aws_iam_role.lambda[0].name]
role = aws_iam_role.lambda[0].name
policy_arn = var.policy
}

######################################
# List of ARNs of additional policies
######################################

resource "aws_iam_policy_attachment" "additional_many" {
resource "aws_iam_role_policy_attachment" "additional_many" {
count = local.create_role && var.attach_policies ? var.number_of_policies : 0

name = var.function_name
roles = [aws_iam_role.lambda[0].name]
role = aws_iam_role.lambda[0].name
policy_arn = var.policies[count.index]
}

Expand Down

0 comments on commit c635d16

Please sign in to comment.