Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow configuring max_session_duration for the ECS Task Execution role #186

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module "service" {
task_exec_iam_role_permissions_boundary = try(each.value.task_exec_iam_role_permissions_boundary, null)
task_exec_iam_role_tags = try(each.value.task_exec_iam_role_tags, {})
task_exec_iam_role_policies = try(each.value.task_exec_iam_role_policies, {})
task_exec_iam_role_max_session_duration = try(each.value.task_exec_iam_role_max_session_duration, null)

# Task execution IAM role policy
create_task_exec_policy = try(each.value.create_task_exec_policy, true)
Expand Down
1 change: 1 addition & 0 deletions modules/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ module "ecs_service" {
| <a name="input_task_definition_placement_constraints"></a> [task\_definition\_placement\_constraints](#input\_task\_definition\_placement\_constraints) | Configuration block for rules that are taken into consideration during task placement (up to max of 10). This is set at the task definition, see `placement_constraints` for setting at the service | `any` | `{}` | no |
| <a name="input_task_exec_iam_role_arn"></a> [task\_exec\_iam\_role\_arn](#input\_task\_exec\_iam\_role\_arn) | Existing IAM role ARN | `string` | `null` | no |
| <a name="input_task_exec_iam_role_description"></a> [task\_exec\_iam\_role\_description](#input\_task\_exec\_iam\_role\_description) | Description of the role | `string` | `null` | no |
| <a name="input_task_exec_iam_role_max_session_duration"></a> [task\_exec\_iam\_role\_max\_session\_duration](#input\_task\_exec\_iam\_role\_max\_session\_duration) | Maximum session duration (in seconds) for ECS task execution role. Default is 3600. | `number` | `null` | no |
| <a name="input_task_exec_iam_role_name"></a> [task\_exec\_iam\_role\_name](#input\_task\_exec\_iam\_role\_name) | Name to use on IAM role created | `string` | `null` | no |
| <a name="input_task_exec_iam_role_path"></a> [task\_exec\_iam\_role\_path](#input\_task\_exec\_iam\_role\_path) | IAM role path | `string` | `null` | no |
| <a name="input_task_exec_iam_role_permissions_boundary"></a> [task\_exec\_iam\_role\_permissions\_boundary](#input\_task\_exec\_iam\_role\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the IAM role | `string` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ resource "aws_iam_role" "task_exec" {
description = coalesce(var.task_exec_iam_role_description, "Task execution role for ${local.task_exec_iam_role_name}")

assume_role_policy = data.aws_iam_policy_document.task_exec_assume[0].json
max_session_duration = var.task_exec_iam_role_max_session_duration
permissions_boundary = var.task_exec_iam_role_permissions_boundary
force_detach_policies = true

Expand Down
6 changes: 6 additions & 0 deletions modules/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ variable "task_exec_iam_role_policies" {
default = {}
}

variable "task_exec_iam_role_max_session_duration" {
description = "Maximum session duration (in seconds) for ECS task execution role. Default is 3600."
type = number
default = null
}

variable "create_task_exec_policy" {
description = "Determines whether the ECS task definition IAM policy should be created. This includes permissions included in AmazonECSTaskExecutionRolePolicy as well as access to secrets and SSM parameters"
type = bool
Expand Down
1 change: 1 addition & 0 deletions wrappers/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ module "wrapper" {
task_definition_placement_constraints = try(each.value.task_definition_placement_constraints, var.defaults.task_definition_placement_constraints, {})
task_exec_iam_role_arn = try(each.value.task_exec_iam_role_arn, var.defaults.task_exec_iam_role_arn, null)
task_exec_iam_role_description = try(each.value.task_exec_iam_role_description, var.defaults.task_exec_iam_role_description, null)
task_exec_iam_role_max_session_duration = try(each.value.task_exec_iam_role_max_session_duration, var.defaults.task_exec_iam_role_max_session_duration, null)
task_exec_iam_role_name = try(each.value.task_exec_iam_role_name, var.defaults.task_exec_iam_role_name, null)
task_exec_iam_role_path = try(each.value.task_exec_iam_role_path, var.defaults.task_exec_iam_role_path, null)
task_exec_iam_role_permissions_boundary = try(each.value.task_exec_iam_role_permissions_boundary, var.defaults.task_exec_iam_role_permissions_boundary, null)
Expand Down