Skip to content

Commit 253fea4

Browse files
feat: serverless collection submodule
1 parent 35ae6b2 commit 253fea4

File tree

7 files changed

+265
-0
lines changed

7 files changed

+265
-0
lines changed

modules/collection/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Requirements
2+
3+
| Name | Version |
4+
|------|---------|
5+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.4 |
6+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.15 |
7+
8+
## Providers
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.15 |
13+
14+
## Modules
15+
16+
| Name | Source | Version |
17+
|------|--------|---------|
18+
| <a name="module_aoss"></a> [aoss](#module\_aoss) | terraform-aws-modules/opensearch/aws//modules/collection | ~> 1.5.0 |
19+
20+
## Resources
21+
22+
| Name | Type |
23+
|------|------|
24+
| [aws_opensearchserverless_vpc_endpoint.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/opensearchserverless_vpc_endpoint) | resource |
25+
26+
## Inputs
27+
28+
| Name | Description | Type | Default | Required |
29+
|------|-------------|------|---------|:--------:|
30+
| <a name="input_access_policy"></a> [access\_policy](#input\_access\_policy) | Access policy to apply to the collection | `any` | `{}` | no |
31+
| <a name="input_access_policy_collection_permissions"></a> [access\_policy\_collection\_permissions](#input\_access\_policy\_collection\_permissions) | Access policy permissions for the collection | `list(string)` | <pre>[<br/> "aoss:*"<br/>]</pre> | no |
32+
| <a name="input_access_policy_index_permissions"></a> [access\_policy\_index\_permissions](#input\_access\_policy\_index\_permissions) | Access policy permissions for the collection index | `list(string)` | <pre>[<br/> "aoss:*"<br/>]</pre> | no |
33+
| <a name="input_access_policy_principals"></a> [access\_policy\_principals](#input\_access\_policy\_principals) | Access policy principals | `list(string)` | `[]` | no |
34+
| <a name="input_allow_public_access"></a> [allow\_public\_access](#input\_allow\_public\_access) | Whether public access is to be given | `bool` | `false` | no |
35+
| <a name="input_collection_type"></a> [collection\_type](#input\_collection\_type) | Type of collection. Possible values are `SEARCH`, `TIMESERIES` or `VECTORSEARCH` | `string` | n/a | yes |
36+
| <a name="input_create_access_policy"></a> [create\_access\_policy](#input\_create\_access\_policy) | Determines whether an access policy will be created | `bool` | `true` | no |
37+
| <a name="input_create_encryption_policy"></a> [create\_encryption\_policy](#input\_create\_encryption\_policy) | Determines whether an encryption policy will be created | `bool` | `true` | no |
38+
| <a name="input_create_lifecycle_policy"></a> [create\_lifecycle\_policy](#input\_create\_lifecycle\_policy) | Determines whether an lifecycle policy will be created | `bool` | `false` | no |
39+
| <a name="input_create_network_policy"></a> [create\_network\_policy](#input\_create\_network\_policy) | Determines whether an network policy will be created | `bool` | `true` | no |
40+
| <a name="input_create_vpc_endpoint"></a> [create\_vpc\_endpoint](#input\_create\_vpc\_endpoint) | Whether a VPC endpoint is to be created for the collection | `bool` | `false` | no |
41+
| <a name="input_description"></a> [description](#input\_description) | Description for the OpenSearch Serverless collection. | `string` | n/a | yes |
42+
| <a name="input_encryption_kms_arn"></a> [encryption\_kms\_arn](#input\_encryption\_kms\_arn) | Encryption policy to apply to the collection | `string` | `null` | no |
43+
| <a name="input_lifecycle_policy_min_index_retention"></a> [lifecycle\_policy\_min\_index\_retention](#input\_lifecycle\_policy\_min\_index\_retention) | The minimum period, in days (d) or hours (h), to retain the document in the index. The lower bound is `24h` and the upper bound is `3650d` | `string` | `null` | no |
44+
| <a name="input_lifecycle_policy_no_min_index_retention"></a> [lifecycle\_policy\_no\_min\_index\_retention](#input\_lifecycle\_policy\_no\_min\_index\_retention) | If true, OpenSearch Serverless retains documents indefinitely | `bool` | `null` | no |
45+
| <a name="input_name"></a> [name](#input\_name) | Name of the OpenSearch Serverless collection. | `string` | n/a | yes |
46+
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | Security group IDs attached to the VPC endpoint. Needed only if `create_vpc_endpoint` is true | `list(string)` | `[]` | no |
47+
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | Subnet IDs in which the VPC endpoint is created. Needed only if `create_vpc_endpoint` is true | `list(string)` | `[]` | no |
48+
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A mapping of tags to assign to the resources | `map(string)` | `{}` | no |
49+
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC ID to deploy the cluster into. Need only if the VPC endpoint created. | `string` | `""` | no |
50+
51+
## Outputs
52+
53+
| Name | Description |
54+
|------|-------------|
55+
| <a name="output_arn"></a> [arn](#output\_arn) | ARN of the Opensearch Collection |
56+
| <a name="output_dashboard_endpoint"></a> [dashboard\_endpoint](#output\_dashboard\_endpoint) | Collection-specific endpoint used to access OpenSearch Dashboards |
57+
| <a name="output_endpoint"></a> [endpoint](#output\_endpoint) | Collection-specific endpoint used to submit index, search, and data upload requests to an OpenSearch Serverless collection |
58+
| <a name="output_id"></a> [id](#output\_id) | ID of the Opensearch Collection |
59+
| <a name="output_vpc_endpoint_id"></a> [vpc\_endpoint\_id](#output\_vpc\_endpoint\_id) | VPC endpoint ID for the OpenSearch collection |

modules/collection/endpoint.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_opensearchserverless_vpc_endpoint" "this" {
2+
count = var.create_vpc_endpoint ? 1 : 0
3+
4+
name = "${var.name}-vpce"
5+
vpc_id = var.vpc_id
6+
subnet_ids = var.subnet_ids
7+
security_group_ids = var.security_group_ids
8+
}

modules/collection/locals.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
locals {
2+
encryption_policy = {
3+
"Rules" = [
4+
{
5+
"Resource" = [
6+
"collection/${var.name}"
7+
],
8+
"ResourceType" = "collection"
9+
}
10+
],
11+
"AWSOwnedKey" = var.encryption_kms_arn == null ? true : false
12+
"KmsARN" = var.encryption_kms_arn
13+
}
14+
15+
network_policy = {
16+
AllowFromPublic = var.allow_public_access
17+
SourceVPCEs = var.create_vpc_endpoint ? [aws_opensearchserverless_vpc_endpoint.this[0].id] : []
18+
}
19+
}

modules/collection/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module "aoss" {
2+
source = "terraform-aws-modules/opensearch/aws//modules/collection"
3+
version = "~> 1.5.0"
4+
5+
name = var.name
6+
description = var.description
7+
type = var.collection_type
8+
9+
create_access_policy = var.create_access_policy
10+
access_policy_collection_permissions = var.access_policy_collection_permissions
11+
access_policy_index_permissions = var.access_policy_index_permissions
12+
access_policy_principals = var.access_policy_principals
13+
access_policy = var.access_policy
14+
15+
create_network_policy = var.create_network_policy
16+
network_policy = local.network_policy
17+
18+
create_encryption_policy = var.create_encryption_policy
19+
encryption_policy = local.encryption_policy
20+
21+
create_lifecycle_policy = var.create_lifecycle_policy
22+
lifecycle_policy_min_index_retention = var.lifecycle_policy_min_index_retention
23+
lifecycle_policy_no_min_index_retention = var.lifecycle_policy_no_min_index_retention
24+
25+
tags = var.tags
26+
}

modules/collection/outputs.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
output "id" {
2+
description = "ID of the Opensearch Collection"
3+
value = module.aoss.id
4+
}
5+
6+
output "arn" {
7+
description = "ARN of the Opensearch Collection"
8+
value = module.aoss.arn
9+
}
10+
11+
output "endpoint" {
12+
description = "Collection-specific endpoint used to submit index, search, and data upload requests to an OpenSearch Serverless collection"
13+
value = module.aoss.endpoint
14+
}
15+
16+
output "dashboard_endpoint" {
17+
description = "Collection-specific endpoint used to access OpenSearch Dashboards"
18+
value = module.aoss.dashboard_endpoint
19+
}
20+
21+
output "vpc_endpoint_id" {
22+
description = "VPC endpoint ID for the OpenSearch collection"
23+
value = var.create_vpc_endpoint ? aws_opensearchserverless_vpc_endpoint.this[0].id : null
24+
}

modules/collection/variables.tf

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
variable "name" {
2+
type = string
3+
description = "Name of the OpenSearch Serverless collection."
4+
}
5+
6+
variable "collection_type" {
7+
type = string
8+
description = "Type of collection. Possible values are `SEARCH`, `TIMESERIES` or `VECTORSEARCH`"
9+
}
10+
11+
variable "description" {
12+
type = string
13+
description = "Description for the OpenSearch Serverless collection."
14+
}
15+
16+
variable "allow_public_access" {
17+
type = bool
18+
description = "Whether public access is to be given"
19+
default = false
20+
}
21+
22+
variable "vpc_id" {
23+
description = "VPC ID to deploy the cluster into. Need only if the VPC endpoint created."
24+
type = string
25+
default = ""
26+
}
27+
28+
variable "subnet_ids" {
29+
description = "Subnet IDs in which the VPC endpoint is created. Needed only if `create_vpc_endpoint` is true"
30+
type = list(string)
31+
default = []
32+
}
33+
34+
variable "security_group_ids" {
35+
description = "Security group IDs attached to the VPC endpoint. Needed only if `create_vpc_endpoint` is true"
36+
type = list(string)
37+
default = []
38+
}
39+
40+
variable "create_vpc_endpoint" {
41+
type = bool
42+
description = "Whether a VPC endpoint is to be created for the collection"
43+
default = false
44+
}
45+
46+
variable "tags" {
47+
description = "(Optional) A mapping of tags to assign to the resources"
48+
type = map(string)
49+
default = {}
50+
}
51+
52+
###########
53+
# Policies
54+
###########
55+
variable "create_encryption_policy" {
56+
description = "Determines whether an encryption policy will be created"
57+
type = bool
58+
default = true
59+
}
60+
61+
variable "encryption_kms_arn" {
62+
description = "Encryption policy to apply to the collection"
63+
type = string
64+
default = null
65+
}
66+
67+
variable "create_network_policy" {
68+
description = "Determines whether an network policy will be created"
69+
type = bool
70+
default = true
71+
}
72+
73+
variable "create_access_policy" {
74+
description = "Determines whether an access policy will be created"
75+
type = bool
76+
default = true
77+
}
78+
79+
variable "access_policy_index_permissions" {
80+
description = "Access policy permissions for the collection index"
81+
type = list(string)
82+
default = ["aoss:*"]
83+
}
84+
85+
variable "access_policy_collection_permissions" {
86+
description = "Access policy permissions for the collection"
87+
type = list(string)
88+
default = ["aoss:*"]
89+
}
90+
91+
variable "access_policy_principals" {
92+
description = "Access policy principals"
93+
type = list(string)
94+
default = []
95+
}
96+
97+
variable "access_policy" {
98+
description = "Access policy to apply to the collection"
99+
type = any
100+
default = {}
101+
}
102+
103+
variable "create_lifecycle_policy" {
104+
description = "Determines whether an lifecycle policy will be created"
105+
type = bool
106+
default = false
107+
}
108+
109+
variable "lifecycle_policy_min_index_retention" {
110+
description = "The minimum period, in days (d) or hours (h), to retain the document in the index. The lower bound is `24h` and the upper bound is `3650d`"
111+
type = string
112+
default = null
113+
}
114+
115+
variable "lifecycle_policy_no_min_index_retention" {
116+
description = "If true, OpenSearch Serverless retains documents indefinitely"
117+
type = bool
118+
default = null
119+
}

modules/collection/versions.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.4"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.15"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)