Skip to content

Commit ef9bec0

Browse files
authored
fix: Fixed service_integration type conversion with tomap (#16)
1 parent d02b6b0 commit ef9bec0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ resource "aws_iam_role" "this" {
7373
##############################
7474

7575
data "aws_iam_policy_document" "service" {
76-
for_each = local.create_role && var.attach_policies_for_integrations ? var.service_integrations : tomap({})
76+
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
7777

7878
dynamic "statement" {
7979
for_each = each.value
@@ -97,14 +97,14 @@ data "aws_iam_policy_document" "service" {
9797
}
9898

9999
resource "aws_iam_policy" "service" {
100-
for_each = local.create_role && var.attach_policies_for_integrations ? var.service_integrations : tomap({})
100+
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
101101

102102
name = "${local.role_name}-${each.key}"
103103
policy = data.aws_iam_policy_document.service[each.key].json
104104
}
105105

106106
resource "aws_iam_policy_attachment" "service" {
107-
for_each = local.create_role && var.attach_policies_for_integrations ? var.service_integrations : tomap({})
107+
for_each = local.create_role && var.attach_policies_for_integrations ? try(tomap(var.service_integrations), var.service_integrations) : tomap({})
108108

109109
name = "${local.role_name}-${each.key}"
110110
roles = [aws_iam_role.this[0].name]

0 commit comments

Comments
 (0)