Skip to content

Commit

Permalink
chore(deps): bump phillbaker/elasticsearch from 1.6.0 to 2.0.0 (#13)
Browse files Browse the repository at this point in the history
Bump phillbaker/elasticsearch version from 1.6.0 to 2.0.0

BREAKING CHANGE: All deprecated `elasticsearch_opendistro_*` resources have been renamed to `elasticsearch_opensearch_*`.
After upgrading the module version you have to import/delete all `elasticsearch_*` resources:
```
for OLD_NAME in $(terraform state list | grep \.elasticsearch_opendistro_); do
  NEW_NAME="${OLD_NAME/.elasticsearch_opendistro_/.elasticsearch_opensearch_}"
  IDENTIFIER="$(perl -ne '/\["(.+)"\]/ && print "$1\n";' <<< "${OLD_NAME}")"

  terraform import "${NEW_NAME}" "${IDENTIFIER}" && terraform state rm "${OLD_NAME}"
done
```
  • Loading branch information
steveteuber authored May 12, 2022
1 parent 651553d commit 2c4422d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 28 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ data "http" "saml_metadata" {
}
provider "elasticsearch" {
url = "https://${local.cluster_name}.${local.cluster_domain}"
url = module.opensearch.cluster_endpoint
aws_region = data.aws_region.current.name
elasticsearch_version = "7.10.2"
healthcheck = false
}
Expand All @@ -48,7 +47,7 @@ module "opensearch" {
cluster_name = local.cluster_name
cluster_domain = local.cluster_domain
cluster_version = "1.0"
cluster_version = "1.2"
saml_entity_id = local.saml_entity_id
saml_metadata_content = data.http.saml_metadata.body
Expand All @@ -75,7 +74,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) | >= 3.65 |
| <a name="requirement_elasticsearch"></a> [elasticsearch](#requirement\_elasticsearch) | >= 1.6.0 |
| <a name="requirement_elasticsearch"></a> [elasticsearch](#requirement\_elasticsearch) | >= 2.0.0 |

## Modules

Expand All @@ -93,10 +92,10 @@ Here is a working example of using this Terraform module:
| [aws_route53_record.opensearch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | 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_opendistro_ism_policy.ism_policy](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opendistro_ism_policy) | resource |
| [elasticsearch_opendistro_role.role](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opendistro_role) | resource |
| [elasticsearch_opendistro_roles_mapping.master_user_arn](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opendistro_roles_mapping) | resource |
| [elasticsearch_opendistro_roles_mapping.role_mapping](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opendistro_roles_mapping) | 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.role_mapping](https://registry.terraform.io/providers/phillbaker/elasticsearch/latest/docs/resources/opensearch_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_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
Expand Down Expand Up @@ -147,7 +146,7 @@ Here is a working example of using this Terraform module:
| <a name="output_cluster_endpoint"></a> [cluster\_endpoint](#output\_cluster\_endpoint) | The endpoint URL of the OpenSearch cluster. |
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | The name of the OpenSearch cluster. |
| <a name="output_cluster_version"></a> [cluster\_version](#output\_cluster\_version) | The version of the OpenSearch cluster. |
| <a name="output_kibana_endpoint"></a> [kibana\_endpoint](#output\_kibana\_endpoint) | The endpoint URL of Kibana. |
| <a name="output_kibana_endpoint"></a> [kibana\_endpoint](#output\_kibana\_endpoint) | The endpoint URL of the OpenSearch dashboards. |
<!-- END_TF_DOCS -->

## License
Expand Down
9 changes: 4 additions & 5 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ data "http" "saml_metadata" {
}

provider "elasticsearch" {
url = "https://${var.cluster_name}.${var.cluster_domain}"
aws_region = data.aws_region.current.name
elasticsearch_version = "7.10.2"
healthcheck = false
url = module.opensearch.cluster_endpoint
aws_region = data.aws_region.current.name
healthcheck = false
}

module "opensearch" {
source = "../../"

cluster_name = var.cluster_name
cluster_domain = var.cluster_domain
cluster_version = "1.0"
cluster_version = "1.2"

saml_entity_id = var.saml_entity_id
saml_metadata_content = data.http.saml_metadata.body
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
}
elasticsearch = {
source = "phillbaker/elasticsearch"
version = "2.0.0-beta.2"
version = "2.0.0"
}
}
}
2 changes: 1 addition & 1 deletion index.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "elasticsearch_index" "index" {

depends_on = [
elasticsearch_index_template.index_template,
elasticsearch_opendistro_ism_policy.ism_policy,
elasticsearch_opensearch_ism_policy.ism_policy,
]

lifecycle {
Expand Down
2 changes: 1 addition & 1 deletion index_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ resource "elasticsearch_index_template" "index_template" {
name = each.key
body = jsonencode(each.value)

depends_on = [elasticsearch_opendistro_roles_mapping.master_user_arn]
depends_on = [elasticsearch_opensearch_roles_mapping.master_user_arn]
}
4 changes: 2 additions & 2 deletions ism_policy.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "elasticsearch_opendistro_ism_policy" "ism_policy" {
resource "elasticsearch_opensearch_ism_policy" "ism_policy" {
for_each = local.ism_policies

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

depends_on = [elasticsearch_opendistro_roles_mapping.master_user_arn]
depends_on = [elasticsearch_opensearch_roles_mapping.master_user_arn]
}
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ output "cluster_version" {

output "cluster_endpoint" {
description = "The endpoint URL of the OpenSearch cluster."
value = "https://${aws_route53_record.opensearch.fqdn}"
value = "https://${aws_elasticsearch_domain.opensearch.domain_endpoint_options[0].custom_endpoint}"
}

output "kibana_endpoint" {
description = "The endpoint URL of Kibana."
value = "https://${aws_route53_record.opensearch.fqdn}/_dashboards/"
description = "The endpoint URL of the OpenSearch dashboards."
value = "https://${aws_elasticsearch_domain.opensearch.domain_endpoint_options[0].custom_endpoint}/_dashboards/"
}
6 changes: 3 additions & 3 deletions role_mapping.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "elasticsearch_opendistro_roles_mapping" "role_mapping" {
resource "elasticsearch_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 @@ -10,10 +10,10 @@ resource "elasticsearch_opendistro_roles_mapping" "role_mapping" {
hosts = try(each.value.hosts, [])
users = try(each.value.users, [])

depends_on = [elasticsearch_opendistro_role.role]
depends_on = [elasticsearch_opensearch_role.role]
}

resource "elasticsearch_opendistro_roles_mapping" "master_user_arn" {
resource "elasticsearch_opensearch_roles_mapping" "master_user_arn" {
for_each = {
for key in ["all_access", "security_manager"] :
key => try(local.role_mappings[key], {})
Expand Down
4 changes: 2 additions & 2 deletions roles.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "elasticsearch_opendistro_role" "role" {
resource "elasticsearch_opensearch_role" "role" {
for_each = local.roles

role_name = each.key
Expand All @@ -22,6 +22,6 @@ resource "elasticsearch_opendistro_role" "role" {
}
}

depends_on = [elasticsearch_opendistro_roles_mapping.master_user_arn]
depends_on = [elasticsearch_opensearch_roles_mapping.master_user_arn]
}

2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
}
elasticsearch = {
source = "phillbaker/elasticsearch"
version = ">= 1.6.0"
version = ">= 2.0.0"
}
}
}

0 comments on commit 2c4422d

Please sign in to comment.