# Organizational Units

Provisions and manages OUs up to 3 levels deep (root, child, grandchild) under the organization root. Fully configurable via the `organizational_units` variable. Depends on the `governance/organization` module for the root ID.

## Usage

```hcl
module "ou" {
  source  = "hcassc.jfrog.io/iac-terraform-modules-virtual/governance/ou/aws"
  version = "0.1.0"

  root_id = module.organization.roots[0].id

  organizational_units = {
    workloads = {
      name       = "Workloads"
      parent_key = "root"
    }
    workloads_prod = {
      name       = "Prod"
      parent_key = "workloads"
    }
    sandbox = {
      name       = "Sandbox"
      parent_key = "root"
    }
  }
}
```

<!-- BEGIN_TF_DOCS — DO NOT EDIT BELOW THIS LINE -->

## Requirements

| Name                                                                     | Version |
| ------------------------------------------------------------------------ | ------- |
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | ~> 1.5  |
| <a name="requirement_aws"></a> [aws](#requirement_aws)                   | ~> 5.0  |

## Providers

| Name                                             | Version |
| ------------------------------------------------ | ------- |
| <a name="provider_aws"></a> [aws](#provider_aws) | 6.50.0  |

## Resources

| Name                                                                                                                                                              | Type     |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| [aws_organizations_organizational_unit.child](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_organizational_unit)      | resource |
| [aws_organizations_organizational_unit.grandchild](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_organizational_unit) | resource |
| [aws_organizations_organizational_unit.root](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/organizations_organizational_unit)       | resource |

## Inputs

| Name                                                                                          | Description                                                                                                                                         | Type                                                                                                               | Default | Required |
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------- | :------: |
| <a name="input_organizational_units"></a> [organizational_units](#input_organizational_units) | Map of OU definitions. Each key is a logical name used internally.<br/>parent_key references another key in this map (or 'root' for top-level OUs). | <pre>map(object({<br/> name = string<br/> parent_key = string<br/> tags = optional(map(string), {})<br/> }))</pre> | n/a     |   yes    |
| <a name="input_root_id"></a> [root_id](#input_root_id)                                        | Organization root ID under which top-level OUs are created (e.g. r-xxxx)                                                                            | `string`                                                                                                           | n/a     |   yes    |

## Outputs

| Name                                                                                      | Description                              |
| ----------------------------------------------------------------------------------------- | ---------------------------------------- |
| <a name="output_all_ou_ids"></a> [all_ou_ids](#output_all_ou_ids)                         | Merged map of all OU logical keys to IDs |
| <a name="output_child_ou_arns"></a> [child_ou_arns](#output_child_ou_arns)                | Map of logical key to child OU ARN       |
| <a name="output_child_ou_ids"></a> [child_ou_ids](#output_child_ou_ids)                   | Map of logical key to child OU ID        |
| <a name="output_grandchild_ou_arns"></a> [grandchild_ou_arns](#output_grandchild_ou_arns) | Map of logical key to grandchild OU ARN  |
| <a name="output_grandchild_ou_ids"></a> [grandchild_ou_ids](#output_grandchild_ou_ids)    | Map of logical key to grandchild OU ID   |
| <a name="output_root_ou_arns"></a> [root_ou_arns](#output_root_ou_arns)                   | Map of logical key to root-level OU ARN  |
| <a name="output_root_ou_ids"></a> [root_ou_ids](#output_root_ou_ids)                      | Map of logical key to root-level OU ID   |

<!-- END_TF_DOCS — DO NOT EDIT ABOVE THIS LINE -->
