From c29d7d6abf8455d224d82dce2d5eaa914b776d5f Mon Sep 17 00:00:00 2001 From: 1david5 Date: Wed, 19 Jan 2022 19:38:15 -0500 Subject: [PATCH] allow to set role and policy path (#40) Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> --- README.md | 1 + docs/terraform.md | 1 + main.tf | 2 ++ variables.tf | 6 ++++++ 4 files changed, 10 insertions(+) diff --git a/README.md b/README.md index c60b807..71b076b 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ For automated tests of the complete example using [bats](https://github.com/bats | [max\_session\_duration](#input\_max\_session\_duration) | The maximum session duration (in seconds) for the role. Can have a value from 1 hour to 12 hours | `number` | `3600` | no | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | +| [path](#input\_path) | Path to the role and policy. See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html) for more information. | `string` | `"/"` | no | | [permissions\_boundary](#input\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the role | `string` | `""` | no | | [policy\_description](#input\_policy\_description) | The description of the IAM policy that is visible in the IAM policy manager | `string` | `""` | no | | [policy\_document\_count](#input\_policy\_document\_count) | Number of policy documents (length of policy\_documents list) | `number` | `1` | no | diff --git a/docs/terraform.md b/docs/terraform.md index 8c626b9..847e1df 100644 --- a/docs/terraform.md +++ b/docs/terraform.md @@ -54,6 +54,7 @@ | [max\_session\_duration](#input\_max\_session\_duration) | The maximum session duration (in seconds) for the role. Can have a value from 1 hour to 12 hours | `number` | `3600` | no | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no | +| [path](#input\_path) | Path to the role and policy. See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html) for more information. | `string` | `"/"` | no | | [permissions\_boundary](#input\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the role | `string` | `""` | no | | [policy\_description](#input\_policy\_description) | The description of the IAM policy that is visible in the IAM policy manager | `string` | `""` | no | | [policy\_document\_count](#input\_policy\_document\_count) | Number of policy documents (length of policy\_documents list) | `number` | `1` | no | diff --git a/main.tf b/main.tf index ff8f679..dcaecf3 100644 --- a/main.tf +++ b/main.tf @@ -33,6 +33,7 @@ resource "aws_iam_role" "default" { description = var.role_description max_session_duration = var.max_session_duration permissions_boundary = var.permissions_boundary + path = var.path tags = module.this.tags } @@ -46,6 +47,7 @@ resource "aws_iam_policy" "default" { name = module.this.id description = var.policy_description policy = join("", data.aws_iam_policy_document.default.*.json) + path = var.path tags = module.this.tags } diff --git a/variables.tf b/variables.tf index 0a31d92..283a188 100644 --- a/variables.tf +++ b/variables.tf @@ -76,3 +76,9 @@ variable "instance_profile_enabled" { default = false description = "Create EC2 Instance Profile for the role" } + +variable "path" { + type = string + description = "Path to the role and policy. See [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html) for more information." + default = "/" +} \ No newline at end of file