From 4a76b9ce927ef2392439ca6de5e55c5938a7eb15 Mon Sep 17 00:00:00 2001 From: changhyuni Date: Wed, 8 Mar 2023 00:24:59 +0900 Subject: [PATCH 1/5] Fix opensearch kibana endpoint --- internal/service/opensearch/domain.go | 10 +++++----- internal/service/opensearch/domain_data_source.go | 8 ++++---- internal/service/opensearch/domain_test.go | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/opensearch/domain.go b/internal/service/opensearch/domain.go index 2ab5107f15d..eae5c307687 100644 --- a/internal/service/opensearch/domain.go +++ b/internal/service/opensearch/domain.go @@ -449,7 +449,7 @@ func ResourceDomain() *schema.Resource { Optional: true, Default: "OpenSearch_1.1", }, - "kibana_endpoint": { + "dashboard_endpoint": { Type: schema.TypeString, Computed: true, }, @@ -848,14 +848,14 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf endpoints := flex.PointersMapToStringList(ds.Endpoints) d.Set("endpoint", endpoints["vpc"]) - d.Set("kibana_endpoint", getKibanaEndpoint(d)) + d.Set("dashboard_endpoint", getDashboardEndpoint(d)) if ds.Endpoint != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain in VPC expected to have null Endpoint value", d.Id()) } } else { if ds.Endpoint != nil { d.Set("endpoint", ds.Endpoint) - d.Set("kibana_endpoint", getKibanaEndpoint(d)) + d.Set("dashboard_endpoint", getDashboardEndpoint(d)) } if ds.Endpoints != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain not in VPC expected to have null Endpoints value", d.Id()) @@ -1097,8 +1097,8 @@ func suppressEquivalentKMSKeyIDs(k, old, new string, d *schema.ResourceData) boo return strings.Contains(old, new) } -func getKibanaEndpoint(d *schema.ResourceData) string { - return d.Get("endpoint").(string) + "/_plugin/kibana/" +func getDashboardEndpoint(d *schema.ResourceData) string { + return d.Get("endpoint").(string) + "/_dashboards" } func isDedicatedMasterDisabled(k, old, new string, d *schema.ResourceData) bool { diff --git a/internal/service/opensearch/domain_data_source.go b/internal/service/opensearch/domain_data_source.go index 2018f3c4172..56e277d19e7 100644 --- a/internal/service/opensearch/domain_data_source.go +++ b/internal/service/opensearch/domain_data_source.go @@ -109,7 +109,7 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "kibana_endpoint": { + "dashboard_endpoint": { Type: schema.TypeString, Computed: true, }, @@ -386,7 +386,7 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("arn", ds.ARN) d.Set("domain_id", ds.DomainId) d.Set("endpoint", ds.Endpoint) - d.Set("kibana_endpoint", getKibanaEndpoint(d)) + d.Set("dashboard_endpoint", getDashboardEndpoint(d)) if err := d.Set("advanced_security_options", flattenAdvancedSecurityOptions(ds.AdvancedSecurityOptions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting advanced_security_options: %s", err) @@ -427,14 +427,14 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte if err := d.Set("endpoint", endpoints["vpc"]); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err) } - d.Set("kibana_endpoint", getKibanaEndpoint(d)) + d.Set("dashboard_endpoint", getDashboardEndpoint(d)) if ds.Endpoint != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain in VPC expected to have null Endpoint value", d.Id()) } } else { if ds.Endpoint != nil { d.Set("endpoint", ds.Endpoint) - d.Set("kibana_endpoint", getKibanaEndpoint(d)) + d.Set("dashboard_endpoint", getDashboardEndpoint(d)) } if ds.Endpoints != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain not in VPC expected to have null Endpoints value", d.Id()) diff --git a/internal/service/opensearch/domain_test.go b/internal/service/opensearch/domain_test.go index 7e2d0939d0a..d004bf2878d 100644 --- a/internal/service/opensearch/domain_test.go +++ b/internal/service/opensearch/domain_test.go @@ -150,7 +150,7 @@ func TestAccOpenSearchDomain_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), resource.TestCheckResourceAttr(resourceName, "engine_version", "OpenSearch_1.1"), - resource.TestMatchResourceAttr(resourceName, "kibana_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_plugin/kibana/`)), + resource.TestMatchResourceAttr(resourceName, "dashboard_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_dashboards/`)), resource.TestCheckResourceAttr(resourceName, "vpc_options.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), From 440c2149af63512780d0d65703b78d93adf356a8 Mon Sep 17 00:00:00 2001 From: changhyuni Date: Thu, 9 Mar 2023 00:55:05 +0900 Subject: [PATCH 2/5] Fix typo --- internal/service/opensearch/domain_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/opensearch/domain_test.go b/internal/service/opensearch/domain_test.go index d004bf2878d..4f668fc3f1e 100644 --- a/internal/service/opensearch/domain_test.go +++ b/internal/service/opensearch/domain_test.go @@ -150,7 +150,7 @@ func TestAccOpenSearchDomain_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), resource.TestCheckResourceAttr(resourceName, "engine_version", "OpenSearch_1.1"), - resource.TestMatchResourceAttr(resourceName, "dashboard_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_dashboards/`)), + resource.TestMatchResourceAttr(resourceName, "dashboard_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_dashboards`)), resource.TestCheckResourceAttr(resourceName, "vpc_options.#", "0"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), From 3de934543f205b05f06855e8ead7f49dec372c28 Mon Sep 17 00:00:00 2001 From: changhyuni Date: Thu, 9 Mar 2023 01:01:50 +0900 Subject: [PATCH 3/5] Fix opensearch document --- website/docs/d/opensearch_domain.html.markdown | 4 ++-- website/docs/r/opensearch_domain.html.markdown | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/d/opensearch_domain.html.markdown b/website/docs/d/opensearch_domain.html.markdown index bc39452c13d..6d61b5f906c 100644 --- a/website/docs/d/opensearch_domain.html.markdown +++ b/website/docs/d/opensearch_domain.html.markdown @@ -57,7 +57,7 @@ The following attributes are exported: * `warm_enabled` - Warm storage is enabled. * `warm_count` - Number of warm nodes in the cluster. * `warm_type` - Instance type for the OpenSearch cluster's warm nodes. -* `cognito_options` - Domain Amazon Cognito Authentication options for Kibana. +* `cognito_options` - Domain Amazon Cognito Authentication options for Dashboard. * `enabled` - Whether Amazon Cognito Authentication is enabled. * `user_pool_id` - Cognito User pool used by the domain. * `identity_pool_id` - Cognito Identity pool used by the domain. @@ -76,7 +76,7 @@ The following attributes are exported: * `enabled` - Whether encryption at rest is enabled in the domain. * `kms_key_id` - KMS key id used to encrypt data at rest. * `endpoint` – Domain-specific endpoint used to submit index, search, and data upload requests. -* `kibana_endpoint` - Domain-specific endpoint used to access the Kibana application. +* `dashboard_endpoint` - Domain-specific endpoint used to access the Dashboard application. * `log_publishing_options` - Domain log publishing related options. * `log_type` - Type of OpenSearch log being published. * `cloudwatch_log_group_arn` - CloudWatch Log Group where the logs are published. diff --git a/website/docs/r/opensearch_domain.html.markdown b/website/docs/r/opensearch_domain.html.markdown index d851e183d34..61f4f0bac27 100644 --- a/website/docs/r/opensearch_domain.html.markdown +++ b/website/docs/r/opensearch_domain.html.markdown @@ -322,7 +322,7 @@ The following arguments are optional: * `advanced_security_options` - (Optional) Configuration block for [fine-grained access control](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/fgac.html). Detailed below. * `auto_tune_options` - (Optional) Configuration block for the Auto-Tune options of the domain. Detailed below. * `cluster_config` - (Optional) Configuration block for the cluster of the domain. Detailed below. -* `cognito_options` - (Optional) Configuration block for authenticating Kibana with Cognito. Detailed below. +* `cognito_options` - (Optional) Configuration block for authenticating dashboard with Cognito. Detailed below. * `domain_endpoint_options` - (Optional) Configuration block for domain endpoint HTTP(S) related options. Detailed below. * `ebs_options` - (Optional) Configuration block for EBS related options, may be required based on chosen [instance size](https://aws.amazon.com/opensearch-service/pricing/). Detailed below. * `engine_version` - (Optional) Either `Elasticsearch_X.Y` or `OpenSearch_X.Y` to specify the engine version for the Amazon OpenSearch Service domain. For example, `OpenSearch_1.0` or `Elasticsearch_7.9`. See [Creating and managing Amazon OpenSearch Service domains](http://docs.aws.amazon.com/opensearch-service/latest/developerguide/createupdatedomains.html#createdomains). Defaults to `OpenSearch_1.1`. @@ -387,9 +387,9 @@ The following arguments are optional: ### cognito_options -AWS documentation: [Amazon Cognito Authentication for Kibana](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/es-cognito-auth.html) +AWS documentation: [Amazon Cognito Authentication for Dashboard](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/es-cognito-auth.html) -* `enabled` - (Optional) Whether Amazon Cognito authentication with Kibana is enabled or not. Default is `false`. +* `enabled` - (Optional) Whether Amazon Cognito authentication with Dashboard is enabled or not. Default is `false`. * `identity_pool_id` - (Required) ID of the Cognito Identity Pool to use. * `role_arn` - (Required) ARN of the IAM role that has the AmazonOpenSearchServiceCognitoAccess policy attached. * `user_pool_id` - (Required) ID of the Cognito User Pool to use. @@ -452,7 +452,7 @@ In addition to all arguments above, the following attributes are exported: * `domain_id` - Unique identifier for the domain. * `domain_name` - Name of the OpenSearch domain. * `endpoint` - Domain-specific endpoint used to submit index, search, and data upload requests. -* `kibana_endpoint` - Domain-specific endpoint for kibana without https scheme. +* `dashboard_endpoint` - Domain-specific endpoint for Dashboard without https scheme. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). * `vpc_options.0.availability_zones` - If the domain was created inside a VPC, the names of the availability zones the configured `subnet_ids` were created inside. * `vpc_options.0.vpc_id` - If the domain was created inside a VPC, the ID of the VPC. From 041d304137e71b520d3bf83ecd59cdd7ec169f2c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 14 Mar 2023 09:15:42 -0400 Subject: [PATCH 4/5] Add CHANGELOG entry. --- .changelog/29867.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changelog/29867.txt diff --git a/.changelog/29867.txt b/.changelog/29867.txt new file mode 100644 index 00000000000..a2a8f1c28f2 --- /dev/null +++ b/.changelog/29867.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/aws_opensearch_domain: Add `dashboard_endpoint` attribute +``` + +```release-note:enhancement +data-source/aws_opensearch_domain: Add `dashboard_endpoint` attribute +``` \ No newline at end of file From 99ec9b1e94dfb24589d4b7b07b400538afdc62fb Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 14 Mar 2023 09:29:39 -0400 Subject: [PATCH 5/5] OpenSearch Domain: Restore 'kibana_endpoint' attribute until it can be deprecated in a major version. --- internal/service/opensearch/domain.go | 12 +++++++++++- internal/service/opensearch/domain_data_source.go | 13 ++++++++++--- internal/service/opensearch/domain_test.go | 5 +++-- website/docs/d/opensearch_domain.html.markdown | 3 ++- website/docs/r/opensearch_domain.html.markdown | 1 + 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/internal/service/opensearch/domain.go b/internal/service/opensearch/domain.go index eae5c307687..490707e6acc 100644 --- a/internal/service/opensearch/domain.go +++ b/internal/service/opensearch/domain.go @@ -335,6 +335,10 @@ func ResourceDomain() *schema.Resource { }, }, }, + "dashboard_endpoint": { + Type: schema.TypeString, + Computed: true, + }, "domain_endpoint_options": { Type: schema.TypeList, Optional: true, @@ -449,7 +453,7 @@ func ResourceDomain() *schema.Resource { Optional: true, Default: "OpenSearch_1.1", }, - "dashboard_endpoint": { + "kibana_endpoint": { Type: schema.TypeString, Computed: true, }, @@ -849,6 +853,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf endpoints := flex.PointersMapToStringList(ds.Endpoints) d.Set("endpoint", endpoints["vpc"]) d.Set("dashboard_endpoint", getDashboardEndpoint(d)) + d.Set("kibana_endpoint", getKibanaEndpoint(d)) if ds.Endpoint != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain in VPC expected to have null Endpoint value", d.Id()) } @@ -856,6 +861,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf if ds.Endpoint != nil { d.Set("endpoint", ds.Endpoint) d.Set("dashboard_endpoint", getDashboardEndpoint(d)) + d.Set("kibana_endpoint", getKibanaEndpoint(d)) } if ds.Endpoints != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain not in VPC expected to have null Endpoints value", d.Id()) @@ -1101,6 +1107,10 @@ func getDashboardEndpoint(d *schema.ResourceData) string { return d.Get("endpoint").(string) + "/_dashboards" } +func getKibanaEndpoint(d *schema.ResourceData) string { + return d.Get("endpoint").(string) + "/_plugin/kibana/" +} + func isDedicatedMasterDisabled(k, old, new string, d *schema.ResourceData) bool { v, ok := d.GetOk("cluster_config") if ok { diff --git a/internal/service/opensearch/domain_data_source.go b/internal/service/opensearch/domain_data_source.go index 56e277d19e7..030119a7874 100644 --- a/internal/service/opensearch/domain_data_source.go +++ b/internal/service/opensearch/domain_data_source.go @@ -101,15 +101,15 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain_id": { + "dashboard_endpoint": { Type: schema.TypeString, Computed: true, }, - "endpoint": { + "domain_id": { Type: schema.TypeString, Computed: true, }, - "dashboard_endpoint": { + "endpoint": { Type: schema.TypeString, Computed: true, }, @@ -157,6 +157,10 @@ func DataSourceDomain() *schema.Resource { }, }, }, + "kibana_endpoint": { + Type: schema.TypeString, + Computed: true, + }, "node_to_node_encryption": { Type: schema.TypeList, Computed: true, @@ -387,6 +391,7 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("domain_id", ds.DomainId) d.Set("endpoint", ds.Endpoint) d.Set("dashboard_endpoint", getDashboardEndpoint(d)) + d.Set("kibana_endpoint", getKibanaEndpoint(d)) if err := d.Set("advanced_security_options", flattenAdvancedSecurityOptions(ds.AdvancedSecurityOptions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting advanced_security_options: %s", err) @@ -428,6 +433,7 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err) } d.Set("dashboard_endpoint", getDashboardEndpoint(d)) + d.Set("kibana_endpoint", getKibanaEndpoint(d)) if ds.Endpoint != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain in VPC expected to have null Endpoint value", d.Id()) } @@ -435,6 +441,7 @@ func dataSourceDomainRead(ctx context.Context, d *schema.ResourceData, meta inte if ds.Endpoint != nil { d.Set("endpoint", ds.Endpoint) d.Set("dashboard_endpoint", getDashboardEndpoint(d)) + d.Set("kibana_endpoint", getKibanaEndpoint(d)) } if ds.Endpoints != nil { return sdkdiag.AppendErrorf(diags, "%q: OpenSearch domain not in VPC expected to have null Endpoints value", d.Id()) diff --git a/internal/service/opensearch/domain_test.go b/internal/service/opensearch/domain_test.go index 4f668fc3f1e..d32062ce04e 100644 --- a/internal/service/opensearch/domain_test.go +++ b/internal/service/opensearch/domain_test.go @@ -149,10 +149,11 @@ func TestAccOpenSearchDomain_basic(t *testing.T) { Config: testAccDomainConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), - resource.TestCheckResourceAttr(resourceName, "engine_version", "OpenSearch_1.1"), resource.TestMatchResourceAttr(resourceName, "dashboard_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_dashboards`)), - resource.TestCheckResourceAttr(resourceName, "vpc_options.#", "0"), + resource.TestCheckResourceAttr(resourceName, "engine_version", "OpenSearch_1.1"), + resource.TestMatchResourceAttr(resourceName, "kibana_endpoint", regexp.MustCompile(`.*(opensearch|es)\..*/_plugin/kibana/`)), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "vpc_options.#", "0"), ), }, { diff --git a/website/docs/d/opensearch_domain.html.markdown b/website/docs/d/opensearch_domain.html.markdown index 6d61b5f906c..66c7b0b7cee 100644 --- a/website/docs/d/opensearch_domain.html.markdown +++ b/website/docs/d/opensearch_domain.html.markdown @@ -76,7 +76,8 @@ The following attributes are exported: * `enabled` - Whether encryption at rest is enabled in the domain. * `kms_key_id` - KMS key id used to encrypt data at rest. * `endpoint` – Domain-specific endpoint used to submit index, search, and data upload requests. -* `dashboard_endpoint` - Domain-specific endpoint used to access the Dashboard application. +* `dashboard_endpoint` - Domain-specific endpoint used to access the [Dashboard application](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/dashboards.html). +* `kibana_endpoint` - Domain-specific endpoint used to access the Kibana application. OpenSearch Dashboards do not use Kibana, so this attribute will be **DEPRECATED** in a future version. * `log_publishing_options` - Domain log publishing related options. * `log_type` - Type of OpenSearch log being published. * `cloudwatch_log_group_arn` - CloudWatch Log Group where the logs are published. diff --git a/website/docs/r/opensearch_domain.html.markdown b/website/docs/r/opensearch_domain.html.markdown index 61f4f0bac27..bb0b459e06e 100644 --- a/website/docs/r/opensearch_domain.html.markdown +++ b/website/docs/r/opensearch_domain.html.markdown @@ -453,6 +453,7 @@ In addition to all arguments above, the following attributes are exported: * `domain_name` - Name of the OpenSearch domain. * `endpoint` - Domain-specific endpoint used to submit index, search, and data upload requests. * `dashboard_endpoint` - Domain-specific endpoint for Dashboard without https scheme. +* `kibana_endpoint` - Domain-specific endpoint for kibana without https scheme. OpenSearch Dashboards do not use Kibana, so this attribute will be **DEPRECATED** in a future version. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). * `vpc_options.0.availability_zones` - If the domain was created inside a VPC, the names of the availability zones the configured `subnet_ids` were created inside. * `vpc_options.0.vpc_id` - If the domain was created inside a VPC, the ID of the VPC.