Skip to content

Commit

Permalink
feat(provider): migrate to dedicated OpenSearch provider (#59)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All `elasticsearch_*` resources have been renamed to `opensearch_*`.
  • Loading branch information
steveteuber authored Dec 5, 2023
1 parent c58cef1 commit 0388438
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 55 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Here is a working example of using this Terraform module:
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.12.0 |
| <a name="requirement_elasticsearch"></a> [elasticsearch](#requirement\_elasticsearch) | >= 2.0.0 |
| <a name="requirement_opensearch"></a> [opensearch](#requirement\_opensearch) | >= 2.0.0 |

## Modules

Expand All @@ -94,14 +94,14 @@ Here is a working example of using this Terraform module:
| [aws_elasticsearch_domain_saml_options.opensearch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticsearch_domain_saml_options) | resource |
| [aws_iam_service_linked_role.es](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_service_linked_role) | resource |
| [aws_route53_record.opensearch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [elasticsearch_composable_index_template.composable_index_template](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/composable_index_template) | resource |
| [elasticsearch_index.index](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/index) | resource |
| [elasticsearch_index_template.index_template](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/index_template) | resource |
| [elasticsearch_opensearch_ism_policy.ism_policy](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_ism_policy) | resource |
| [elasticsearch_opensearch_role.role](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_role) | resource |
| [elasticsearch_opensearch_roles_mapping.master_user_arn](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_roles_mapping) | resource |
| [elasticsearch_opensearch_roles_mapping.master_user_name](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_roles_mapping) | resource |
| [elasticsearch_opensearch_roles_mapping.role_mapping](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_roles_mapping) | resource |
| [opensearch_composable_index_template.composable_index_template](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/composable_index_template) | resource |
| [opensearch_index.index](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/index) | resource |
| [opensearch_index_template.index_template](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/index_template) | resource |
| [opensearch_ism_policy.ism_policy](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/ism_policy) | resource |
| [opensearch_role.role](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/role) | resource |
| [opensearch_roles_mapping.master_user_arn](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/roles_mapping) | resource |
| [opensearch_roles_mapping.master_user_name](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/roles_mapping) | resource |
| [opensearch_roles_mapping.role_mapping](https://registry.terraform.io/providers/opensearch-project/opensearch/latest/docs/resources/roles_mapping) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.access_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.allow_logging](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
Expand All @@ -124,7 +124,7 @@ Here is a working example of using this Terraform module:
| <a name="input_cluster_domain"></a> [cluster\_domain](#input\_cluster\_domain) | The hosted zone name of the OpenSearch cluster. | `string` | n/a | yes |
| <a name="input_cluster_domain_private"></a> [cluster\_domain\_private](#input\_cluster\_domain\_private) | Indicates whether to create records in a private (true) or public (false) zone | `bool` | `false` | no |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the OpenSearch cluster. | `string` | `"opensearch"` | no |
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | The version of OpenSearch to deploy. | `string` | `"1.0"` | no |
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | The version of OpenSearch to deploy. | `string` | `"2.11"` | no |
| <a name="input_cognito_options"></a> [cognito\_options](#input\_cognito\_options) | Configuration block for authenticating Kibana with Cognito. | `map(string)` | `{}` | no |
| <a name="input_cognito_options_enabled"></a> [cognito\_options\_enabled](#input\_cognito\_options\_enabled) | Whether Amazon Cognito authentication with Kibana is enabled or not. | `bool` | `false` | no |
| <a name="input_composable_index_template_files"></a> [composable\_index\_template\_files](#input\_composable\_index\_template\_files) | A set of all composable index template files to create. | `set(string)` | `[]` | no |
Expand Down
6 changes: 3 additions & 3 deletions composable_index_template.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "elasticsearch_composable_index_template" "composable_index_template" {
resource "opensearch_composable_index_template" "composable_index_template" {
for_each = local.composable_index_templates

name = each.key
body = jsonencode(each.value)

depends_on = [
elasticsearch_opensearch_roles_mapping.master_user_arn,
elasticsearch_opensearch_roles_mapping.master_user_name,
opensearch_roles_mapping.master_user_arn,
opensearch_roles_mapping.master_user_name,
aws_route53_record.opensearch
]
}
29 changes: 15 additions & 14 deletions examples/complete/index-templates/example-template.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
---
index_patterns:
- example-*
settings:
index:
number_of_shards: "2"
number_of_replicas: "1"
refresh_interval: 30s
mappings:
_source:
enabled: false
properties:
created_at:
format: EEE MMM dd HH:mm:ss Z YYYY
type: date
host_name:
type: keyword
template:
settings:
index:
number_of_shards: "2"
number_of_replicas: "1"
refresh_interval: 30s
mappings:
_source:
enabled: false
properties:
created_at:
format: EEE MMM dd HH:mm:ss Z YYYY
type: date
host_name:
type: keyword
4 changes: 2 additions & 2 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data "http" "saml_metadata" {
url = var.saml_metadata_url
}

provider "elasticsearch" {
provider "opensearch" {
url = module.opensearch.cluster_endpoint
aws_region = data.aws_region.current.name
healthcheck = false
Expand All @@ -23,7 +23,7 @@ module "opensearch" {

cluster_name = var.cluster_name
cluster_domain = var.cluster_domain
cluster_version = "1.3"
cluster_version = "2.11"

saml_entity_id = var.saml_entity_id
saml_metadata_content = data.http.saml_metadata.body
Expand Down
4 changes: 2 additions & 2 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.0"
}
elasticsearch = {
source = "phillbaker/elasticsearch"
opensearch = {
source = "opensearch-project/opensearch"
version = ">= 2.0"
}
http = {
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ provider "aws" {

data "aws_region" "current" {}

provider "elasticsearch" {
provider "opensearch" {
url = module.opensearch.cluster_endpoint
aws_region = data.aws_region.current.name
healthcheck = false
Expand All @@ -19,7 +19,7 @@ module "opensearch" {

cluster_name = var.cluster_name
cluster_domain = var.cluster_domain
cluster_version = "1.3"
cluster_version = "2.11"

saml_enabled = false
}
4 changes: 2 additions & 2 deletions examples/minimal/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.0"
}
elasticsearch = {
source = "phillbaker/elasticsearch"
opensearch = {
source = "opensearch-project/opensearch"
version = ">= 2.0"
}
http = {
Expand Down
8 changes: 4 additions & 4 deletions index.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "elasticsearch_index" "index" {
resource "opensearch_index" "index" {
for_each = local.indices

name = each.key
Expand All @@ -10,9 +10,9 @@ resource "elasticsearch_index" "index" {
force_destroy = true

depends_on = [
elasticsearch_index_template.index_template,
elasticsearch_composable_index_template.composable_index_template,
elasticsearch_opensearch_ism_policy.ism_policy,
opensearch_index_template.index_template,
opensearch_composable_index_template.composable_index_template,
opensearch_ism_policy.ism_policy,
aws_route53_record.opensearch
]

Expand Down
6 changes: 3 additions & 3 deletions index_template.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "elasticsearch_index_template" "index_template" {
resource "opensearch_index_template" "index_template" {
for_each = local.index_templates

name = each.key
body = jsonencode(each.value)

depends_on = [
elasticsearch_opensearch_roles_mapping.master_user_arn,
elasticsearch_opensearch_roles_mapping.master_user_name,
opensearch_roles_mapping.master_user_arn,
opensearch_roles_mapping.master_user_name,
aws_route53_record.opensearch
]
}
6 changes: 3 additions & 3 deletions ism_policy.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "elasticsearch_opensearch_ism_policy" "ism_policy" {
resource "opensearch_ism_policy" "ism_policy" {
for_each = local.ism_policies

policy_id = each.key
body = jsonencode({ "policy" = each.value })

depends_on = [
elasticsearch_opensearch_roles_mapping.master_user_arn,
elasticsearch_opensearch_roles_mapping.master_user_name,
opensearch_roles_mapping.master_user_arn,
opensearch_roles_mapping.master_user_name,
aws_route53_record.opensearch
]
}
8 changes: 4 additions & 4 deletions role_mapping.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "elasticsearch_opensearch_roles_mapping" "role_mapping" {
resource "opensearch_roles_mapping" "role_mapping" {
for_each = {
for key, value in local.role_mappings :
key => value if !contains(["all_access", "security_manager"], key)
Expand All @@ -11,12 +11,12 @@ resource "elasticsearch_opensearch_roles_mapping" "role_mapping" {
users = try(each.value.users, [])

depends_on = [
elasticsearch_opensearch_role.role,
opensearch_role.role,
aws_route53_record.opensearch
]
}

resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
resource "opensearch_roles_mapping" "master_user_arn" {
for_each = var.advanced_security_options_internal_user_database_enabled ? {} : {
for key in ["all_access", "security_manager"] :
key => try(local.role_mappings[key], {})
Expand All @@ -31,7 +31,7 @@ resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
depends_on = [aws_route53_record.opensearch]
}

resource "elasticsearch_opensearch_roles_mapping" "master_user_name" {
resource "opensearch_roles_mapping" "master_user_name" {
for_each = var.advanced_security_options_internal_user_database_enabled ? {
for key in ["all_access", "security_manager"] :
key => try(local.role_mappings[key], {})
Expand Down
6 changes: 3 additions & 3 deletions roles.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "elasticsearch_opensearch_role" "role" {
resource "opensearch_role" "role" {
for_each = local.roles

role_name = each.key
Expand All @@ -23,8 +23,8 @@ resource "elasticsearch_opensearch_role" "role" {
}

depends_on = [
elasticsearch_opensearch_roles_mapping.master_user_arn,
elasticsearch_opensearch_roles_mapping.master_user_name,
opensearch_roles_mapping.master_user_arn,
opensearch_roles_mapping.master_user_name,
aws_route53_record.opensearch
]
}
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "cluster_name" {
variable "cluster_version" {
description = "The version of OpenSearch to deploy."
type = string
default = "1.0"
default = "2.11"
}

variable "cluster_domain" {
Expand Down
4 changes: 2 additions & 2 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.12.0"
}
elasticsearch = {
source = "phillbaker/elasticsearch"
opensearch = {
source = "opensearch-project/opensearch"
version = ">= 2.0.0"
}
}
Expand Down

0 comments on commit 0388438

Please sign in to comment.