Skip to content

Commit 219f003

Browse files
SergKnozaq
andauthored
feat: add permissions boundaries for IAM entities support (#288)
It might be a case when iam roles can be created with predefined boundaries. This PR introduce such capabilities by providing permissions_boundary_arn option Currently single permissions_boundary_arn will be applied to all iam_roles provisioned by this module Signed-off-by: Sergiy Kulanov <[email protected]> Co-authored-by: nozaq <[email protected]>
1 parent f0cdf3e commit 219f003

File tree

11 files changed

+33
-0
lines changed

11 files changed

+33
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ This module is composed of several submodules and each of which can be used inde
192192
| <a name="input_no_mfa_console_signin_enabled"></a> [no\_mfa\_console\_signin\_enabled](#input\_no\_mfa\_console\_signin\_enabled) | The boolean flag whether the no\_mfa\_console\_signin alarm is enabled or not. No resources are created when set to false. | `bool` | no |
193193
| <a name="input_organizations_changes_enabled"></a> [organizations\_changes\_enabled](#input\_organizations\_changes\_enabled) | The boolean flag whether the organizations\_changes alarm is enabled or not. No resources are created when set to false. | `bool` | no |
194194
| <a name="input_password_reuse_prevention"></a> [password\_reuse\_prevention](#input\_password\_reuse\_prevention) | The number of previous passwords that users are prevented from reusing. | `number` | no |
195+
| <a name="input_permissions_boundary_arn"></a> [permissions\_boundary\_arn](#input\_permissions\_boundary\_arn) | The permissions boundary ARN for all IAM Roles, provisioned by this module | `string` | no |
195196
| <a name="input_require_lowercase_characters"></a> [require\_lowercase\_characters](#input\_require\_lowercase\_characters) | Whether to require lowercase characters for user passwords. | `bool` | no |
196197
| <a name="input_require_numbers"></a> [require\_numbers](#input\_require\_numbers) | Whether to require numbers for user passwords. | `bool` | no |
197198
| <a name="input_require_symbols"></a> [require\_symbols](#input\_require\_symbols) | Whether to require symbols for user passwords. | `bool` | no |

config_baselines.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ resource "aws_iam_role" "recorder" {
4343
name = var.config_iam_role_name
4444
assume_role_policy = data.aws_iam_policy_document.recorder_assume_role_policy[0].json
4545

46+
permissions_boundary = var.permissions_boundary_arn
47+
4648
tags = var.tags
4749
}
4850

@@ -630,6 +632,8 @@ resource "aws_iam_role" "config_organization" {
630632
name_prefix = var.config_aggregator_name_prefix
631633
assume_role_policy = data.aws_iam_policy_document.config_organization_assume_role_policy[0].json
632634

635+
permissions_boundary = var.permissions_boundary_arn
636+
633637
tags = var.tags
634638
}
635639

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module "iam_baseline" {
4343

4444
support_iam_role_name = var.support_iam_role_name
4545
support_iam_role_principal_arns = var.support_iam_role_principal_arns
46+
permissions_boundary_arn = var.permissions_boundary_arn
4647
minimum_password_length = var.minimum_password_length
4748
password_reuse_prevention = var.password_reuse_prevention
4849
require_lowercase_characters = var.require_lowercase_characters
@@ -75,6 +76,7 @@ module "cloudtrail_baseline" {
7576
cloudwatch_logs_retention_in_days = var.cloudwatch_logs_retention_in_days
7677
iam_role_name = var.cloudtrail_iam_role_name
7778
iam_role_policy_name = var.cloudtrail_iam_role_policy_name
79+
permissions_boundary_arn = var.permissions_boundary_arn
7880
key_deletion_window_in_days = var.cloudtrail_key_deletion_window_in_days
7981
region = var.region
8082
s3_bucket_name = local.audit_log_bucket_id

modules/cloudtrail-baseline/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Enable CloudTrail in all regions and deliver events to CloudWatch Logs. CloudTra
3636
| <a name="input_is_organization_trail"></a> [is\_organization\_trail](#input\_is\_organization\_trail) | Specifies whether the trail is an AWS Organizations trail. Organization trails log events for the master account and all member accounts. Can only be created in the organization master account. | `bool` | no |
3737
| <a name="input_key_deletion_window_in_days"></a> [key\_deletion\_window\_in\_days](#input\_key\_deletion\_window\_in\_days) | Duration in days after which the key is deleted after destruction of the resource, must be between 7 and 30 days. Defaults to 30 days. | `number` | no |
3838
| <a name="input_lambda_invocation_logging_lambdas"></a> [lambda\_invocation\_logging\_lambdas](#input\_lambda\_invocation\_logging\_lambdas) | The list of lambda ARNs on which to enable invocation logging. | `list(string)` | no |
39+
| <a name="input_permissions_boundary_arn"></a> [permissions\_boundary\_arn](#input\_permissions\_boundary\_arn) | The permissions boundary ARN for all IAM Roles, provisioned by this module | `string` | no |
3940
| <a name="input_s3_key_prefix"></a> [s3\_key\_prefix](#input\_s3\_key\_prefix) | The prefix for the specified S3 bucket. | `string` | no |
4041
| <a name="input_s3_object_level_logging_buckets"></a> [s3\_object\_level\_logging\_buckets](#input\_s3\_object\_level\_logging\_buckets) | The list of S3 bucket ARNs on which to enable object-level logging. | `list(string)` | no |
4142
| <a name="input_tags"></a> [tags](#input\_tags) | Specifies object tags key and value. This applies to all resources created by this module. | `map(string)` | no |

modules/cloudtrail-baseline/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ resource "aws_iam_role" "cloudwatch_delivery" {
2929
name = var.iam_role_name
3030
assume_role_policy = data.aws_iam_policy_document.cloudwatch_delivery_assume_policy.json
3131

32+
permissions_boundary = var.permissions_boundary_arn
33+
3234
tags = var.tags
3335
}
3436

modules/cloudtrail-baseline/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ variable "iam_role_policy_name" {
5151
default = "CloudTrail-CloudWatch-Delivery-Policy"
5252
}
5353

54+
variable "permissions_boundary_arn" {
55+
description = "The permissions boundary ARN for all IAM Roles, provisioned by this module"
56+
type = string
57+
default = ""
58+
}
59+
5460
variable "key_deletion_window_in_days" {
5561
description = "Duration in days after which the key is deleted after destruction of the resource, must be between 7 and 30 days. Defaults to 30 days."
5662
type = number

modules/iam-baseline/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
| <a name="input_max_password_age"></a> [max\_password\_age](#input\_max\_password\_age) | The number of days that an user password is valid. | `number` | no |
3131
| <a name="input_minimum_password_length"></a> [minimum\_password\_length](#input\_minimum\_password\_length) | Minimum length to require for user passwords. | `number` | no |
3232
| <a name="input_password_reuse_prevention"></a> [password\_reuse\_prevention](#input\_password\_reuse\_prevention) | The number of previous passwords that users are prevented from reusing. | `number` | no |
33+
| <a name="input_permissions_boundary_arn"></a> [permissions\_boundary\_arn](#input\_permissions\_boundary\_arn) | The permissions boundary ARN for all IAM Roles, provisioned by this module | `string` | no |
3334
| <a name="input_require_lowercase_characters"></a> [require\_lowercase\_characters](#input\_require\_lowercase\_characters) | Whether to require lowercase characters for user passwords. | `bool` | no |
3435
| <a name="input_require_numbers"></a> [require\_numbers](#input\_require\_numbers) | Whether to require numbers for user passwords. | `bool` | no |
3536
| <a name="input_require_symbols"></a> [require\_symbols](#input\_require\_symbols) | Whether to require symbols for user passwords. | `bool` | no |

modules/iam-baseline/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ resource "aws_iam_role" "support" {
3535
name = var.support_iam_role_name
3636
assume_role_policy = data.aws_iam_policy_document.support_assume_policy.json
3737

38+
permissions_boundary = var.permissions_boundary_arn
39+
3840
tags = var.tags
3941
}
4042

modules/iam-baseline/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "support_iam_role_name" {
44
default = "IAM-Support"
55
}
66

7+
variable "permissions_boundary_arn" {
8+
description = "The permissions boundary ARN for all IAM Roles, provisioned by this module"
9+
type = string
10+
default = ""
11+
}
12+
713
variable "support_iam_role_principal_arns" {
814
type = list(any)
915
description = "List of ARNs of the IAM principal elements by which the support role could be assumed."

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ variable "member_accounts" {
3333
default = []
3434
}
3535

36+
variable "permissions_boundary_arn" {
37+
description = "The permissions boundary ARN for all IAM Roles, provisioned by this module"
38+
type = string
39+
default = ""
40+
}
41+
3642
variable "target_regions" {
3743
description = "A list of regions to set up with this module."
3844
type = list(string)

0 commit comments

Comments
 (0)