# ram-share

Creates AWS RAM resource shares that attach resource ARNs and principals to
a share. Org-shared principals auto-accept, while non-Org principals require
a separate `ram-acceptance` module invocation from the receiver account.

Custom permissions are attached via `permission_arns`, a direct attribute on
the resource share — AWS RAM has no separate permission-association resource.
When omitted, AWS auto-attaches its default managed permission for each
resource type in the share. Custom permission ARNs (from `aws_ram_permission`
or an AWS-managed permission) must be created elsewhere and passed in; this
module does not create permissions.

Share names are derived as `${name_prefix}-${region_abbr}-${name_suffix}`,
matching the naming convention used across other modules.

## Usage

```hcl
module "ram_share" {
  source  = "hcassc.jfrog.io/iac-tf-modules-virtual__networking/ram-share/aws"
  version = "0.3.0"

  name_prefix = "acme-dev-shared"

  resource_shares = {
    example_share = {
      name_suffix   = "example-share"
      resource_arns = ["arn:aws:ec2:ap-south-1:123456789012:subnet/subnet-xxxx"]
      principals    = ["arn:aws:organizations::123456789012:organization/o-xxxxxxxxxx"]
    }
  }

  tags = local.stack_tags
}
```

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

## Requirements

| Name                                                                     | Version            |
| ------------------------------------------------------------------------ | ------------------ |
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | >= 1.15.0, < 2.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement_aws)                   | >= 6.0, < 7.0      |

## Providers

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

## Resources

| Name                                                                                                                                        | Type     |
| ------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| [aws_ram_principal_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_principal_association) | resource |
| [aws_ram_resource_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_association)   | resource |
| [aws_ram_resource_share.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ram_resource_share)               | resource |

## Inputs

| Name                                                                           | Description                                                                                                                                                                   | Type                                                                                                                                                                                                                                                                        | Default | Required |
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | :------: |
| <a name="input_name_prefix"></a> [name_prefix](#input_name_prefix)             | Prefix prepended to resource names created by this module                                                                                                                     | `string`                                                                                                                                                                                                                                                                    | n/a     |   yes    |
| <a name="input_resource_shares"></a> [resource_shares](#input_resource_shares) | Map of RAM resource share definitions.<br/>resource_arns and principals are required to be explicitly passed in<br/>to ensure deterministic, auditable sharing relationships. | <pre>map(object({<br/> name_suffix = string<br/> resource_arns = list(string)<br/> principals = list(string)<br/> allow_external_principals = optional(bool, false)<br/> permission_arns = optional(list(string))<br/><br/> tags = optional(map(string), {})<br/> }))</pre> | `{}`    |    no    |
| <a name="input_tags"></a> [tags](#input_tags)                                  | Tags applied to all resources in this module.                                                                                                                                 | `map(string)`                                                                                                                                                                                                                                                               | `{}`    |    no    |

## Outputs

| Name                                                                                                  | Description                                                      |
| ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| <a name="output_principal_associations"></a> [principal_associations](#output_principal_associations) | Map of principal association keys to the associated principal.   |
| <a name="output_resource_associations"></a> [resource_associations](#output_resource_associations)    | Map of resource association keys to the associated resource ARN. |
| <a name="output_resource_share_arns"></a> [resource_share_arns](#output_resource_share_arns)          | Map of resource share keys to RAM resource share ARNs.           |
| <a name="output_resource_share_ids"></a> [resource_share_ids](#output_resource_share_ids)             | Map of resource share keys to RAM resource share IDs.            |
| <a name="output_resource_share_status"></a> [resource_share_status](#output_resource_share_status)    | Map of resource share keys to their current status.              |

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