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

fix: Allow for custom_iam_policy_arns that are unknown at apply #46

Merged
merged 1 commit into from
Oct 11, 2023
Merged
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
8 changes: 6 additions & 2 deletions iam-role.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
custom_iam_policy_arns_map = length(var.custom_iam_policy_arns) > 0 ? { for i, arn in var.custom_iam_policy_arns : i => arn } : {}
}

resource "aws_iam_role" "this" {
count = local.enabled ? 1 : 0

Expand Down Expand Up @@ -82,8 +86,8 @@ resource "aws_iam_role_policy_attachment" "ssm" {
}

resource "aws_iam_role_policy_attachment" "custom" {
for_each = local.enabled && length(var.custom_iam_policy_arns) > 0 ? var.custom_iam_policy_arns : toset([])
for_each = local.enabled ? local.custom_iam_policy_arns_map : {}

role = aws_iam_role.this[0].name
policy_arn = each.key
policy_arn = each.value
}