Skip to content

Commit fe0d030

Browse files
author
Eduardo Lopez
authored
[feature] Allow overwriting the IAM Role max session duration (#208)
### Summary Allows us to overwrite the iam role max_role session duration. ### Test Plan ### References
1 parent 1fe821e commit fe0d030

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

aws-iam-role-crossacct/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ No requirements.
3232
| Name | Description | Type | Default | Required |
3333
|------|-------------|------|---------|:--------:|
3434
| iam\_path | The IAM path to put this role in. | `string` | `"/"` | no |
35+
| max\_session\_duration | The maximum session duration (in seconds) for the role. | `number` | `3600` | no |
3536
| oidc | A list of AWS OIDC IDPs to establish a trust relationship for this role. | <pre>list(object(<br> {<br> idp_arn : string, # the AWS IAM IDP arn<br> client_ids : list(string), # a list of oidc client ids<br> provider : string # your provider url, such as foo.okta.com<br> }<br> ))</pre> | `[]` | no |
3637
| role\_name | The name of the role. | `string` | n/a | yes |
3738
| saml\_idp\_arn | The AWS SAML IDP arn to establish a trust relationship. Ignored if empty or not provided. | `string` | `""` | no |

aws-iam-role-crossacct/main.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ data "aws_iam_policy_document" "assume-role" {
6161
}
6262

6363
resource "aws_iam_role" "role" {
64-
name = var.role_name
65-
path = var.iam_path
66-
assume_role_policy = data.aws_iam_policy_document.assume-role.json
67-
tags = var.tags
64+
name = var.role_name
65+
path = var.iam_path
66+
assume_role_policy = data.aws_iam_policy_document.assume-role.json
67+
tags = var.tags
68+
max_session_duration = var.max_session_duration
6869

6970
# We have to force detach policies in order to recreate roles.
7071
# The other option would be to use name_prefix and create_before_destroy, but that

aws-iam-role-crossacct/variables.tf

+7
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ variable tags {
4444
default = {}
4545
description = "A map of tags to assign this IAM Role."
4646
}
47+
48+
49+
variable max_session_duration {
50+
type = number
51+
default = 60 * 60 // 1 hour
52+
description = "The maximum session duration (in seconds) for the role."
53+
}

aws-iam-role-poweruser/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ No requirements.
3333
|------|-------------|------|---------|:--------:|
3434
| authorize\_iam | Indicates if we should augment the PowerUserAccess policy with certain IAM actions. | `bool` | `true` | no |
3535
| iam\_path | n/a | `string` | `"/"` | no |
36+
| max\_session\_duration | The maximum session duration (in seconds) for the role. | `number` | `3600` | no |
3637
| oidc | A list of AWS OIDC IDPs to establish a trust relationship for this role. | <pre>list(object(<br> {<br> idp_arn : string, # the AWS IAM IDP arn<br> client_ids : list(string), # a list of oidc client ids<br> provider : string # your provider url, such as foo.okta.com<br> }<br> ))</pre> | `[]` | no |
3738
| role\_name | n/a | `string` | `"poweruser"` | no |
3839
| saml\_idp\_arn | The AWS SAML IDP arn to establish a trust relationship. Ignored if empty or not provided. | `string` | `""` | no |

aws-iam-role-poweruser/main.tf

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ data "aws_iam_policy_document" "assume-role" {
6161
}
6262

6363
resource "aws_iam_role" "poweruser" {
64-
name = var.role_name
65-
path = var.iam_path
66-
assume_role_policy = data.aws_iam_policy_document.assume-role.json
67-
tags = var.tags
64+
name = var.role_name
65+
path = var.iam_path
66+
assume_role_policy = data.aws_iam_policy_document.assume-role.json
67+
max_session_duration = var.max_session_duration
68+
tags = var.tags
6869
}
6970

7071
resource "aws_iam_role_policy_attachment" "poweruser" {

aws-iam-role-poweruser/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ variable authorize_iam {
4545
description = "Indicates if we should augment the PowerUserAccess policy with certain IAM actions."
4646
}
4747

48+
variable max_session_duration {
49+
type = number
50+
default = 60 * 60 // 1 hour
51+
description = "The maximum session duration (in seconds) for the role."
52+
}
53+
4854
variable tags {
4955
type = map(string)
5056
default = {}

aws-s3-private-bucket/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ No requirements.
4949
| bucket\_policy | n/a | `string` | `""` | no |
5050
| enable\_versioning | Keep old versions of overwritten S3 objects. | `bool` | `true` | no |
5151
| env | n/a | `string` | n/a | yes |
52-
| grants | List of objects with the canonical user id and permissions, used when defining the grant acl. | <pre>list(object(<br> {<br> canonical_user_id : string, <br> permissions : list(string), # a list of permissions granted to the AWS account with the canonical user <br> }<br> ))</pre> | `[]` | no |
52+
| grants | A list of canonical user ID to permissions pairs. Used when we want to grant permissions to AWS accounts via the S3 ACL system. | `list(object({ canonical_user_id : string, permissions : list(string) }))` | `[]` | no |
5353
| lifecycle\_rules | List of maps containing configuration of object lifecycle management. | `any` | <pre>[<br> {<br> "enabled": true,<br> "expiration": {<br> "expired_object_delete_marker": true<br> },<br> "noncurrent_version_expiration": {<br> "days": 365<br> },<br> "noncurrent_version_transition": {<br> "days": 30,<br> "storage_class": "STANDARD_IA"<br> }<br> }<br>]</pre> | no |
5454
| owner | n/a | `string` | n/a | yes |
5555
| project | n/a | `string` | n/a | yes |

0 commit comments

Comments
 (0)