Skip to content

Commit

Permalink
feat: Add optional policy_path variable used for policy definitions (#60
Browse files Browse the repository at this point in the history
)

Co-authored-by: Anton Babenko <anton@antonbabenko.com>
  • Loading branch information
rgrund-inform and antonbabenko committed Dec 4, 2023
1 parent ef27130 commit cddcf93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ No modules.
| <a name="input_policy"></a> [policy](#input\_policy) | An additional policy document ARN to attach to IAM role | `string` | `null` | no |
| <a name="input_policy_json"></a> [policy\_json](#input\_policy\_json) | An additional policy document as JSON to attach to IAM role | `string` | `null` | no |
| <a name="input_policy_jsons"></a> [policy\_jsons](#input\_policy\_jsons) | List of additional policy documents as JSON to attach to IAM role | `list(string)` | `[]` | no |
| <a name="input_policy_path"></a> [policy\_path](#input\_policy\_path) | Path of IAM policies to use for Step Function | `string` | `null` | no |
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | Map of dynamic policy statements to attach to IAM role | `any` | `{}` | no |
| <a name="input_publish"></a> [publish](#input\_publish) | Determines whether to set a version of the state machine when it is created. | `bool` | `false` | no |
| <a name="input_role_arn"></a> [role\_arn](#input\_role\_arn) | The Amazon Resource Name (ARN) of the IAM role to use for this Step Function | `string` | `""` | no |
Expand Down
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ resource "aws_iam_policy" "service" {
for_each = { for k, v in var.service_integrations : k => v if local.create_role && var.attach_policies_for_integrations }

name = "${local.role_name}-${each.key}"
path = var.policy_path
policy = data.aws_iam_policy_document.service[each.key].json
tags = var.tags
}
Expand All @@ -137,6 +138,7 @@ resource "aws_iam_policy" "additional_json" {
count = local.create_role && var.attach_policy_json ? 1 : 0

name = local.role_name
path = var.policy_path
policy = var.policy_json
tags = var.tags
}
Expand All @@ -157,6 +159,7 @@ resource "aws_iam_policy" "additional_jsons" {
count = local.create_role && var.attach_policy_jsons ? var.number_of_policy_jsons : 0

name = "${local.role_name}-${count.index}"
path = var.policy_path
policy = var.policy_jsons[count.index]
tags = var.tags
}
Expand Down Expand Up @@ -241,6 +244,7 @@ resource "aws_iam_policy" "additional_inline" {
count = local.create_role && var.attach_policy_statements ? 1 : 0

name = "${local.role_name}-inline"
path = var.policy_path
policy = data.aws_iam_policy_document.additional_inline[0].json
tags = var.tags
}
Expand Down Expand Up @@ -283,6 +287,7 @@ resource "aws_iam_policy" "logs" {
count = local.create_role && local.enable_logging && var.attach_cloudwatch_logs_policy ? 1 : 0

name = "${local.role_name}-logs"
path = var.policy_path
policy = data.aws_iam_policy_document.logs[0].json
tags = var.tags
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ variable "policy" {
default = null
}

variable "policy_path" {
description = "Path of IAM policies to use for Step Function"
type = string
default = null
}

variable "policies" {
description = "List of policy statements ARN to attach to IAM role"
type = list(string)
Expand Down

0 comments on commit cddcf93

Please sign in to comment.