|
1 |
| -# terraform-aws-opensearch-serverless |
2 |
| -Dynamic Terraform module, which creates a Opensearch Serverless Collection |
| 1 | +# AWS Opensearch Serverless Terraform module |
| 2 | + |
| 3 | +[](https://github.com/semantic-release/semantic-release) |
| 4 | + |
| 5 | +Dynamic Terraform module, which creates a Opensearch Serverless Collection and related resources. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [AWS Opensearch Serverless Terraform module](#aws-opensearch-serverless-terraform-module) |
| 10 | + * [Table of Contents](#table-of-contents) |
| 11 | + * [Module versioning rule](#module-versioning-rule) |
| 12 | + * [Features](#features) |
| 13 | + * [How to Use](#how-to-use) |
| 14 | + + [Basic Example](#basic-example) |
| 15 | + + [Encryption Policy](#encryption-policy) |
| 16 | + + [Network Policy](#network-policy) |
| 17 | + - [VPC Access](#vpc-access) |
| 18 | + + [Data Access Policy](#data-access-policy) |
| 19 | + * [Examples](#examples) |
| 20 | + * [Requirements](#requirements) |
| 21 | + * [Providers](#providers) |
| 22 | + * [Modules](#modules) |
| 23 | + * [Resources](#resources) |
| 24 | + * [Inputs](#inputs) |
| 25 | + * [Outputs](#outputs) |
| 26 | + * [License](#license) |
| 27 | + |
| 28 | + |
| 29 | +## Module versioning rule |
| 30 | + |
| 31 | +| Module version | AWS Provider version | |
| 32 | +|----------------|----------------------| |
| 33 | +| >= 1.x.x | => 5.31 | |
| 34 | + |
| 35 | +## Features |
| 36 | + |
| 37 | +- Encryption Policy |
| 38 | +- Network Policy |
| 39 | +- Data Access Policy |
| 40 | +- Opensearch Serverless VPCE |
| 41 | + |
| 42 | +## How to Use |
| 43 | + |
| 44 | +### Basic Example |
| 45 | + |
| 46 | +This example will create: |
| 47 | + * Opensearch Serverless Collection |
| 48 | + * Encryption Policy with AWS Managed KMS Key |
| 49 | + * Public Network Policy to Both Endpoints |
| 50 | + * Data Access Policy with all permissions to collection and all indexes |
| 51 | + |
| 52 | +```hcl |
| 53 | +module "firehose" { |
| 54 | + source = "fdmsantos/opensearch-serverless/aws" |
| 55 | + version = "x.x.x" |
| 56 | + name = "demo-collection" |
| 57 | + access_policy_rules = [ |
| 58 | + { |
| 59 | + type = "collection" |
| 60 | + permissions = ["All"] |
| 61 | + principals = [data.aws_caller_identity.current.arn] |
| 62 | + }, |
| 63 | + { |
| 64 | + type = "index" |
| 65 | + permissions = ["All"] |
| 66 | + indexes = ["*"] |
| 67 | + principals = [data.aws_caller_identity.current.arn] |
| 68 | + } |
| 69 | + ] |
| 70 | +} |
| 71 | +``` |
| 72 | + |
| 73 | +### Encryption Policy |
| 74 | + |
| 75 | +By default, the encryption policy use AWS managed KMS Key. To Use Customer Managed KMS Key use the variable `encryption_policy_kms_key_arn` |
| 76 | + |
| 77 | +### Network Policy |
| 78 | + |
| 79 | +By default, the network policy is created with public access to dashboard and collection endpoints. |
| 80 | +To change the network policy use variable `network_policy_type`. The supported values are: |
| 81 | + |
| 82 | +| Value | Description | |
| 83 | +|----------------------------------|--------------------------------------------------------------------| |
| 84 | +| AllPublic | Public endpoints for Dashboard and Collection | |
| 85 | +| AllPrivate | Private endpoints for Dashboard and Collection | |
| 86 | +| PublicCollectionPrivateDashboard | Public endpoint for Collection and Private endpoint for Collection | |
| 87 | +| PrivateCollectionPublicDashboard | Private endpoint for Collection and Public endpoint forCollection | |
| 88 | + |
| 89 | +#### VPC Access |
| 90 | + |
| 91 | +If the variable `network_policy_type` is different from "AllPublic", the module will create Opensearch Serverless Endpoint to private access. |
| 92 | +In this case it's necessary configure the following variables: `vpce_subnet_ids` and `vpce_vpc_id`. `vpce_security_group_ids` is optional. |
| 93 | + |
| 94 | +### Data Access Policy |
| 95 | + |
| 96 | +To configure data access policy use variable `access_policy_rules`. This variable is a list of data access rules. |
| 97 | +Each rule contains the following fields: |
| 98 | + |
| 99 | +| Field | Supported Values | |
| 100 | +|-------------|----------------------------------------------------------------------------------------------------------------------| |
| 101 | +| type | collection;index | |
| 102 | +| permissions | Collection Type: All;Create;Read;Update;Delete. Index Type: All;Create;Read;Update;Delete;ReadDocument;WriteDocument | |
| 103 | +| principals | IAM Users;IAM Roles;SAML users;SAML Groups | |
| 104 | +| principals | IAM Users;IAM Roles;SAML users;SAML Groups | |
| 105 | +| indexes | List of indexes to be used on policy rule | |
| 106 | + |
| 107 | +## Examples |
| 108 | + |
| 109 | +- [Complete](https://github.com/fdmsantos/terraform-aws-opensearch-serverless/tree/main/examples/complete) - Creates an opensearch serverless collection with all features. |
| 110 | + |
| 111 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 112 | +## Requirements |
| 113 | + |
| 114 | +| Name | Version | |
| 115 | +|------|---------| |
| 116 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 | |
| 117 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.31 | |
| 118 | + |
| 119 | +## Providers |
| 120 | + |
| 121 | +| Name | Version | |
| 122 | +|------|---------| |
| 123 | +| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.31 | |
| 124 | + |
| 125 | +## Modules |
| 126 | + |
| 127 | +No modules. |
| 128 | + |
| 129 | +## Resources |
| 130 | + |
| 131 | +| Name | Type | |
| 132 | +|------|------| |
| 133 | +| [aws_opensearchserverless_access_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_access_policy) | resource | |
| 134 | +| [aws_opensearchserverless_collection.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_collection) | resource | |
| 135 | +| [aws_opensearchserverless_security_policy.encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_security_policy) | resource | |
| 136 | +| [aws_opensearchserverless_security_policy.network](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_security_policy) | resource | |
| 137 | +| [aws_opensearchserverless_vpc_endpoint.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_vpc_endpoint) | resource | |
| 138 | + |
| 139 | +## Inputs |
| 140 | + |
| 141 | +| Name | Description | Type | Default | Required | |
| 142 | +|------|-------------|------|---------|:--------:| |
| 143 | +| <a name="input_access_policy_description"></a> [access\_policy\_description](#input\_access\_policy\_description) | Description of the access policy. | `string` | `null` | no | |
| 144 | +| <a name="input_access_policy_name"></a> [access\_policy\_name](#input\_access\_policy\_name) | The name of the data access policy. | `string` | `null` | no | |
| 145 | +| <a name="input_access_policy_rules"></a> [access\_policy\_rules](#input\_access\_policy\_rules) | Rules to apply on access policy. | <pre>list(object({<br> type = string<br> permissions = list(string)<br> principals = list(string)<br> indexes = optional(list(string), [])<br> }))</pre> | `[]` | no | |
| 146 | +| <a name="input_create_access_policy"></a> [create\_access\_policy](#input\_create\_access\_policy) | Controls if data access policy should be created. | `bool` | `true` | no | |
| 147 | +| <a name="input_create_encryption_policy"></a> [create\_encryption\_policy](#input\_create\_encryption\_policy) | Controls if encryption policy should be created. | `bool` | `true` | no | |
| 148 | +| <a name="input_create_network_policy"></a> [create\_network\_policy](#input\_create\_network\_policy) | Controls if network policy should be created. | `bool` | `true` | no | |
| 149 | +| <a name="input_description"></a> [description](#input\_description) | Description of the collection. | `string` | `null` | no | |
| 150 | +| <a name="input_encryption_policy_description"></a> [encryption\_policy\_description](#input\_encryption\_policy\_description) | Description of the encryption policy. | `string` | `null` | no | |
| 151 | +| <a name="input_encryption_policy_kms_key_arn"></a> [encryption\_policy\_kms\_key\_arn](#input\_encryption\_policy\_kms\_key\_arn) | MS Customer managed key arn to use in the encryption policy. | `string` | `null` | no | |
| 152 | +| <a name="input_encryption_policy_name"></a> [encryption\_policy\_name](#input\_encryption\_policy\_name) | The name of the encryption policy. | `string` | `null` | no | |
| 153 | +| <a name="input_name"></a> [name](#input\_name) | Name of the collection. | `string` | n/a | yes | |
| 154 | +| <a name="input_network_policy_description"></a> [network\_policy\_description](#input\_network\_policy\_description) | Description of the network policy. | `string` | `null` | no | |
| 155 | +| <a name="input_network_policy_name"></a> [network\_policy\_name](#input\_network\_policy\_name) | The name of the network policy. | `string` | `null` | no | |
| 156 | +| <a name="input_network_policy_type"></a> [network\_policy\_type](#input\_network\_policy\_type) | Type of Network Policy. Supported Values are: AllPublic, AllPrivate, PublicCollectionPrivateDashboard, PrivateCollectionPublicDashboard | `string` | `"AllPublic"` | no | |
| 157 | +| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the collection. If configured with a provider default\_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level. | `map(string)` | `{}` | no | |
| 158 | +| <a name="input_type"></a> [type](#input\_type) | Type of collection. One of SEARCH, TIMESERIES, or VECTORSEARCH. Defaults to TIMESERIES. | `string` | `"TIMESERIES"` | no | |
| 159 | +| <a name="input_use_standby_replicas"></a> [use\_standby\_replicas](#input\_use\_standby\_replicas) | Indicates whether standby replicas should be used for a collection. | `bool` | `true` | no | |
| 160 | +| <a name="input_vpce_name"></a> [vpce\_name](#input\_vpce\_name) | Name of the interface endpoint. | `string` | `null` | no | |
| 161 | +| <a name="input_vpce_security_group_ids"></a> [vpce\_security\_group\_ids](#input\_vpce\_security\_group\_ids) | One or more security groups that define the ports, protocols, and sources for inbound traffic that you are authorizing into your endpoint. Up to 5 security groups can be provided. | `list(string)` | `null` | no | |
| 162 | +| <a name="input_vpce_subnet_ids"></a> [vpce\_subnet\_ids](#input\_vpce\_subnet\_ids) | One or more subnet IDs from which you'll access OpenSearch Serverless. Up to 6 subnets can be provided. | `list(string)` | `[]` | no | |
| 163 | +| <a name="input_vpce_vpc_id"></a> [vpce\_vpc\_id](#input\_vpce\_vpc\_id) | ID of the VPC from which you'll access OpenSearch Serverless. | `string` | `null` | no | |
| 164 | + |
| 165 | +## Outputs |
| 166 | + |
| 167 | +| Name | Description | |
| 168 | +|------|-------------| |
| 169 | +| <a name="output_collection_arn"></a> [collection\_arn](#output\_collection\_arn) | Amazon Resource Name (ARN) of the collection. | |
| 170 | +| <a name="output_collection_endpoint"></a> [collection\_endpoint](#output\_collection\_endpoint) | Collection-specific endpoint used to submit index, search, and data upload requests to an OpenSearch Serverless collection. | |
| 171 | +| <a name="output_collection_id"></a> [collection\_id](#output\_collection\_id) | Unique identifier for the collection. | |
| 172 | +| <a name="output_dashboard_endpoint"></a> [dashboard\_endpoint](#output\_dashboard\_endpoint) | Collection-specific endpoint used to access OpenSearch Dashboards. | |
| 173 | +| <a name="output_encryption_policy_name"></a> [encryption\_policy\_name](#output\_encryption\_policy\_name) | Name of the encryption policy. | |
| 174 | +| <a name="output_encryption_policy_version"></a> [encryption\_policy\_version](#output\_encryption\_policy\_version) | Version of the encryption policy. | |
| 175 | +| <a name="output_kms_key_arn"></a> [kms\_key\_arn](#output\_kms\_key\_arn) | The ARN of the Amazon Web Services KMS key used to encrypt the collection. | |
| 176 | +| <a name="output_network_policy_name"></a> [network\_policy\_name](#output\_network\_policy\_name) | Name of the network policy. | |
| 177 | +| <a name="output_network_policy_version"></a> [network\_policy\_version](#output\_network\_policy\_version) | Version of the network policy. | |
| 178 | +| <a name="output_vpce_id"></a> [vpce\_id](#output\_vpce\_id) | Id of the vpce. | |
| 179 | +| <a name="output_vpce_name"></a> [vpce\_name](#output\_vpce\_name) | Name of the interface endpoint. | |
| 180 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 181 | + |
| 182 | +## License |
| 183 | + |
| 184 | +Apache 2 Licensed. See [LICENSE](https://github.com/fdmsantos/terraform-aws-opensearch-serverlesse/tree/main/LICENSE) for full details. |
0 commit comments