cloudposse / terraform-aws-transit-gateway

Terraform module to provision AWS Transit Gateway, AWS Resource Access Manager (AWS RAM) Resource, and share the Transit Gateway with the Organization or another AWS Account.
https://cloudposse.com/accelerate
Apache License 2.0
53 stars 47 forks source link

Feature/ram share multiple principals #14

Closed paulrob-100 closed 2 years ago

paulrob-100 commented 2 years ago

what

why

references

mergify[bot] commented 2 years ago

This pull request is now in conflict. Could you fix it @paulrob-100? 🙏

nitrocode commented 2 years ago

@paulrob-100 could you remove the changes unrelated to the multiple principals ?

I think we can do something as simple as this

locals {
  enabled = module.this.enabled

  ram_resource_share_enabled = local.enabled && var.ram_resource_share_enabled

  ram_principals = toset(concat(var.ram_principals, data.aws_organizations_organization.default.*.arn))
}

resource "aws_ram_principal_association" "default" {
  for_each = local.ram_resource_share_enabled ? toset(local.ram_principals) : toset([])

  principal          = each.value
  resource_share_arn = try(aws_ram_resource_share.default[0].id, "")
}

Also @paulrob-100 so you're unblocked, we're also outputting the ram_resource_share_id so principals can be attached to the RAM share from outside the module.