You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: per-role max_session_duration override and inline policy support
Two additive fields on each var.roles entry:
- max_session_duration: per-role override of the module-level duration,
enforced to the same 3600-43200 band. Lets a single long-running CI
job bump its own session without leaking that duration to every role.
- inline_policies: map of policy name to rendered policy document JSON,
rendered as aws_iam_role_policy resources. Removes the need to create
a standalone aws_iam_policy for grants that will never be reused.
Both fields are optional and default to inherit-module-default / empty,
so existing configurations pass through unchanged and plans emit zero
diff on upgrade. Validation blocks reject out-of-band durations and
invalid IAM policy names at plan time.
README's "Full example" is extended with a role exercising both fields,
plus a key-by-key description of the roles object for quick reference.
Each entry in `roles` supports the following keys:
85
+
86
+
-`subject_repos` (required) — OIDC subject claims allowed to assume the role. See the cheat sheet below.
87
+
-`policy_arns` (required, may be empty) — IAM policy ARNs to attach.
88
+
-`inline_policies` (optional) — Map of policy name → rendered policy document JSON. Good for one-off grants that don't deserve a standalone `aws_iam_policy`.
89
+
-`max_session_duration` (optional) — Per-role override in seconds (3600–43200). Omit to inherit the module-level `var.max_session_duration`.
90
+
-`role_path` (optional) — IAM path. Defaults to `/`.
91
+
-`assume_role_names` (optional) — IAM role names in the same account that may also `sts:AssumeRole` this role. Development-only escape hatch; see [Security notes](#security-notes).
92
+
72
93
## Subject string cheat sheet
73
94
74
95
The `subject_repos` list contains GitHub OIDC `sub` claim patterns. Common shapes:
@@ -177,7 +198,7 @@ If you set `audience:` on `aws-actions/configure-aws-credentials`, set the match
177
198
| <a name="input_aud_value"></a> [aud\_value](#input\_aud\_value) | Audience claim required in the OIDC token. Defaults to the value the official aws-actions/configure-aws-credentials action sends. | `string` | `"sts.amazonaws.com"` | no |
178
199
| <a name="input_github_tls_url"></a> [github\_tls\_url](#input\_github\_tls\_url) | GitHub OIDC issuer URL. Override only for GitHub Enterprise Server. | `string` | `"https://token.actions.githubusercontent.com"` | no |
179
200
| <a name="input_max_session_duration"></a> [max\_session\_duration](#input\_max\_session\_duration) | Maximum session duration in seconds for every role created. Defaults to 1 hour. Increase up to 43200 (12h) if your workflows need longer sessions. | `number` | `3600` | no |
180
-
| <a name="input_roles"></a> [roles](#input\_roles) | Map of IAM roles to create. The map key is the role name. Each value defines:<br/> - `subject_repos` : OIDC subject claims allowed to assume this role (e.g. "repo:my-org/my-repo:ref:refs/heads/main").<br/> - `policy_arns` : IAM policy ARNs to attach to the role.<br/> - `role_path` : (optional) IAM path for the role. Defaults to "/".<br/> - `assume_role_names` : (optional) IAM role names in the same account that may also assume this role (useful for local debugging). | <pre>map(object({<br/> role_path = optional(string, "/")<br/> subject_repos = list(string)<br/> policy_arns = list(string)<br/> assume_role_names = optional(list(string))<br/> }))</pre> | n/a | yes |
201
+
| <a name="input_roles"></a> [roles](#input\_roles) | Map of IAM roles to create. The map key is the role name. Each value defines:<br/> - `subject_repos` : OIDC subject claims allowed to assume this role (e.g. "repo:my-org/my-repo:ref:refs/heads/main").<br/> - `policy_arns` : IAM policy ARNs to attach to the role.<br/> - `role_path` : (optional) IAM path for the role. Defaults to "/".<br/> - `assume_role_names` : (optional) IAM role names in the same account that may also assume this role (useful for local debugging).<br/> - `max_session_duration` : (optional) Per-role override of the module-level max\_session\_duration, in seconds. Must be 3600-43200. Omit to inherit var.max\_session\_duration.<br/> - `inline_policies` : (optional) Map of inline IAM policy name to rendered policy document JSON (typically from data.aws\_iam\_policy\_document.<name>.json). | <pre>map(object({<br/> role_path = optional(string, "/")<br/> subject_repos = list(string)<br/> policy_arns = list(string)<br/> assume_role_names = optional(list(string))<br/> max_session_duration = optional(number)<br/> inline_policies = optional(map(string), {})<br/> }))</pre> | n/a | yes |
181
202
| <a name="input_tags"></a> [tags](#input\_tags) | Tags applied to the OIDC provider and every IAM role created by this module. | `map(string)` | `{}` | no |
Copy file name to clipboardExpand all lines: modules/aws-roles-oidc-github/variables.tf
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,12 @@ variable "policy_arns" {
33
33
description="IAM policy ARNs to attach to the role (managed or customer-managed policies)."
34
34
}
35
35
36
+
variable"inline_policies" {
37
+
type=map(string)
38
+
default={}
39
+
description="Inline IAM policies to attach to the role. Map of policy name to rendered policy document JSON (typically from data.aws_iam_policy_document.<name>.json)."
Copy file name to clipboardExpand all lines: variables.tf
+29-8Lines changed: 29 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,20 @@
1
1
variable"roles" {
2
2
type=map(object({
3
-
role_path =optional(string, "/")
4
-
subject_repos =list(string)
5
-
policy_arns =list(string)
6
-
assume_role_names =optional(list(string))
3
+
role_path =optional(string, "/")
4
+
subject_repos =list(string)
5
+
policy_arns =list(string)
6
+
assume_role_names =optional(list(string))
7
+
max_session_duration =optional(number)
8
+
inline_policies =optional(map(string), {})
7
9
}))
8
10
description=<<-EOT
9
11
Map of IAM roles to create. The map key is the role name. Each value defines:
10
-
- `subject_repos` : OIDC subject claims allowed to assume this role (e.g. "repo:my-org/my-repo:ref:refs/heads/main").
11
-
- `policy_arns` : IAM policy ARNs to attach to the role.
12
-
- `role_path` : (optional) IAM path for the role. Defaults to "/".
13
-
- `assume_role_names` : (optional) IAM role names in the same account that may also assume this role (useful for local debugging).
12
+
- `subject_repos` : OIDC subject claims allowed to assume this role (e.g. "repo:my-org/my-repo:ref:refs/heads/main").
13
+
- `policy_arns` : IAM policy ARNs to attach to the role.
14
+
- `role_path` : (optional) IAM path for the role. Defaults to "/".
15
+
- `assume_role_names` : (optional) IAM role names in the same account that may also assume this role (useful for local debugging).
16
+
- `max_session_duration` : (optional) Per-role override of the module-level max_session_duration, in seconds. Must be 3600-43200. Omit to inherit var.max_session_duration.
17
+
- `inline_policies` : (optional) Map of inline IAM policy name to rendered policy document JSON (typically from data.aws_iam_policy_document.<name>.json).
14
18
EOT
15
19
16
20
validation {
@@ -42,6 +46,23 @@ variable "roles" {
42
46
])
43
47
error_message="Every policy_arns entry must be a valid IAM policy ARN (e.g. \"arn:aws:iam::aws:policy/ReadOnlyAccess\" or \"arn:aws:iam::123456789012:policy/my-policy\")."
0 commit comments