Skip to content

Commit 97e8435

Browse files
committed
feat: changing the boundary parameter to a name rather than full arn
1 parent 5d790c9 commit 97e8435

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

Diff for: examples/role/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module "common_provider_example" {
1313
repository = "appvia/something"
1414

1515
// Set the permission boundary for both the read-only and read-write role
16-
permission_boundary_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
16+
permission_boundary = "AdministratorAccess"
1717

1818
// List of policy ARNs to attach to the read-only role
1919
read_only_policy_arns = [

Diff for: modules/role/data.tf

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
2+
## Retrieve the current AWS account identity
13
data "aws_caller_identity" "current" {}
4+
## Retrieve the current AWS region
25
data "aws_region" "current" {}

Diff for: modules/role/locals.tf

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ locals {
2424
subject_tag_mapping = "project_path:{repo}:ref_type:{type}:ref:{ref}"
2525
}
2626
}
27+
# The full ARN of the permission boundary to attach to the role
28+
permission_boundary_arn = format("arn:aws:iam::%s:policy/%s", data.aws_caller_identity.current.account_id, var.permission_boundary)
2729
}
2830

2931
locals {

Diff for: modules/role/main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "aws_iam_role" "ro" {
4444

4545
force_detach_policies = var.force_detach_policies
4646
max_session_duration = var.read_only_max_session_duration
47-
permissions_boundary = var.permission_boundary_arn
47+
permissions_boundary = local.permission_boundary_arn
4848

4949
dynamic "inline_policy" {
5050
for_each = var.read_only_inline_policies
@@ -119,7 +119,7 @@ resource "aws_iam_role" "rw" {
119119

120120
force_detach_policies = var.force_detach_policies
121121
max_session_duration = var.read_write_max_session_duration
122-
permissions_boundary = var.permission_boundary_arn
122+
permissions_boundary = local.permission_boundary_arn
123123

124124
dynamic "inline_policy" {
125125
for_each = var.read_write_inline_policies

Diff for: modules/role/variables.tf

+2-4
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,12 @@ variable "force_detach_policies" {
104104
description = "Flag to force detachment of policies attached to the IAM role."
105105
}
106106

107-
variable "permission_boundary_arn" {
107+
variable "permission_boundary" {
108108
type = string
109-
default = null
110-
description = "The ARN of the policy that is used to set the permissions boundary for the IAM role"
109+
description = "The name of the policy that is used to set the permissions boundary for the IAM role"
111110
}
112111

113112
variable "tags" {
114113
type = map(string)
115-
default = {}
116114
description = "Tags to apply resoures created by this module"
117115
}

0 commit comments

Comments
 (0)