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

Add support for multiple roles to assume when requesting CIDR range from IPAM #1542

Merged
merged 1 commit into from
Sep 17, 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
6 changes: 4 additions & 2 deletions network/ipam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ module "ram_share_with_capabilities" {
resource_arns = [
for pool in values(module.regional_capabilities_pools) : pool.arn
]
principals = formatlist(var.ipam_role_pattern, module.org-account-query.account_ids, var.ipam_role_name)
tags = var.tags
principals = flatten([
for pattern in var.ipam_role_patterns : formatlist(pattern, module.org-account-query.account_ids)
])
tags = var.tags
}
18 changes: 6 additions & 12 deletions network/ipam/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,14 @@ variable "ipam_ou_id" {
description = "The ID of the AWS Organization OU that you want to query for accounts. This is used for sharing access to the IPAM pools."
}

variable "ipam_role_name" {
type = string
description = "The name of an IAM role in each AWS Organization account that is allowed to request IP addresses from the IPAM pools."
default = "AWSServiceRoleForIPAM"
}

variable "ipam_role_pattern" {
type = string
variable "ipam_role_patterns" {
type = list(string)
description = <<EOF
The pattern of a role ARN that is allowed to request IP addresses from the IPAM pools.
The %s placeholders will be replaced with the AWS account ID from var.ipam_ou_id
and the value of var.ipam_role_name within this module.
The pattern of a role ARNs that are1 allowed to request IP addresses from the IPAM pools.
The %s placeholders will be replaced with the AWS account ID from accounts under
the OU specified by var.ipam_ou_id.
EOF
default = "arn:aws:iam::%s:role/aws-service-role/ipam.amazonaws.com/%s"
default = ["arn:aws:iam::%s:role/aws-service-role/ipam.amazonaws.com/AWSServiceRoleForIPAM"]
}

variable "tags" {
Expand Down
Loading