Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Arunsai14 committed Nov 6, 2024
1 parent bf5e171 commit beb39cd
Show file tree
Hide file tree
Showing 14 changed files with 324 additions and 329 deletions.
142 changes: 82 additions & 60 deletions README.md

Large diffs are not rendered by default.

32 changes: 12 additions & 20 deletions example/non-vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ Terraform module example for supporting AWS OpenSearch.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.7 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.4 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.58.0 |
No providers.

## Modules

Expand All @@ -28,27 +24,23 @@ Terraform module example for supporting AWS OpenSearch.

## Resources

| Name | Type |
|------|------|
| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ebs_volume_size"></a> [ebs\_volume\_size](#input\_ebs\_volume\_size) | EBS volumes for data storage in GB | `number` | `10` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment, i.e. dev, stage, prod | `string` | `"poc"` | no |
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | Number of data nodes in the cluster. | `number` | `2` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | ElasticSearch or OpenSearch instance type for data nodes in the cluster | `string` | `"t3.medium.elasticsearch"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of the project, i.e. arc | `string` | `"arc"` | no |
| <a name="input_region"></a> [region](#input\_region) | Name of the region resources will be deployed in | `string` | `"us-east-1"` | no |
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | OpenSearch or Elasticsearch engine version | `string` | `"OpenSearch_1.0"` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `"dev"` | no |
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | Number of instances in the cluster | `number` | `2` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Instance type for the OpenSearch domain | `string` | `"m5.large.search"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of the project, i.e. refarch | `string` | `"arc"` | no |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Project name | `string` | `"sourcefuse"` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS region | `string` | `"us-east-1"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_domain_id"></a> [domain\_id](#output\_domain\_id) | Unique identifier for the OpenSearch domain |
| <a name="output_opensearch_name"></a> [opensearch\_name](#output\_opensearch\_name) | OpenSearch cluster name. |
No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- BEGIN_TF_DOCS -->
Expand Down Expand Up @@ -89,4 +81,4 @@ No resources.
## Outputs

No outputs.
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
26 changes: 5 additions & 21 deletions example/non-vpc/dev.tfvars
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
region = "us-east-2"
engine_version = "OpenSearch_2.15"
instance_type = "m5.large.search"
instance_count = 2

# # Access policy as a Heredoc block
# access_policy = <<POLICY
# {
# "Version": "2012-10-17",
# "Statement": [
# {
# "Effect": "Allow",
# "Principal": {
# "AWS": "*"
# },
# "Action": "es:*",
# "Resource": "arn:aws:es:us-east-2:804295906245:domain/arc-opensearch-domain/*"
# }
# ]
# }
# POLICY
region = "us-east-2"
project_name = "arc"
engine_version = "OpenSearch_2.15"
instance_type = "m5.large.search"
instance_count = 2
21 changes: 8 additions & 13 deletions example/non-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
## defaults
################################################################################
terraform {
required_version = "~> 1.7"
required_version = ">= 1.5.0"

required_providers {
aws = {
version = ">= 5.64"
source = "hashicorp/aws"
version = "~> 5.0"
}
}

}


provider "aws" {
region = var.region
}
Expand All @@ -34,20 +34,15 @@ module "tags" {
module "opensearch" {
source = "../.."

region = var.region
domain_name = "${var.project_name}-${var.environment}-opensearch"
namespace = var.namespace
environment = var.environment

name = "${var.project_name}-${var.environment}-opensearch"
engine_version = var.engine_version
instance_type = var.instance_type
instance_count = var.instance_count
enable_vpc_options = false
enable_encrypt_at_rest = true
auto_software_update_enabled = false
enable_domain_endpoint_options = true
enable_domain_endpoint_options = false
advanced_security_enabled = true
# access_policies = var.access_policy
enable_zone_awareness = false
tags = module.tags.tags
}



14 changes: 7 additions & 7 deletions example/non-vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ variable "environment" {
description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'"
}

variable "namespace" {
type = string
description = "Namespace of the project, i.e. refarch"
default = "arc"
}


variable "engine_version" {
description = "OpenSearch or Elasticsearch engine version"
Expand All @@ -26,17 +32,11 @@ variable "engine_version" {
variable "instance_type" {
description = "Instance type for the OpenSearch domain"
type = string
default = "m4.large.search"
default = "m5.large.search"
}

variable "instance_count" {
description = "Number of instances in the cluster"
type = number
default = 2
}


# variable "access_policy" {
# description = "Access policy for the OpenSearch domain"
# type = string
# }
29 changes: 12 additions & 17 deletions example/vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,26 @@ Terraform module example for supporting AWS OpenSearch.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.7 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.4 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.74.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_opensearch"></a> [opensearch](#module\_opensearch) | sourcefuse/arc-opensearch/aws | n/a |
| <a name="module_opensearch"></a> [opensearch](#module\_opensearch) | ../.. | n/a |
| <a name="module_tags"></a> [tags](#module\_tags) | sourcefuse/arc-tags/aws | 1.2.6 |

## Resources

| Name | Type |
|------|------|
| [aws_caller_identity.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_subnet.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |
| [aws_subnets.private](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnets) | data source |
| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
Expand All @@ -39,21 +36,19 @@ Terraform module example for supporting AWS OpenSearch.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ebs_volume_size"></a> [ebs\_volume\_size](#input\_ebs\_volume\_size) | EBS volumes for data storage in GB | `number` | `10` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment, i.e. dev, stage, prod | `string` | `"poc"` | no |
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | Number of data nodes in the cluster. | `number` | `2` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | ElasticSearch or OpenSearch instance type for data nodes in the cluster | `string` | `"t3.medium.elasticsearch"` | no |
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | OpenSearch or Elasticsearch engine version | `string` | `"OpenSearch_1.0"` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `"dev"` | no |
| <a name="input_instance_count"></a> [instance\_count](#input\_instance\_count) | Number of instances in the cluster | `number` | `2` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Instance type for the OpenSearch domain | `string` | `"m5.large.search"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace of the project, i.e. arc | `string` | `"arc"` | no |
| <a name="input_region"></a> [region](#input\_region) | Name of the region resources will be deployed in | `string` | `"us-east-1"` | no |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Project name | `string` | `"sourcefuse"` | no |
| <a name="input_region"></a> [region](#input\_region) | AWS region | `string` | `"us-east-1"` | no |
| <a name="input_subnet_names"></a> [subnet\_names](#input\_subnet\_names) | List of subnet names to lookup | `list(string)` | <pre>[<br> "arc-poc-private-subnet-private-us-east-1a",<br> "arc-poc-private-subnet-private-us-east-1b"<br>]</pre> | no |
| <a name="input_vpc_name"></a> [vpc\_name](#input\_vpc\_name) | Name of the VPC to add the resources | `string` | `"arc-poc-vpc"` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_domain_id"></a> [domain\_id](#output\_domain\_id) | Unique identifier for the OpenSearch domain |
| <a name="output_opensearch_name"></a> [opensearch\_name](#output\_opensearch\_name) | OpenSearch cluster name. |
No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- BEGIN_TF_DOCS -->
Expand Down Expand Up @@ -107,4 +102,4 @@ Terraform module example for supporting AWS OpenSearch.
## Outputs

No outputs.
<!-- END_TF_DOCS -->
<!-- END_TF_DOCS -->
29 changes: 29 additions & 0 deletions example/vpc/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
data "aws_vpc" "default" {
filter {
name = "tag:Name"
values = var.vpc_name != null ? [var.vpc_name] : ["${var.namespace}-${var.environment}-vpc"]
}
}

# network
data "aws_subnets" "private" {
filter {
name = "tag:Name"

## try the created subnets from the upstream network module, or override with custom names
values = length(var.subnet_names) > 0 ? var.subnet_names : [
"${var.namespace}-${var.environment}-private-subnet-private-${var.region}a",
"${var.namespace}-${var.environment}-private-subnet-private-${var.region}b"
]
}

filter {
name = "vpc-id"
values = [data.aws_vpc.default.id]
}
}

data "aws_subnet" "private" {
for_each = toset(data.aws_subnets.private.ids)
id = each.value
}
43 changes: 1 addition & 42 deletions example/vpc/dev.tfvars
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
region = "us-east-2"
domain_name = "arc-opensearch-domain"
project_name = "arc"
engine_version = "OpenSearch_2.15"
instance_type = "m5.large.search"
instance_count = 2

# Access policy as a Heredoc block
access_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "es:*",
"Resource": "arn:aws:es:us-east-2:804295906245:domain/arc-opensearch-domain/*"
}
]
}
POLICY

ingress_rules = [
{
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
},
{
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
]

egress_rules = [
{
from_port = 0
to_port = 0
protocol = "-1" # "-1" allows all protocols
cidr_blocks = ["0.0.0.0/0"]
}
]
25 changes: 24 additions & 1 deletion example/vpc/locals.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
locals {
private_subnet_ids = [for s in data.aws_subnet.private : s.id]
private_subnet_azs = [for s in data.aws_subnet.private : s.availability_zone]

ingress_rules = [
{
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = [data.aws_vpc.default.cidr_block]
},
{
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = [data.aws_vpc.default.cidr_block]
}
]

egress_rules = [
{
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
]
}
Loading

0 comments on commit beb39cd

Please sign in to comment.