From 3c84970fc3ee5bcfdaf7d317d50b055ab3ed1602 Mon Sep 17 00:00:00 2001 From: badra001 Date: Mon, 23 Jun 2025 11:50:07 -0400 Subject: [PATCH] * 2.12.0 -- 2025-06-23 - share-resources - add share_explict_enabled to force creation of aws_ram_resource_association, not needed within the same organization and sharing enabled --- CHANGELOG.md | 3 ++ common/version.tf | 2 +- share-resources/README.md | 72 ++++++++++++++++++++++++++++++++++++ share-resources/share.tf | 4 +- share-resources/variables.tf | 10 +++++ 5 files changed, 88 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b40597f..7a5459a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -476,3 +476,6 @@ - vpc-interface-endpoint - add arn output to vpce_service_info +* 2.12.0 -- 2025-06-23 + - share-resources + - add share_explict_enabled to force creation of aws_ram_resource_association, not needed within the same organization and sharing enabled diff --git a/common/version.tf b/common/version.tf index 8e8bc5e..afa03be 100644 --- a/common/version.tf +++ b/common/version.tf @@ -1,5 +1,5 @@ locals { - _module_version = "2.11.9" + _module_version = "2.12.0" _module_names = { "_main_" = "aws-vpc-setup" diff --git a/share-resources/README.md b/share-resources/README.md index bb9833a..af84da5 100644 --- a/share-resources/README.md +++ b/share-resources/README.md @@ -66,3 +66,75 @@ No modules. ## Outputs No outputs. + + +# About aws-vpc-setup :: share-resources + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.0.0 | +| [aws](#requirement\_aws) | >= 4.0.0 | +| [ldap](#requirement\_ldap) | >= 0.5.4 | +| [local](#requirement\_local) | >= 1.0.0 | +| [null](#requirement\_null) | >= 3.0 | +| [random](#requirement\_random) | >= 3.0 | +| [template](#requirement\_template) | >= 2.0 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | >= 4.0.0 | +| [aws.org\_master](#provider\_aws.org\_master) | >= 4.0.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_ram_principal_association.subnets_accounts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_principal_association) | resource | +| [aws_ram_principal_association.subnets_organizational_units](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_principal_association) | resource | +| [aws_ram_resource_association.subnets_accounts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_association) | resource | +| [aws_ram_resource_association.subnets_organizational_units](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_association) | resource | +| [aws_ram_resource_share.subnets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_share) | resource | +| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_arn.org_master_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_caller_identity.org_master_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_account_alias.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_account_alias) | data source | +| [aws_organizations_organization.org](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_organization) | data source | +| [aws_organizations_resource_tags.accounts](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_resource_tags) | data source | +| [aws_organizations_resource_tags.organizational_units](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/organizations_resource_tags) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [account\_alias](#input\_account\_alias) | AWS Account Alias (default: will pull from current account\_alias) | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default: will pull from current user) | `string` | `""` | no | +| [create](#input\_create) | Flag to indicate whether to create the resources or not (default: true) | `bool` | `true` | no | +| [org\_master\_profile](#input\_org\_master\_profile) | AWS Organization Master account profile | `string` | n/a | yes | +| [org\_master\_region](#input\_org\_master\_region) | AWS Organization Master region (see docs: https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-organizations.html) | `string` | n/a | yes | +| [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component. This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | +| [private\_subnets\_ids](#input\_private\_subnets\_ids) | List of private subnet objects including: subnet, label, availability\_zone, id, arn, tags |
list(object({
subnet = string
label = string
availability_zone = string
id = string
arn = optional(string, null)
tags = optional(map(string), {})
}))
| `[]` | no | +| [share\_account\_list](#input\_share\_account\_list) | List of AWS Account IDs to share VPC/subnets into. If the account is not part of the organziation, this will produce an error. | `list(string)` | `[]` | no | +| [share\_enabled](#input\_share\_enabled) | Flag indiciating whether to share resources to other accounts and OUs | `bool` | `false` | no | +| [share\_explicit\_enabled](#input\_share\_explicit\_enabled) | Flag indiciating whether to share resources explicitly | `bool` | `false` | no | +| [share\_organizational\_unit\_list](#input\_share\_organizational\_unit\_list) | List of Organizational Unit IDs to share VPC/subnets into. This does not check if they are OUs. | `list(string)` | `[]` | no | +| [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | +| [vpc\_environment](#input\_vpc\_environment) | VPC environment purpose (infrastructure, common, shared, dev, stage, ite, prod, inpection) | `string` | `null` | no | +| [vpc\_full\_name](#input\_vpc\_full\_name) | VPC full name component (vpc{index}-{vpc\_name}) | `string` | `null` | no | +| [vpc\_index](#input\_vpc\_index) | VPC index number (integer starting at 1) | `number` | `null` | no | +| [vpc\_name](#input\_vpc\_name) | VPC name component used through the VPC descrbing its purpose (ex: dice-dev) | `string` | `null` | no | +| [vpc\_short\_name](#input\_vpc\_short\_name) | VPC short name component (vpc{index}) | `string` | `null` | no | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/share-resources/share.tf b/share-resources/share.tf index 958f6a7..5de80ae 100644 --- a/share-resources/share.tf +++ b/share-resources/share.tf @@ -70,7 +70,7 @@ resource "aws_ram_principal_association" "subnets_accounts" { } resource "aws_ram_resource_association" "subnets_accounts" { - for_each = var.share_enabled ? local.share_account_map : {} + for_each = var.share_enabled && var.share_explicit_enabled ? local.share_account_map : {} resource_arn = each.value.subnet_arn resource_share_arn = aws_ram_resource_share.subnets[each.value.subnet_id].arn } @@ -95,7 +95,7 @@ resource "aws_ram_principal_association" "subnets_organizational_units" { } resource "aws_ram_resource_association" "subnets_organizational_units" { - for_each = var.share_enabled ? local.share_organizational_unit_map : {} + for_each = var.share_enabled && var.share_explicit_enabled ? local.share_organizational_unit_map : {} resource_arn = each.value.subnet_arn resource_share_arn = aws_ram_resource_share.subnets[each.value.subnet_id].arn } diff --git a/share-resources/variables.tf b/share-resources/variables.tf index 82ad9e5..c9828be 100644 --- a/share-resources/variables.tf +++ b/share-resources/variables.tf @@ -16,6 +16,16 @@ variable "share_enabled" { default = false } +# this is to disable the creation of the aws_ram_resource_association, not necessary within the same organization +# with sharing enabled. See: +# https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-create.html + +variable "share_explicit_enabled" { + description = "Flag indiciating whether to share resources explicitly" + type = bool + default = false +} + variable "share_account_list" { description = "List of AWS Account IDs to share VPC/subnets into. If the account is not part of the organziation, this will produce an error." type = list(string)