Skip to content

Commit b0a5ec2

Browse files
authored
Adding support for permission boundary for IAM Role creation (#31)
1 parent 5dfc0cb commit b0a5ec2

File tree

3 files changed

+47
-21
lines changed

3 files changed

+47
-21
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ In order to run all checks at any point run the following command:
5656

5757
| Name | Version |
5858
|------|---------|
59-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.32.0 |
59+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.31.0 |
6060

6161
## Modules
6262

@@ -77,28 +77,29 @@ No modules.
7777

7878
| Name | Description | Type | Default | Required |
7979
|------|-------------|------|---------|:--------:|
80-
| <a name="input_ecs_cluster_arn"></a> [ecs\_cluster\_arn](#input\_ecs\_cluster\_arn) | The ECS Cluster where the scheduled task will run. | `any` | n/a | yes |
81-
| <a name="input_ecs_execution_task_role_arn"></a> [ecs\_execution\_task\_role\_arn](#input\_ecs\_execution\_task\_role\_arn) | (Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `any` | n/a | yes |
82-
| <a name="input_ecs_task_role_arn"></a> [ecs\_task\_role\_arn](#input\_ecs\_task\_role\_arn) | (Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `any` | `null` | no |
83-
| <a name="input_event_rule_description"></a> [event\_rule\_description](#input\_event\_rule\_description) | (Optional) The description of the rule. | `any` | `null` | no |
84-
| <a name="input_event_rule_event_bus_name"></a> [event\_rule\_event\_bus\_name](#input\_event\_rule\_event\_bus\_name) | (Optional) The event bus to associate with this rule. If you omit this, the default event bus is used. | `any` | `null` | no |
85-
| <a name="input_event_rule_event_pattern"></a> [event\_rule\_event\_pattern](#input\_event\_rule\_event\_pattern) | (Optional) The event pattern described a JSON object. At least one of schedule\_expression or event\_pattern is required. | `any` | `null` | no |
80+
| <a name="input_ecs_cluster_arn"></a> [ecs\_cluster\_arn](#input\_ecs\_cluster\_arn) | The ECS Cluster where the scheduled task will run. | `string` | n/a | yes |
81+
| <a name="input_ecs_execution_task_role_arn"></a> [ecs\_execution\_task\_role\_arn](#input\_ecs\_execution\_task\_role\_arn) | (Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `string` | n/a | yes |
82+
| <a name="input_ecs_task_role_arn"></a> [ecs\_task\_role\_arn](#input\_ecs\_task\_role\_arn) | (Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. | `string` | `null` | no |
83+
| <a name="input_event_rule_description"></a> [event\_rule\_description](#input\_event\_rule\_description) | (Optional) The description of the rule. | `string` | `null` | no |
84+
| <a name="input_event_rule_event_bus_name"></a> [event\_rule\_event\_bus\_name](#input\_event\_rule\_event\_bus\_name) | (Optional) The event bus to associate with this rule. If you omit this, the default event bus is used. | `string` | `null` | no |
85+
| <a name="input_event_rule_event_pattern"></a> [event\_rule\_event\_pattern](#input\_event\_rule\_event\_pattern) | (Optional) The event pattern described a JSON object. At least one of schedule\_expression or event\_pattern is required. | `string` | `null` | no |
8686
| <a name="input_event_rule_is_enabled"></a> [event\_rule\_is\_enabled](#input\_event\_rule\_is\_enabled) | (Optional) Whether the rule should be enabled (defaults to true). | `bool` | `true` | no |
87-
| <a name="input_event_rule_name"></a> [event\_rule\_name](#input\_event\_rule\_name) | The name of the rule. | `any` | n/a | yes |
88-
| <a name="input_event_rule_role_arn"></a> [event\_rule\_role\_arn](#input\_event\_rule\_role\_arn) | (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. | `any` | `null` | no |
89-
| <a name="input_event_rule_schedule_expression"></a> [event\_rule\_schedule\_expression](#input\_event\_rule\_schedule\_expression) | (Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event\_rule\_schedule\_expression or event\_rule\_event\_pattern is required. Can only be used on the default event bus. | `any` | `null` | no |
87+
| <a name="input_event_rule_name"></a> [event\_rule\_name](#input\_event\_rule\_name) | The name of the rule. | `string` | n/a | yes |
88+
| <a name="input_event_rule_role_arn"></a> [event\_rule\_role\_arn](#input\_event\_rule\_role\_arn) | (Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation. | `string` | `null` | no |
89+
| <a name="input_event_rule_schedule_expression"></a> [event\_rule\_schedule\_expression](#input\_event\_rule\_schedule\_expression) | (Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event\_rule\_schedule\_expression or event\_rule\_event\_pattern is required. Can only be used on the default event bus. | `string` | `null` | no |
9090
| <a name="input_event_target_ecs_target_assign_public_ip"></a> [event\_target\_ecs\_target\_assign\_public\_ip](#input\_event\_target\_ecs\_target\_assign\_public\_ip) | (Optional) Assign a public IP address to the ENI. Default false. | `bool` | `false` | no |
91-
| <a name="input_event_target_ecs_target_group"></a> [event\_target\_ecs\_target\_group](#input\_event\_target\_ecs\_target\_group) | (Optional) Specifies an ECS task group for the task. The maximum length is 255 characters. | `any` | `null` | no |
91+
| <a name="input_event_target_ecs_target_group"></a> [event\_target\_ecs\_target\_group](#input\_event\_target\_ecs\_target\_group) | (Optional) Specifies an ECS task group for the task. The maximum length is 255 characters. | `string` | `null` | no |
9292
| <a name="input_event_target_ecs_target_platform_version"></a> [event\_target\_ecs\_target\_platform\_version](#input\_event\_target\_ecs\_target\_platform\_version) | (Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST. | `string` | `"LATEST"` | no |
9393
| <a name="input_event_target_ecs_target_propagate_tags"></a> [event\_target\_ecs\_target\_propagate\_tags](#input\_event\_target\_ecs\_target\_propagate\_tags) | (Optional) Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Tags can only be propagated to the task during task creation. Valid values: `TASK_DEFINITION` or leave empty to avoid propagation. | `string` | `""` | no |
9494
| <a name="input_event_target_ecs_target_security_groups"></a> [event\_target\_ecs\_target\_security\_groups](#input\_event\_target\_ecs\_target\_security\_groups) | (Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used. | `list(any)` | `null` | no |
9595
| <a name="input_event_target_ecs_target_subnets"></a> [event\_target\_ecs\_target\_subnets](#input\_event\_target\_ecs\_target\_subnets) | The subnets associated with the task or service. | `list(any)` | n/a | yes |
9696
| <a name="input_event_target_ecs_target_task_count"></a> [event\_target\_ecs\_target\_task\_count](#input\_event\_target\_ecs\_target\_task\_count) | (Optional) The number of tasks to create based on the TaskDefinition. The default is 1. | `number` | `1` | no |
97-
| <a name="input_event_target_ecs_target_task_definition_arn"></a> [event\_target\_ecs\_target\_task\_definition\_arn](#input\_event\_target\_ecs\_target\_task\_definition\_arn) | (Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster. | `any` | n/a | yes |
98-
| <a name="input_event_target_input"></a> [event\_target\_input](#input\_event\_target\_input) | (Optional) Valid JSON text passed to the target. Conflicts with event\_target\_input\_path. | `any` | `null` | no |
99-
| <a name="input_event_target_input_path"></a> [event\_target\_input\_path](#input\_event\_target\_input\_path) | (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event\_target\_input. | `any` | `null` | no |
100-
| <a name="input_event_target_target_id"></a> [event\_target\_target\_id](#input\_event\_target\_target\_id) | (Optional) The unique target assignment ID. If missing, will generate a random, unique id. | `any` | `null` | no |
101-
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix for resources on AWS. | `any` | n/a | yes |
97+
| <a name="input_event_target_ecs_target_task_definition_arn"></a> [event\_target\_ecs\_target\_task\_definition\_arn](#input\_event\_target\_ecs\_target\_task\_definition\_arn) | (Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster. | `string` | n/a | yes |
98+
| <a name="input_event_target_input"></a> [event\_target\_input](#input\_event\_target\_input) | (Optional) Valid JSON text passed to the target. Conflicts with event\_target\_input\_path. | `string` | `null` | no |
99+
| <a name="input_event_target_input_path"></a> [event\_target\_input\_path](#input\_event\_target\_input\_path) | (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event\_target\_input. | `string` | `null` | no |
100+
| <a name="input_event_target_target_id"></a> [event\_target\_target\_id](#input\_event\_target\_target\_id) | (Optional) The unique target assignment ID. If missing, will generate a random, unique id. | `string` | `null` | no |
101+
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix for resources on AWS. | `string` | n/a | yes |
102+
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | (Optional) The ARN of the policy that is used to set the permissions boundary for the role. | `string` | `null` | no |
102103

103104
## Outputs
104105

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ resource "aws_iam_role" "scheduled_task_cw_event_role" {
3333
count = var.event_rule_role_arn == null ? 1 : 0
3434
name = "${var.name_prefix}-st-cw-role"
3535
assume_role_policy = data.aws_iam_policy_document.scheduled_task_cw_event_role_assume_role_policy.json
36+
37+
permissions_boundary = var.permissions_boundary == null ? null : var.permissions_boundary
3638
}
3739

3840
resource "aws_iam_role_policy" "scheduled_task_cw_event_role_cloudwatch_policy" {

variables.tf

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,51 @@
33
#------------------------------------------------------------------------------
44
variable "name_prefix" {
55
description = "Name prefix for resources on AWS."
6+
type = string
67
}
78

89
#------------------------------------------------------------------------------
910
# CLOUDWATCH EVENT RULE
1011
#------------------------------------------------------------------------------
1112
variable "event_rule_name" {
1213
description = "The name of the rule."
14+
type = string
1315
}
1416

1517
variable "event_rule_schedule_expression" {
1618
description = "(Optional) The scheduling expression. For example, cron(0 20 * * ? *) or rate(5 minutes). At least one of event_rule_schedule_expression or event_rule_event_pattern is required. Can only be used on the default event bus."
1719
default = null
20+
type = string
1821
}
1922

2023
variable "event_rule_event_bus_name" {
2124
description = "(Optional) The event bus to associate with this rule. If you omit this, the default event bus is used."
2225
default = null
26+
type = string
2327
}
2428

2529
variable "event_rule_event_pattern" {
2630
description = "(Optional) The event pattern described a JSON object. At least one of schedule_expression or event_pattern is required."
2731
default = null
32+
type = string
2833
}
2934

3035
variable "event_rule_description" {
3136
description = "(Optional) The description of the rule."
3237
default = null
38+
type = string
3339
}
3440

3541
variable "event_rule_role_arn" {
3642
description = "(Optional) The Amazon Resource Name (ARN) associated with the role that is used for target invocation."
3743
default = null
44+
type = string
3845
}
3946

4047
variable "event_rule_is_enabled" {
4148
description = "(Optional) Whether the rule should be enabled (defaults to true)."
42-
type = bool
4349
default = true
50+
type = bool
4451
}
4552

4653
#------------------------------------------------------------------------------
@@ -49,49 +56,58 @@ variable "event_rule_is_enabled" {
4956
variable "event_target_target_id" {
5057
description = "(Optional) The unique target assignment ID. If missing, will generate a random, unique id."
5158
default = null
59+
type = string
5260
}
5361

5462
variable "ecs_cluster_arn" {
5563
description = "The ECS Cluster where the scheduled task will run."
64+
type = string
5665
}
5766

5867
variable "event_target_input" {
5968
description = "(Optional) Valid JSON text passed to the target. Conflicts with event_target_input_path."
6069
default = null
70+
type = string
6171
}
6272

6373
variable "event_target_input_path" {
6474
description = " (Optional) The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. Conflicts with event_target_input."
6575
default = null
76+
type = string
6677
}
6778

6879
variable "ecs_execution_task_role_arn" {
6980
description = "(Required) The task definition execution role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered."
81+
type = string
7082
}
7183

7284
variable "ecs_task_role_arn" {
7385
description = "(Optional) The task definition role. The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered."
7486
default = null
87+
type = string
7588
}
7689

7790
variable "event_target_ecs_target_group" {
7891
description = "(Optional) Specifies an ECS task group for the task. The maximum length is 255 characters."
7992
default = null
93+
type = string
8094
}
8195

8296
variable "event_target_ecs_target_platform_version" {
8397
description = "(Optional) Specifies the platform version for the task. Specify only the numeric portion of the platform version, such as 1.1.0. For more information about valid platform versions, see AWS Fargate Platform Versions. Default to LATEST."
8498
default = "LATEST"
99+
type = string
85100
}
86101

87102
variable "event_target_ecs_target_task_count" {
88103
description = "(Optional) The number of tasks to create based on the TaskDefinition. The default is 1."
89-
type = number
90104
default = 1
105+
type = number
91106
}
92107

93108
variable "event_target_ecs_target_task_definition_arn" {
94109
description = "(Required) The ARN of the task definition to use if the event target is an Amazon ECS cluster."
110+
type = string
95111
}
96112

97113
variable "event_target_ecs_target_subnets" {
@@ -101,18 +117,25 @@ variable "event_target_ecs_target_subnets" {
101117

102118
variable "event_target_ecs_target_security_groups" {
103119
description = "(Optional) The security groups associated with the task or service. If you do not specify a security group, the default security group for the VPC is used."
104-
type = list(any)
105120
default = null
121+
type = list(any)
106122
}
107123

108124
variable "event_target_ecs_target_assign_public_ip" {
109125
description = "(Optional) Assign a public IP address to the ENI. Default false."
110-
type = bool
111126
default = false
127+
type = bool
128+
112129
}
113130

114131
variable "event_target_ecs_target_propagate_tags" {
115132
description = "(Optional) Specifies whether to propagate the tags from the task definition to the task. If no value is specified, the tags are not propagated. Tags can only be propagated to the task during task creation. Valid values: `TASK_DEFINITION` or leave empty to avoid propagation."
116-
type = string
117133
default = ""
134+
type = string
118135
}
136+
137+
variable "permissions_boundary" {
138+
description = "(Optional) The ARN of the policy that is used to set the permissions boundary for the role."
139+
default = null
140+
type = string
141+
}

0 commit comments

Comments
 (0)