Skip to content

Commit 5bf5f6f

Browse files
authored
feat: Add name_prefix to iam-policy and iam-read-only-policy modules (#369)
Co-authored-by: magreenbaum <magreenbaum>
1 parent 263426f commit 5bf5f6f

File tree

7 files changed

+21
-5
lines changed

7 files changed

+21
-5
lines changed

examples/iam-policy/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ data "aws_iam_policy_document" "bucket_policy" {
1616
module "iam_policy" {
1717
source = "../../modules/iam-policy"
1818

19-
name = "example"
19+
name_prefix = "example-"
2020
path = "/"
2121
description = "My example policy"
2222

modules/iam-policy/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ No modules.
3232
|------|-------------|------|---------|:--------:|
3333
| <a name="input_create_policy"></a> [create\_policy](#input\_create\_policy) | Whether to create the IAM policy | `bool` | `true` | no |
3434
| <a name="input_description"></a> [description](#input\_description) | The description of the policy | `string` | `"IAM Policy"` | no |
35-
| <a name="input_name"></a> [name](#input\_name) | The name of the policy | `string` | `""` | no |
35+
| <a name="input_name"></a> [name](#input\_name) | The name of the policy | `string` | `null` | no |
36+
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | IAM policy name prefix | `string` | `null` | no |
3637
| <a name="input_path"></a> [path](#input\_path) | The path of the policy in IAM | `string` | `"/"` | no |
3738
| <a name="input_policy"></a> [policy](#input\_policy) | The path of the policy in IAM (tpl file) | `string` | `""` | no |
3839
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |

modules/iam-policy/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ resource "aws_iam_policy" "policy" {
22
count = var.create_policy ? 1 : 0
33

44
name = var.name
5+
name_prefix = var.name_prefix
56
path = var.path
67
description = var.description
78

modules/iam-policy/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ variable "create_policy" {
77
variable "name" {
88
description = "The name of the policy"
99
type = string
10-
default = ""
10+
default = null
11+
}
12+
13+
variable "name_prefix" {
14+
description = "IAM policy name prefix"
15+
type = string
16+
default = null
1117
}
1218

1319
variable "path" {

modules/iam-read-only-policy/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ No modules.
4343
| <a name="input_allowed_services"></a> [allowed\_services](#input\_allowed\_services) | List of services to allow Get/List/Describe/View options. Service name should be the same as corresponding service IAM prefix. See what it is for each service here https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html | `list(string)` | n/a | yes |
4444
| <a name="input_create_policy"></a> [create\_policy](#input\_create\_policy) | Whether to create the IAM policy | `bool` | `true` | no |
4545
| <a name="input_description"></a> [description](#input\_description) | The description of the policy | `string` | `"IAM Policy"` | no |
46-
| <a name="input_name"></a> [name](#input\_name) | The name of the policy | `string` | `""` | no |
46+
| <a name="input_name"></a> [name](#input\_name) | The name of the policy | `string` | `null` | no |
47+
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | IAM policy name prefix | `string` | `null` | no |
4748
| <a name="input_path"></a> [path](#input\_path) | The path of the policy in IAM | `string` | `"/"` | no |
4849
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. | `map(string)` | `{}` | no |
4950
| <a name="input_web_console_services"></a> [web\_console\_services](#input\_web\_console\_services) | List of web console services to allow | `list(string)` | <pre>[<br> "resource-groups",<br> "tag",<br> "health",<br> "ce"<br>]</pre> | no |

modules/iam-read-only-policy/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ resource "aws_iam_policy" "policy" {
22
count = var.create_policy ? 1 : 0
33

44
name = var.name
5+
name_prefix = var.name_prefix
56
path = var.path
67
description = var.description
78

modules/iam-read-only-policy/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ variable "create_policy" {
77
variable "name" {
88
description = "The name of the policy"
99
type = string
10-
default = ""
10+
default = null
11+
}
12+
13+
variable "name_prefix" {
14+
description = "IAM policy name prefix"
15+
type = string
16+
default = null
1117
}
1218

1319
variable "path" {

0 commit comments

Comments
 (0)