Skip to content

Commit a2a875d

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

File tree

24 files changed

+216
-142
lines changed

24 files changed

+216
-142
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: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ If you find a bug, please open an issue with supporting configuration to reprodu
66

77
## List of backwards incompatible changes
88

9+
- Terraform `v1.5.7` is now minimum supported version
10+
- AWS provider `v6.0.0` is now minimum supported version
911
- The ability to allow roles to assume their own roles has been removed. This was previously added as part of helping users mitigate https://aws.amazon.com/blogs/security/announcing-an-update-to-iam-role-trust-policy-behavior/. Going forward, users will need to mitigate this on the application side (i.e. - do not have a role assume itself), or update the trust policy in their implementation to continue using this behavior. It is strongly recommended to mitigate this by not having the role assume itself.
1012

1113
- `iam-account`:
@@ -21,7 +23,7 @@ If you find a bug, please open an issue with supporting configuration to reprodu
2123
- `iam-group-with-assumable-roles-policy` has been merged into `iam-group`
2224
- `iam-eks-role` has been removed; `iam-role-for-service-accounts` or [`eks-pod-identity`](https://github.com/terraform-aws-modules/terraform-aws-eks-pod-identity) should be used instead
2325
- `iam-policy` has been removed; the `aws_iam_policy` resource should be used directly instead
24-
- `iam-role-for-service-accounts`:
26+
- `iam-role-for-service-accounts-eks` has been renamed to `iam-role-for-service-accounts`
2527
- Individual policy creation and attachment has been consolidated under one policy creation and attachment
2628
- Default values that enable permissive permissions have been removed; users will need to be explicit about the scope of access (i.e. ARNs) they provide when enabling permissions
2729
- AppMesh policy support has been removed due to service reaching end of support
@@ -63,15 +65,20 @@ stateDiagram
6365

6466
### Modified
6567

68+
- Variable definitions now contain detailed `object` types in place of the previously used any type
69+
6670
- `iam-group`
6771
- Policy management has been updated to support extending the policy created by the sub-module, as well as adding additional policies that will be attached to the group
68-
- The role assumption permissions has been removed from the policy; users can extend the policy to add this if needed via `permission_statements`
72+
- The role assumption permissions has been removed from the policy; users can extend the policy to add this if needed via `permissions`
6973
- Default create conditional is now `true` instead of `false`
7074
- `iam-role`
71-
- The use of individual variables to control/manipulate the assume role trust policy have been replaced by a generic `assume_role_policy_statements` variable. This allows for any number of custom statements to be added to the role's trust policy.
75+
- The use of individual variables to control/manipulate the assume role trust policy have been replaced by a generic `trust_policy_permissions` variable. This allows for any number of custom statements to be added to the role's trust policy.
7276
- `custom_role_policy_arns` has been renamed to `policies` and now accepts a map of `name`: `policy-arn` pairs; this allows for both existing policies and policies that will get created at the same time as the role. This also replaces the admin, readonly, and poweruser policy ARN variables and their associated `attach_*_policy` variables.
7377
- Default create conditional is now `true` instead of `false`
7478
- `force_detach_policies` has been removed; this is now always `true`
79+
- Support for inline policies has been added
80+
- `iam-role-for-service-accounts`
81+
- Support for inline policies has been added
7582

7683
### Variable and output changes
7784

@@ -85,7 +92,7 @@ stateDiagram
8592
- `iam-oidc-provider`
8693
- `additional_thumbprints` - no longer required by GitHub
8794
- `iam-read-only-policy`
88-
- None
95+
- `additional_policy_json` - use `source_inline_policy_documents` or `override_inline_policy_documents` instead
8996
- `iam-role`
9097
- `trusted_role_actions`
9198
- `trusted_role_arns`
@@ -150,6 +157,7 @@ stateDiagram
150157
- `role_description` -> `description`
151158
- `role_policy_arns` -> `policies`
152159
- `ebs_csi_kms_cmk_ids` -> `ebs_csi_kms_cmk_arns`
160+
- `assume_role_condition_test` -> `trust_condition_test`
153161
- `iam-user`
154162
- `create_user` -> `create`
155163
- `create_iam_user_login_profile` -> `create_login_profile`
@@ -163,23 +171,34 @@ stateDiagram
163171
- `iam-account`
164172
- `create`
165173
- `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
174+
- `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
167175
- `path`/`policy_path`
168176
- `create_policy`
169177
- `enable_mfa_enforcment`
170178
- `iam-oidc-provider`
171179
- None
172180
- `iam-read-only-policy`
173181
- `create`
182+
- `source_policy_documents`
183+
- `override_policy_documents`
174184
- `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
185+
- `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
186+
- `trust_policy_conditions`
187+
- `create_inline_policy`
188+
- `source_inline_policy_documents`
189+
- `override_inline_policy_documents`
190+
- `inline_policy_permissions`
176191
- `iam-role-for-service-accounts`
177192
- `create_policy`
178193
- `source_policy_documents`
179194
- `override_policy_documents`
180-
- `policy_statements`
195+
- `permissions`
181196
- `policy_name`
182197
- `policy_description`
198+
- `create_inline_policy`
199+
- `source_inline_policy_documents`
200+
- `override_inline_policy_documents`
201+
- `inline_policy_permissions`
183202
- `iam-user`
184203
- None
185204

@@ -289,7 +308,7 @@ module "iam_role" {
289308
- "codedeploy.amazonaws.com"
290309
- ]
291310
- role_sts_externalid = ["some-id-goes-here"]
292-
+ assume_role_policy_statements = {
311+
+ trust_policy_permissions = {
293312
+ TrustRoleAndServiceToAssume = {
294313
+ actions = [
295314
+ "sts:AssumeRole",
@@ -367,7 +386,7 @@ module "iam_role" {
367386
+ }
368387

369388
- provider_trust_policy_conditions = [
370-
+ condition = [
389+
+ trust_policy_conditions = [
371390
{
372391
test = "StringLike"
373392
variable = "aws:RequestTag/Environment"
@@ -467,7 +486,7 @@ module "iam_role_admin" {
467486
468487
name = "admin"
469488
470-
assume_role_policy_statements = {
489+
trust_policy_permissions = {
471490
TrustRoleAndServiceToAssume = {
472491
actions = [
473492
"sts:AssumeRole",
@@ -500,7 +519,7 @@ module "iam_role_poweruser" {
500519
501520
name = "Billing-And-Support-Access"
502521
503-
assume_role_policy_statements = {
522+
trust_policy_permissions = {
504523
TrustRoleAndServiceToAssume = {
505524
actions = [
506525
"sts:AssumeRole",
@@ -668,7 +687,7 @@ module "iam_role" {
668687
]
669688

670689
- additional_trust_policy_conditions = [
671-
+ condition = [
690+
+ trust_policy_conditions = [
672691
{
673692
test = "StringEquals"
674693
variable = "token.actions.githubusercontent.com:actor"
@@ -697,7 +716,7 @@ module "iam_group" {
697716
enable_self_management_permissions = false
698717

699718
- assumable_roles = ["arn:aws:iam::111111111111:role/admin"]
700-
+ permission_statements = {
719+
+ permissions = {
701720
+ AssumeRole = {
702721
+ effect = "Allow"
703722
+ 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)