Skip to content

Commit 7baf566

Browse files
committed
feat: Last minute variable name changes for improved ergonomics
1 parent 5e60ce7 commit 7baf566

File tree

24 files changed

+206
-139
lines changed

24 files changed

+206
-139
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module "iam_group" {
4545
]
4646
4747
enable_self_management_permissions = true
48-
permission_statements = {
48+
permissions = {
4949
AssumeRole = {
5050
actions = ["sts:AssumeRole"]
5151
resources = ["arn:aws:iam::111111111111:role/admin"]
@@ -67,7 +67,8 @@ module "iam_group" {
6767

6868
Creates an OpenID connect provider. Useful for trusting external identity providers such as GitHub, Bitbucket, etc.
6969

70-
⚠️ An IAM provider is 1 per account per given URL. This module would be provisioned once per AWS account, and then one or more roles can be created with this provider as the trusted identity.
70+
> [!TIP]
71+
> An IAM provider is 1 per account per given URL. This module would be provisioned once per AWS account, and then one or more roles can be created with this provider as the trusted identity.
7172
7273
```hcl
7374
module "iam_oidc_provider" {
@@ -113,15 +114,15 @@ module "iam_role" {
113114
114115
name = "example"
115116
116-
assume_role_policy_statements = {
117+
trust_policy_permissions = {
117118
TrustRoleAndServiceToAssume = {
118119
principals = [{
119120
type = "AWS"
120121
identifiers = [
121122
"arn:aws:iam::835367859851:user/anton",
122123
]
123124
}]
124-
conditions = [{
125+
condition = [{
125126
test = "StringEquals"
126127
variable = "sts:ExternalId"
127128
values = ["some-secret-id"]
@@ -153,7 +154,7 @@ module "iam_role_github_oidc" {
153154
enable_github_oidc = true
154155
155156
# This should be updated to suit your organization, repository, references/branches, etc.
156-
oidc_subjects = ["terraform-aws-modules/terraform-aws-iam:*"]
157+
oidc_wildcard_subjects = ["terraform-aws-modules/terraform-aws-iam:*"]
157158
158159
policies = {
159160
S3ReadOnly = "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"
@@ -200,7 +201,7 @@ Creates an IAM role that is suitable for EKS IAM role for service accounts (IRSA
200201

201202
```hcl
202203
module "vpc_cni_irsa" {
203-
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts"
204+
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts"
204205
205206
name = "vpc-cni"
206207

docs/UPGRADE-6.0.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ stateDiagram
8585
- `iam-oidc-provider`
8686
- `additional_thumbprints` - no longer required by GitHub
8787
- `iam-read-only-policy`
88-
- None
88+
- `additional_policy_json` - use `source_inline_policy_documents` or `override_inline_policy_documents` instead
8989
- `iam-role`
9090
- `trusted_role_actions`
9191
- `trusted_role_arns`
@@ -150,6 +150,7 @@ stateDiagram
150150
- `role_description` -> `description`
151151
- `role_policy_arns` -> `policies`
152152
- `ebs_csi_kms_cmk_ids` -> `ebs_csi_kms_cmk_arns`
153+
- `assume_role_condition_test` -> `trust_condition_test`
153154
- `iam-user`
154155
- `create_user` -> `create`
155156
- `create_iam_user_login_profile` -> `create_login_profile`
@@ -163,23 +164,34 @@ stateDiagram
163164
- `iam-account`
164165
- `create`
165166
- `iam-group`
166-
- `permission_statements` which allows for any number of custom statements to be added to the role's trust policy. This covers the majority of the variables that were removed
167+
- `permissions` which allows for any number of custom statements to be added to the role's trust policy. This covers the majority of the variables that were removed
167168
- `path`/`policy_path`
168169
- `create_policy`
169170
- `enable_mfa_enforcment`
170171
- `iam-oidc-provider`
171172
- None
172173
- `iam-read-only-policy`
173174
- `create`
175+
- `source_policy_documents`
176+
- `override_policy_documents`
174177
- `iam-role`
175-
- `assume_role_policy_statements` which allows for any number of custom statements to be added to the role's trust policy. This covers the majority of the variables that were removed
178+
- `trust_policy_permissions` which allows for any number of custom statements to be added to the role's trust policy. This covers the majority of the variables that were removed
179+
- `trust_policy_conditions`
180+
- `create_inline_policy`
181+
- `source_inline_policy_documents`
182+
- `override_inline_policy_documents`
183+
- `inline_policy_permissions`
176184
- `iam-role-for-service-accounts`
177185
- `create_policy`
178186
- `source_policy_documents`
179187
- `override_policy_documents`
180-
- `policy_statements`
188+
- `permissions`
181189
- `policy_name`
182190
- `policy_description`
191+
- `create_inline_policy`
192+
- `source_inline_policy_documents`
193+
- `override_inline_policy_documents`
194+
- `inline_policy_permissions`
183195
- `iam-user`
184196
- None
185197

@@ -289,7 +301,7 @@ module "iam_role" {
289301
- "codedeploy.amazonaws.com"
290302
- ]
291303
- role_sts_externalid = ["some-id-goes-here"]
292-
+ assume_role_policy_statements = {
304+
+ trust_policy_permissions = {
293305
+ TrustRoleAndServiceToAssume = {
294306
+ actions = [
295307
+ "sts:AssumeRole",
@@ -367,7 +379,7 @@ module "iam_role" {
367379
+ }
368380

369381
- provider_trust_policy_conditions = [
370-
+ condition = [
382+
+ trust_policy_conditions = [
371383
{
372384
test = "StringLike"
373385
variable = "aws:RequestTag/Environment"
@@ -467,7 +479,7 @@ module "iam_role_admin" {
467479
468480
name = "admin"
469481
470-
assume_role_policy_statements = {
482+
trust_policy_permissions = {
471483
TrustRoleAndServiceToAssume = {
472484
actions = [
473485
"sts:AssumeRole",
@@ -500,7 +512,7 @@ module "iam_role_poweruser" {
500512
501513
name = "Billing-And-Support-Access"
502514
503-
assume_role_policy_statements = {
515+
trust_policy_permissions = {
504516
TrustRoleAndServiceToAssume = {
505517
actions = [
506518
"sts:AssumeRole",
@@ -668,7 +680,7 @@ module "iam_role" {
668680
]
669681

670682
- additional_trust_policy_conditions = [
671-
+ condition = [
683+
+ trust_policy_conditions = [
672684
{
673685
test = "StringEquals"
674686
variable = "token.actions.githubusercontent.com:actor"
@@ -697,7 +709,7 @@ module "iam_group" {
697709
enable_self_management_permissions = false
698710

699711
- assumable_roles = ["arn:aws:iam::111111111111:role/admin"]
700-
+ permission_statements = {
712+
+ permissions = {
701713
+ AssumeRole = {
702714
+ effect = "Allow"
703715
+ actions = ["sts:AssumeRole"]

examples/iam-group/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module "iam_group" {
2626
module.iam_user2.name,
2727
]
2828

29-
permission_statements = {
29+
permissions = {
3030
AssumeRole = {
3131
actions = ["sts:AssumeRole"]
3232
resources = ["arn:aws:iam::111111111111:role/admin"]

examples/iam-role/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module "iam_roles" {
4444

4545
name = each.key
4646

47-
assume_role_policy_statements = {
47+
trust_policy_permissions = {
4848
TrustRoleAndServiceToAssume = {
4949
principals = [{
5050
type = "AWS"
@@ -88,7 +88,7 @@ module "iam_role_instance_profile" {
8888

8989
create_instance_profile = true
9090

91-
assume_role_policy_statements = {
91+
trust_policy_permissions = {
9292
TrustRoleAndServiceToAssume = {
9393
principals = [
9494
{

modules/iam-account/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Creates an account policy and account alias. Module instantiation is once per ac
66

77
```hcl
88
module "iam_account" {
9-
source = "terraform-aws-modules/iam/aws//modules/iam-account"
9+
source = "terraform-aws-modules/iam/aws//modules/iam-account"
1010
1111
account_alias = "awesome-company"
1212

modules/iam-group/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "iam_group" {
1717
]
1818
1919
enable_self_management_permissions = true
20-
permission_statements = {
20+
permissions = {
2121
AssumeRole = {
2222
actions = ["sts:AssumeRole"]
2323
resources = ["arn:aws:iam::111111111111:role/admin"]
@@ -76,7 +76,7 @@ No modules.
7676
| <a name="input_enable_self_management_permissions"></a> [enable\_self\_management\_permissions](#input\_enable\_self\_management\_permissions) | Determines whether permissions are added to the policy which allow the groups IAM users to manage their credentials and MFA | `bool` | `true` | no |
7777
| <a name="input_name"></a> [name](#input\_name) | The group's name. The name must consist of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: `=,.@-_.` | `string` | `""` | no |
7878
| <a name="input_path"></a> [path](#input\_path) | Path in which to create the group | `string` | `null` | no |
79-
| <a name="input_permission_statements"></a> [permission\_statements](#input\_permission\_statements) | A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage | <pre>map(object({<br/> sid = optional(string)<br/> actions = optional(list(string))<br/> not_actions = optional(list(string))<br/> effect = optional(string, "Allow")<br/> resources = optional(list(string))<br/> not_resources = optional(list(string))<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> not_principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> condition = optional(list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> })))<br/> }))</pre> | `null` | no |
79+
| <a name="input_permissions"></a> [permissions](#input\_permissions) | A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permissions | <pre>map(object({<br/> sid = optional(string)<br/> actions = optional(list(string))<br/> not_actions = optional(list(string))<br/> effect = optional(string, "Allow")<br/> resources = optional(list(string))<br/> not_resources = optional(list(string))<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> not_principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> condition = optional(list(object({<br/> test = string<br/> variable = string<br/> values = list(string)<br/> })))<br/> }))</pre> | `null` | no |
8080
| <a name="input_policies"></a> [policies](#input\_policies) | Policies to attach to the IAM role in `{'static_name' = 'policy_arn'}` format | `map(string)` | `{}` | no |
8181
| <a name="input_policy_description"></a> [policy\_description](#input\_policy\_description) | Description of the IAM policy | `string` | `null` | no |
8282
| <a name="input_policy_name"></a> [policy\_name](#input\_policy\_name) | Name to use on IAM policy created | `string` | `null` | no |

modules/iam-group/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ resource "aws_iam_group_membership" "this" {
3939
################################################################################
4040

4141
locals {
42-
create_policy = var.create && var.create_policy && (var.enable_self_management_permissions || var.permission_statements != null)
42+
create_policy = var.create && var.create_policy && (var.enable_self_management_permissions || var.permissions != null)
4343

4444
policy_name = try(coalesce(var.policy_name, var.name), "")
4545
}
@@ -198,7 +198,7 @@ data "aws_iam_policy_document" "this" {
198198
}
199199

200200
dynamic "statement" {
201-
for_each = var.permission_statements != null ? var.permission_statements : {}
201+
for_each = var.permissions != null ? var.permissions : {}
202202

203203
content {
204204
sid = try(coalesce(statement.value.sid, statement.key))

modules/iam-group/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ variable "enable_mfa_enforcment" {
5454
default = true
5555
}
5656

57-
variable "permission_statements" {
58-
description = "A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage"
57+
variable "permissions" {
58+
description = "A map of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permissions"
5959
type = map(object({
6060
sid = optional(string)
6161
actions = optional(list(string))

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,17 @@ No modules.
5252

5353
| Name | Description | Type | Default | Required |
5454
|------|-------------|------|---------|:--------:|
55-
| <a name="input_additional_policy_json"></a> [additional\_policy\_json](#input\_additional\_policy\_json) | JSON policy document if you want to add custom actions | `string` | `""` | no |
5655
| <a name="input_allow_cloudwatch_logs_query"></a> [allow\_cloudwatch\_logs\_query](#input\_allow\_cloudwatch\_logs\_query) | Allows StartQuery/StopQuery/FilterLogEvents CloudWatch actions | `bool` | `true` | no |
5756
| <a name="input_allow_predefined_sts_actions"></a> [allow\_predefined\_sts\_actions](#input\_allow\_predefined\_sts\_actions) | Allows GetCallerIdentity/GetSessionToken/GetAccessKeyInfo sts actions | `bool` | `true` | no |
5857
| <a name="input_allow_web_console_services"></a> [allow\_web\_console\_services](#input\_allow\_web\_console\_services) | Allows List/Get/Describe/View actions for services used when browsing AWS console (e.g. resource-groups, tag, health services) | `bool` | `true` | no |
5958
| <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)` | `[]` | no |
6059
| <a name="input_create"></a> [create](#input\_create) | Controls if resources should be created (affects all resources) | `bool` | `true` | no |
6160
| <a name="input_create_policy"></a> [create\_policy](#input\_create\_policy) | Controls if IAM policy should be created. Set to `false` to generate the policy JSON without creating the policy itself | `bool` | `true` | no |
62-
| <a name="input_description"></a> [description](#input\_description) | The description of the policy | `string` | `"IAM Policy"` | no |
61+
| <a name="input_description"></a> [description](#input\_description) | The description of the policy | `string` | `null` | no |
6362
| <a name="input_name"></a> [name](#input\_name) | Name to use on IAM policy created | `string` | `null` | no |
64-
| <a name="input_path"></a> [path](#input\_path) | Path of IAM policy | `string` | `"/"` | no |
63+
| <a name="input_override_inline_policy_documents"></a> [override\_inline\_policy\_documents](#input\_override\_inline\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |
64+
| <a name="input_path"></a> [path](#input\_path) | Path of IAM policy | `string` | `null` | no |
65+
| <a name="input_source_inline_policy_documents"></a> [source\_inline\_policy\_documents](#input\_source\_inline\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |
6566
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
6667
| <a name="input_use_name_prefix"></a> [use\_name\_prefix](#input\_use\_name\_prefix) | Determines whether the IAM policy name (`name`) is used as a prefix | `bool` | `true` | no |
6768
| <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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ resource "aws_iam_policy" "policy" {
1717
data "aws_iam_policy_document" "this" {
1818
count = var.create ? 1 : 0
1919

20-
source_policy_documents = [var.additional_policy_json]
20+
source_policy_documents = var.source_inline_policy_documents
21+
override_policy_documents = var.override_inline_policy_documents
2122

2223
dynamic "statement" {
2324
for_each = toset(distinct(var.allowed_services))

0 commit comments

Comments
 (0)