Skip to content

Commit

Permalink
feat: Add max session duration for IAM role (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrig authored Apr 14, 2023
1 parent 95e6a57 commit 3a21ac5
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ No modules.
| <a name="input_reserved_concurrent_executions"></a> [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The amount of reserved concurrent executions for this Lambda Function. A value of 0 disables Lambda Function from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. | `number` | `-1` | no |
| <a name="input_role_description"></a> [role\_description](#input\_role\_description) | Description of IAM role to use for Lambda Function | `string` | `null` | no |
| <a name="input_role_force_detach_policies"></a> [role\_force\_detach\_policies](#input\_role\_force\_detach\_policies) | Specifies to force detaching any policies the IAM role has before destroying it. | `bool` | `true` | no |
| <a name="input_role_maximum_session_duration"></a> [role\_maximum\_session\_duration](#input\_role\_maximum\_session\_duration) | Maximum session duration, in seconds, for the IAM role | `number` | `3600` | no |
| <a name="input_role_name"></a> [role\_name](#input\_role\_name) | Name of IAM role to use for Lambda Function | `string` | `null` | no |
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | Path of IAM role to use for Lambda Function | `string` | `null` | no |
| <a name="input_role_permissions_boundary"></a> [role\_permissions\_boundary](#input\_role\_permissions\_boundary) | The ARN of the policy that is used to set the permissions boundary for the IAM role used by Lambda Function | `string` | `null` | no |
Expand Down
2 changes: 2 additions & 0 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module "lambda_function" {
handler = "index.lambda_handler"
runtime = "python3.8"

# role_maximum_session_duration = 7200

# attach_cloudwatch_logs_policy = false

# use_existing_cloudwatch_log_group = true
Expand Down
2 changes: 1 addition & 1 deletion examples/with-efs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version |
|------|--------|---------|
| <a name="module_lambda_function_with_efs"></a> [lambda\_function\_with\_efs](#module\_lambda\_function\_with\_efs) | ../../ | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources

Expand Down
3 changes: 2 additions & 1 deletion examples/with-efs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module "lambda_function_with_efs" {
######

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"

name = random_pet.this.id
cidr = "10.10.0.0/16"
Expand Down
2 changes: 1 addition & 1 deletion examples/with-vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version |
|------|--------|---------|
| <a name="module_lambda_function_in_vpc"></a> [lambda\_function\_in\_vpc](#module\_lambda\_function\_in\_vpc) | ../../ | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |

## Resources

Expand Down
3 changes: 2 additions & 1 deletion examples/with-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module "lambda_function_in_vpc" {
}

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
source = "terraform-aws-modules/vpc/aws"
version = "~> 3.0"

name = random_pet.this.id
cidr = "10.10.0.0/16"
Expand Down
1 change: 1 addition & 0 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ resource "aws_iam_role" "lambda" {
force_detach_policies = var.role_force_detach_policies
permissions_boundary = var.role_permissions_boundary
assume_role_policy = data.aws_iam_policy_document.assume_role[0].json
max_session_duration = var.role_maximum_session_duration

tags = merge(var.tags, var.role_tags)
}
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ variable "role_tags" {
default = {}
}

variable "role_maximum_session_duration" {
description = "Maximum session duration, in seconds, for the IAM role"
type = number
default = 3600
}

###########
# Policies
###########
Expand Down

0 comments on commit 3a21ac5

Please sign in to comment.