From 9e043917339d875721dcdb24f7f422b4b9282a1d Mon Sep 17 00:00:00 2001 From: Mark Adams Date: Thu, 15 Aug 2024 09:44:05 -0500 Subject: [PATCH] Add aliased_url parameter for deployment resource and data source This implements #778 by adding an `aliased_url` parameter to each cluster definition on both the deployment resource and data source. --- docs/data-sources/deployment.md | 5 ++++ docs/resources/deployment.md | 5 ++++ .../deploymentdatasource/flatteners_apm.go | 2 +- .../flatteners_elasticsearch.go | 2 +- .../flatteners_enterprise_search.go | 2 +- .../flatteners_integrations_server.go | 2 +- .../deploymentdatasource/flatteners_kibana.go | 2 +- .../deploymentdatasource/schema_apm.go | 5 ++++ .../schema_elasticsearch.go | 25 +++++++++++-------- .../schema_enterprise_search.go | 5 ++++ .../schema_integrations_server.go | 5 ++++ .../deploymentdatasource/schema_kibana.go | 5 ++++ .../deploymentresource/apm/v1/schema.go | 3 +++ .../deploymentresource/apm/v2/apm_payload.go | 1 + .../deploymentresource/apm/v2/apm_read.go | 3 ++- .../deploymentresource/apm/v2/schema.go | 6 +++++ .../elasticsearch/v1/schema.go | 4 +++ .../elasticsearch/v2/elasticsearch_payload.go | 1 + .../elasticsearch/v2/elasticsearch_read.go | 3 ++- .../elasticsearch/v2/schema.go | 11 ++++++-- .../enterprisesearch/v1/schema.go | 3 +++ .../v2/enterprise_search_read.go | 3 ++- .../enterprisesearch/v2/schema.go | 6 +++++ .../integrationsserver/v1/schema.go | 3 +++ .../v2/integrations_server_read.go | 3 ++- .../integrationsserver/v2/schema.go | 6 +++++ .../deploymentresource/kibana/v1/schema.go | 3 +++ .../kibana/v2/kibana_read.go | 3 ++- .../deploymentresource/kibana/v2/schema.go | 6 +++++ ec/internal/converters/extract_endpoint.go | 15 ++++++++--- 30 files changed, 123 insertions(+), 25 deletions(-) diff --git a/docs/data-sources/deployment.md b/docs/data-sources/deployment.md index ab9c40c82..c64139536 100644 --- a/docs/data-sources/deployment.md +++ b/docs/data-sources/deployment.md @@ -48,6 +48,7 @@ Read-Only: - `healthy` (Boolean) APM resource health status. - `http_endpoint` (String) HTTP endpoint for the APM resource. - `https_endpoint` (String) HTTPS endpoint for the APM resource. +- `aliased_endpoint` (String) Aliased endpoint for the APM resource. - `ref_id` (String) A locally-unique friendly alias for this APM resource. - `resource_id` (String) The resource unique identifier. - `status` (String) APM resource status (for example, "started", "stopped", etc). @@ -76,6 +77,7 @@ Read-Only: - `healthy` (Boolean) Elasticsearch resource health status. - `http_endpoint` (String) HTTP endpoint for the Elasticsearch resource. - `https_endpoint` (String) HTTPS endpoint for the Elasticsearch resource. +- `aliased_endpoint` (String) Aliased endpoint for the Elasticsearch resource. - `ref_id` (String) A locally-unique friendly alias for this Elasticsearch cluster. - `resource_id` (String) The resource unique identifier. - `status` (String) Elasticsearch resource status (for example, "started", "stopped", etc). @@ -121,6 +123,7 @@ Read-Only: - `healthy` (Boolean) Enterprise Search resource health status. - `http_endpoint` (String) HTTP endpoint for the Enterprise Search resource. - `https_endpoint` (String) HTTPS endpoint for the Enterprise Search resource. +- `aliased_endpoint` (String) Aliased endpoint for the Enterprise Search resource. - `ref_id` (String) A locally-unique friendly alias for this Enterprise Search resource. - `resource_id` (String) The resource unique identifier. - `status` (String) Enterprise Search resource status (for example, "started", "stopped", etc). @@ -151,6 +154,7 @@ Read-Only: - `healthy` (Boolean) Resource kind health status. - `http_endpoint` (String) HTTP endpoint for the resource kind. - `https_endpoint` (String) HTTPS endpoint for the resource kind. +- `aliased_endpoint` (String) Aliased endpoint for the resource kind. - `ref_id` (String) A locally-unique friendly alias for this Integrations Server resource. - `resource_id` (String) The resource unique identifier. - `status` (String) Resource kind status (for example, "started", "stopped", etc). @@ -178,6 +182,7 @@ Read-Only: - `healthy` (Boolean) Kibana resource health status. - `http_endpoint` (String) HTTP endpoint for the Kibana resource. - `https_endpoint` (String) HTTPS endpoint for the Kibana resource. +- `aliased_endpoint` (String) Aliased endpoint for the Kibana resource. - `ref_id` (String) A locally-unique friendly alias for this Kibana resource. - `resource_id` (String) The resource unique identifier. - `status` (String) Kibana resource status (for example, "started", "stopped", etc). diff --git a/docs/resources/deployment.md b/docs/resources/deployment.md index efd6fb9b0..9182a0eac 100644 --- a/docs/resources/deployment.md +++ b/docs/resources/deployment.md @@ -385,6 +385,7 @@ Read-Only: - `cloud_id` (String) The encoded Elasticsearch credentials to use in Beats or Logstash - `http_endpoint` (String) The Elasticsearch resource HTTP endpoint - `https_endpoint` (String) The Elasticsearch resource HTTPs endpoint +- `aliased_endpoint` (String) The Elasticsearch resource's aliased endpoint - `region` (String) The Elasticsearch resource region - `resource_id` (String) The Elasticsearch resource unique identifier @@ -817,6 +818,7 @@ Read-Only: - `http_endpoint` (String) - `https_endpoint` (String) +- `aliased_endpoint` (String) - `latest_instance_configuration_id` (String) - `latest_instance_configuration_version` (Number) - `region` (String) @@ -854,6 +856,7 @@ Read-Only: - `http_endpoint` (String) - `https_endpoint` (String) +- `aliased_endpoint` (String) - `latest_instance_configuration_id` (String) - `latest_instance_configuration_version` (Number) - `node_type_appserver` (Boolean) @@ -894,6 +897,7 @@ Read-Only: - `http_endpoint` (String) - `https_endpoint` (String) +- `aliased_endpoint` (String) - `latest_instance_configuration_id` (String) - `latest_instance_configuration_version` (Number) - `region` (String) @@ -942,6 +946,7 @@ Read-Only: - `http_endpoint` (String) - `https_endpoint` (String) +- `aliased_endpoint` (String) - `latest_instance_configuration_id` (String) - `latest_instance_configuration_version` (Number) - `region` (String) diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_apm.go b/ec/ecdatasource/deploymentdatasource/flatteners_apm.go index c617199b2..4ad98bd1f 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_apm.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_apm.go @@ -74,7 +74,7 @@ func flattenApmResources(ctx context.Context, in []*models.ApmResourceInfo) (typ } if res.Info.Metadata != nil { - model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) + model.HttpEndpoint, model.HttpsEndpoint, model.AliasedEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) } } diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go index 0239623e9..332deca8a 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_elasticsearch.go @@ -78,7 +78,7 @@ func flattenElasticsearchResources(ctx context.Context, in []*models.Elasticsear if res.Info.Metadata != nil { model.CloudID = types.StringValue(res.Info.Metadata.CloudID) - model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) + model.HttpEndpoint, model.HttpsEndpoint, model.AliasedEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) } } diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go index 142f1545a..cb13c5de7 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_enterprise_search.go @@ -74,7 +74,7 @@ func flattenEnterpriseSearchResources(ctx context.Context, in []*models.Enterpri } if res.Info.Metadata != nil { - model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) + model.HttpEndpoint, model.HttpsEndpoint, model.AliasedEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) } } diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go index 3201ea6b1..a52b91352 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_integrations_server.go @@ -74,7 +74,7 @@ func flattenIntegrationsServerResources(ctx context.Context, in []*models.Integr } if res.Info.Metadata != nil { - model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) + model.HttpEndpoint, model.HttpsEndpoint, model.AliasedEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) } } diff --git a/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go b/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go index 58f00d898..a261f3133 100644 --- a/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go +++ b/ec/ecdatasource/deploymentdatasource/flatteners_kibana.go @@ -74,7 +74,7 @@ func flattenKibanaResources(ctx context.Context, in []*models.KibanaResourceInfo } if res.Info.Metadata != nil { - model.HttpEndpoint, model.HttpsEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) + model.HttpEndpoint, model.HttpsEndpoint, model.AliasedEndpoint = converters.ExtractEndpointsToTypes(res.Info.Metadata) } } diff --git a/ec/ecdatasource/deploymentdatasource/schema_apm.go b/ec/ecdatasource/deploymentdatasource/schema_apm.go index 33c0a26ad..d1657299a 100644 --- a/ec/ecdatasource/deploymentdatasource/schema_apm.go +++ b/ec/ecdatasource/deploymentdatasource/schema_apm.go @@ -48,6 +48,10 @@ func apmResourceInfoSchema() schema.Attribute { Description: "HTTPS endpoint for the APM resource.", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "Aliased endpoint for the APM resource.", + Computed: true, + }, "ref_id": schema.StringAttribute{ Description: "A locally-unique friendly alias for this APM resource.", Computed: true, @@ -111,6 +115,7 @@ type apmResourceInfoModelV0 struct { Healthy types.Bool `tfsdk:"healthy"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` RefID types.String `tfsdk:"ref_id"` ResourceID types.String `tfsdk:"resource_id"` Status types.String `tfsdk:"status"` diff --git a/ec/ecdatasource/deploymentdatasource/schema_elasticsearch.go b/ec/ecdatasource/deploymentdatasource/schema_elasticsearch.go index 2c52d3008..785086a8f 100644 --- a/ec/ecdatasource/deploymentdatasource/schema_elasticsearch.go +++ b/ec/ecdatasource/deploymentdatasource/schema_elasticsearch.go @@ -53,6 +53,10 @@ func elasticsearchResourceInfoSchema() schema.Attribute { Description: "HTTPS endpoint for the Elasticsearch resource.", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "Aliased endpoint for the Elasticsearch resource.", + Computed: true, + }, "ref_id": schema.StringAttribute{ Description: "A locally-unique friendly alias for this Elasticsearch cluster.", Computed: true, @@ -174,16 +178,17 @@ func elasticsearchAutoscalingElemType() attr.Type { } type elasticsearchResourceInfoModelV0 struct { - Autoscale types.String `tfsdk:"autoscale"` - Healthy types.Bool `tfsdk:"healthy"` - CloudID types.String `tfsdk:"cloud_id"` - HttpEndpoint types.String `tfsdk:"http_endpoint"` - HttpsEndpoint types.String `tfsdk:"https_endpoint"` - RefID types.String `tfsdk:"ref_id"` - ResourceID types.String `tfsdk:"resource_id"` - Status types.String `tfsdk:"status"` - Version types.String `tfsdk:"version"` - Topology types.List `tfsdk:"topology"` //< elasticsearchTopologyModelV0 + Autoscale types.String `tfsdk:"autoscale"` + Healthy types.Bool `tfsdk:"healthy"` + CloudID types.String `tfsdk:"cloud_id"` + HttpEndpoint types.String `tfsdk:"http_endpoint"` + HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` + RefID types.String `tfsdk:"ref_id"` + ResourceID types.String `tfsdk:"resource_id"` + Status types.String `tfsdk:"status"` + Version types.String `tfsdk:"version"` + Topology types.List `tfsdk:"topology"` //< elasticsearchTopologyModelV0 } type elasticsearchTopologyModelV0 struct { diff --git a/ec/ecdatasource/deploymentdatasource/schema_enterprise_search.go b/ec/ecdatasource/deploymentdatasource/schema_enterprise_search.go index 3d6400634..7ae19b034 100644 --- a/ec/ecdatasource/deploymentdatasource/schema_enterprise_search.go +++ b/ec/ecdatasource/deploymentdatasource/schema_enterprise_search.go @@ -48,6 +48,10 @@ func enterpriseSearchResourceInfoSchema() schema.Attribute { Description: "HTTPS endpoint for the Enterprise Search resource.", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "Aliased endpoint for the Enterprise Search resource.", + Computed: true, + }, "ref_id": schema.StringAttribute{ Description: "A locally-unique friendly alias for this Enterprise Search resource.", Computed: true, @@ -123,6 +127,7 @@ type enterpriseSearchResourceInfoModelV0 struct { Healthy types.Bool `tfsdk:"healthy"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` RefID types.String `tfsdk:"ref_id"` ResourceID types.String `tfsdk:"resource_id"` Status types.String `tfsdk:"status"` diff --git a/ec/ecdatasource/deploymentdatasource/schema_integrations_server.go b/ec/ecdatasource/deploymentdatasource/schema_integrations_server.go index 71a2bcd40..b51c4b9ba 100644 --- a/ec/ecdatasource/deploymentdatasource/schema_integrations_server.go +++ b/ec/ecdatasource/deploymentdatasource/schema_integrations_server.go @@ -48,6 +48,10 @@ func integrationsServerResourceInfoSchema() schema.Attribute { Description: "HTTPS endpoint for the resource kind.", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "Aliased endpoint for the resource kind.", + Computed: true, + }, "ref_id": schema.StringAttribute{ Description: "A locally-unique friendly alias for this Integrations Server resource.", Computed: true, @@ -111,6 +115,7 @@ type integrationsServerResourceInfoModelV0 struct { Healthy types.Bool `tfsdk:"healthy"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` RefID types.String `tfsdk:"ref_id"` ResourceID types.String `tfsdk:"resource_id"` Status types.String `tfsdk:"status"` diff --git a/ec/ecdatasource/deploymentdatasource/schema_kibana.go b/ec/ecdatasource/deploymentdatasource/schema_kibana.go index c76e5c8e7..be1b7dcde 100644 --- a/ec/ecdatasource/deploymentdatasource/schema_kibana.go +++ b/ec/ecdatasource/deploymentdatasource/schema_kibana.go @@ -48,6 +48,10 @@ func kibanaResourceInfoSchema() schema.Attribute { Description: "HTTPS endpoint for the Kibana resource.", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "Aliased endpoint for the Kibana resource.", + Computed: true, + }, "ref_id": schema.StringAttribute{ Description: "A locally-unique friendly alias for this Kibana resource.", Computed: true, @@ -111,6 +115,7 @@ type kibanaResourceInfoModelV0 struct { Healthy types.Bool `tfsdk:"healthy"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` RefID types.String `tfsdk:"ref_id"` ResourceID types.String `tfsdk:"resource_id"` Status types.String `tfsdk:"status"` diff --git a/ec/ecresource/deploymentresource/apm/v1/schema.go b/ec/ecresource/deploymentresource/apm/v1/schema.go index c0252594d..d32d5cdab 100644 --- a/ec/ecresource/deploymentresource/apm/v1/schema.go +++ b/ec/ecresource/deploymentresource/apm/v1/schema.go @@ -111,6 +111,9 @@ func ApmSchema() schema.Attribute { "https_endpoint": schema.StringAttribute{ Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + }, "topology": ApmTopologySchema(), "config": ApmConfigSchema(), }, diff --git a/ec/ecresource/deploymentresource/apm/v2/apm_payload.go b/ec/ecresource/deploymentresource/apm/v2/apm_payload.go index bd0e7756a..d4732e29b 100644 --- a/ec/ecresource/deploymentresource/apm/v2/apm_payload.go +++ b/ec/ecresource/deploymentresource/apm/v2/apm_payload.go @@ -36,6 +36,7 @@ type ApmTF struct { Region types.String `tfsdk:"region"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` InstanceConfigurationId types.String `tfsdk:"instance_configuration_id"` LatestInstanceConfigurationId types.String `tfsdk:"latest_instance_configuration_id"` InstanceConfigurationVersion types.Int64 `tfsdk:"instance_configuration_version"` diff --git a/ec/ecresource/deploymentresource/apm/v2/apm_read.go b/ec/ecresource/deploymentresource/apm/v2/apm_read.go index 80f9d3cbf..8cb2c35fa 100644 --- a/ec/ecresource/deploymentresource/apm/v2/apm_read.go +++ b/ec/ecresource/deploymentresource/apm/v2/apm_read.go @@ -31,6 +31,7 @@ type Apm struct { Region *string `tfsdk:"region"` HttpEndpoint *string `tfsdk:"http_endpoint"` HttpsEndpoint *string `tfsdk:"https_endpoint"` + AliasedEndpoint *string `tfsdk:"aliased_endpoint"` InstanceConfigurationId *string `tfsdk:"instance_configuration_id"` LatestInstanceConfigurationId *string `tfsdk:"latest_instance_configuration_id"` InstanceConfigurationVersion *int `tfsdk:"instance_configuration_version"` @@ -81,7 +82,7 @@ func ReadApm(in *models.ApmResourceInfo) (*Apm, error) { apm.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID - apm.HttpEndpoint, apm.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata) + apm.HttpEndpoint, apm.HttpsEndpoint, apm.AliasedEndpoint = converters.ExtractEndpoints(in.Info.Metadata) configs, err := readApmConfigs(plan.Apm) if err != nil { diff --git a/ec/ecresource/deploymentresource/apm/v2/schema.go b/ec/ecresource/deploymentresource/apm/v2/schema.go index 95baa6e15..4f13d78e1 100644 --- a/ec/ecresource/deploymentresource/apm/v2/schema.go +++ b/ec/ecresource/deploymentresource/apm/v2/schema.go @@ -111,6 +111,12 @@ func ApmSchema() schema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "instance_configuration_id": schema.StringAttribute{ Optional: true, Computed: true, diff --git a/ec/ecresource/deploymentresource/elasticsearch/v1/schema.go b/ec/ecresource/deploymentresource/elasticsearch/v1/schema.go index 7c5235507..1129609e1 100644 --- a/ec/ecresource/deploymentresource/elasticsearch/v1/schema.go +++ b/ec/ecresource/deploymentresource/elasticsearch/v1/schema.go @@ -77,6 +77,10 @@ func ElasticsearchSchema() schema.Attribute { Description: "The Elasticsearch resource HTTPs endpoint", Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Description: "The Elasticsearch resource aliased endpoint", + Computed: true, + }, "topology": ElasticsearchTopologySchema(), "trust_account": ElasticsearchTrustAccountSchema(), diff --git a/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_payload.go b/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_payload.go index 9c569b9d2..c2fca5d70 100644 --- a/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_payload.go +++ b/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_payload.go @@ -37,6 +37,7 @@ type ElasticsearchTF struct { CloudID types.String `tfsdk:"cloud_id"` HttpEndpoint types.String `tfsdk:"http_endpoint"` HttpsEndpoint types.String `tfsdk:"https_endpoint"` + AliasedEndpoint types.String `tfsdk:"aliased_endpoint"` HotContentTier types.Object `tfsdk:"hot"` CoordinatingTier types.Object `tfsdk:"coordinating"` MasterTier types.Object `tfsdk:"master"` diff --git a/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_read.go b/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_read.go index 640b883b3..0fba6dd91 100644 --- a/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_read.go +++ b/ec/ecresource/deploymentresource/elasticsearch/v2/elasticsearch_read.go @@ -32,6 +32,7 @@ type Elasticsearch struct { CloudID *string `tfsdk:"cloud_id"` HttpEndpoint *string `tfsdk:"http_endpoint"` HttpsEndpoint *string `tfsdk:"https_endpoint"` + AliasedEndpoint *string `tfsdk:"aliased_endpoint"` HotTier *ElasticsearchTopology `tfsdk:"hot"` CoordinatingTier *ElasticsearchTopology `tfsdk:"coordinating"` MasterTier *ElasticsearchTopology `tfsdk:"master"` @@ -101,7 +102,7 @@ func readElasticsearch(in *models.ElasticsearchResourceInfo, remotes *models.Rem es.CloudID = &meta.CloudID } - es.HttpEndpoint, es.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata) + es.HttpEndpoint, es.HttpsEndpoint, es.AliasedEndpoint = converters.ExtractEndpoints(in.Info.Metadata) es.Config, err = readElasticsearchConfig(plan.Elasticsearch) if err != nil { diff --git a/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go b/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go index 0a58ab60a..a3cf8e97d 100644 --- a/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go +++ b/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go @@ -19,9 +19,10 @@ package v2 import ( "fmt" - "github.com/hashicorp/terraform-plugin-framework/attr" "strings" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -107,7 +108,13 @@ func ElasticsearchSchema() schema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, - + "aliased_endpoint": schema.StringAttribute{ + Description: "The Elasticsearch resource aliased endpoint", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "hot": elasticsearchTopologySchema(topologySchemaOptions{ tierName: "hot", required: true, diff --git a/ec/ecresource/deploymentresource/enterprisesearch/v1/schema.go b/ec/ecresource/deploymentresource/enterprisesearch/v1/schema.go index 48f5b9c3a..18980b65d 100644 --- a/ec/ecresource/deploymentresource/enterprisesearch/v1/schema.go +++ b/ec/ecresource/deploymentresource/enterprisesearch/v1/schema.go @@ -47,6 +47,9 @@ func EnterpriseSearchSchema() schema.Attribute { "https_endpoint": schema.StringAttribute{ Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + }, "topology": schema.ListNestedAttribute{ Description: "Optional topology attribute", Optional: true, diff --git a/ec/ecresource/deploymentresource/enterprisesearch/v2/enterprise_search_read.go b/ec/ecresource/deploymentresource/enterprisesearch/v2/enterprise_search_read.go index e0805bb8a..ad98f4d08 100644 --- a/ec/ecresource/deploymentresource/enterprisesearch/v2/enterprise_search_read.go +++ b/ec/ecresource/deploymentresource/enterprisesearch/v2/enterprise_search_read.go @@ -31,6 +31,7 @@ type EnterpriseSearch struct { Region *string `tfsdk:"region"` HttpEndpoint *string `tfsdk:"http_endpoint"` HttpsEndpoint *string `tfsdk:"https_endpoint"` + AliasedEndpoint *string `tfsdk:"aliased_endpoint"` InstanceConfigurationId *string `tfsdk:"instance_configuration_id"` LatestInstanceConfigurationId *string `tfsdk:"latest_instance_configuration_id"` InstanceConfigurationVersion *int `tfsdk:"instance_configuration_version"` @@ -80,7 +81,7 @@ func ReadEnterpriseSearch(in *models.EnterpriseSearchResourceInfo) (*EnterpriseS ess.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID - ess.HttpEndpoint, ess.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata) + ess.HttpEndpoint, ess.HttpsEndpoint, ess.AliasedEndpoint = converters.ExtractEndpoints(in.Info.Metadata) cfg, err := readEnterpriseSearchConfig(plan.EnterpriseSearch) if err != nil { diff --git a/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go b/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go index 69b400c02..538c0a7f6 100644 --- a/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go +++ b/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go @@ -75,6 +75,12 @@ func EnterpriseSearchSchema() schema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "instance_configuration_id": schema.StringAttribute{ Optional: true, Computed: true, diff --git a/ec/ecresource/deploymentresource/integrationsserver/v1/schema.go b/ec/ecresource/deploymentresource/integrationsserver/v1/schema.go index 2e729f0b2..53e0edfb4 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v1/schema.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v1/schema.go @@ -47,6 +47,9 @@ func IntegrationsServerSchema() schema.Attribute { "https_endpoint": schema.StringAttribute{ Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + }, "topology": schema.ListNestedAttribute{ Description: "Optional topology attribute", Optional: true, diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go index 3e82b5e83..f86ade65b 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go @@ -31,6 +31,7 @@ type IntegrationsServer struct { Region *string `tfsdk:"region"` HttpEndpoint *string `tfsdk:"http_endpoint"` HttpsEndpoint *string `tfsdk:"https_endpoint"` + AliasedEndpoint *string `tfsdk:"aliased_endpoint"` Endpoints *Endpoints `tfsdk:"endpoints"` InstanceConfigurationId *string `tfsdk:"instance_configuration_id"` LatestInstanceConfigurationId *string `tfsdk:"latest_instance_configuration_id"` @@ -94,7 +95,7 @@ func readIntegrationsServer(in *models.IntegrationsServerResourceInfo) (*Integra srv.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID - srv.HttpEndpoint, srv.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata) + srv.HttpEndpoint, srv.HttpsEndpoint, srv.AliasedEndpoint = converters.ExtractEndpoints(in.Info.Metadata) srv.Endpoints = readEndpoints(in) cfg, err := readIntegrationsServerConfigs(plan.IntegrationsServer) diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go index bf273f5e4..edd37e8e3 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go @@ -77,6 +77,12 @@ func IntegrationsServerSchema() schema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "endpoints": schema.ObjectAttribute{ Optional: true, Computed: true, diff --git a/ec/ecresource/deploymentresource/kibana/v1/schema.go b/ec/ecresource/deploymentresource/kibana/v1/schema.go index 0a1d24953..0b68619f4 100644 --- a/ec/ecresource/deploymentresource/kibana/v1/schema.go +++ b/ec/ecresource/deploymentresource/kibana/v1/schema.go @@ -47,6 +47,9 @@ func KibanaSchema() schema.Attribute { "https_endpoint": schema.StringAttribute{ Computed: true, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + }, "topology": schema.ListNestedAttribute{ Description: `Optional topology element`, Optional: true, diff --git a/ec/ecresource/deploymentresource/kibana/v2/kibana_read.go b/ec/ecresource/deploymentresource/kibana/v2/kibana_read.go index 36d821d4d..ff3867c90 100644 --- a/ec/ecresource/deploymentresource/kibana/v2/kibana_read.go +++ b/ec/ecresource/deploymentresource/kibana/v2/kibana_read.go @@ -31,6 +31,7 @@ type Kibana struct { Region *string `tfsdk:"region"` HttpEndpoint *string `tfsdk:"http_endpoint"` HttpsEndpoint *string `tfsdk:"https_endpoint"` + AliasedEndpoint *string `tfsdk:"aliased_endpoint"` InstanceConfigurationId *string `tfsdk:"instance_configuration_id"` LatestInstanceConfigurationId *string `tfsdk:"latest_instance_configuration_id"` InstanceConfigurationVersion *int `tfsdk:"instance_configuration_version"` @@ -85,7 +86,7 @@ func readKibana(in *models.KibanaResourceInfo) (*Kibana, error) { kibana.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID - kibana.HttpEndpoint, kibana.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata) + kibana.HttpEndpoint, kibana.HttpsEndpoint, kibana.AliasedEndpoint = converters.ExtractEndpoints(in.Info.Metadata) config, err := readKibanaConfig(plan.Kibana) if err != nil { diff --git a/ec/ecresource/deploymentresource/kibana/v2/schema.go b/ec/ecresource/deploymentresource/kibana/v2/schema.go index 736388e5d..f41613a3c 100644 --- a/ec/ecresource/deploymentresource/kibana/v2/schema.go +++ b/ec/ecresource/deploymentresource/kibana/v2/schema.go @@ -70,6 +70,12 @@ func KibanaSchema() schema.Attribute { stringplanmodifier.UseStateForUnknown(), }, }, + "aliased_endpoint": schema.StringAttribute{ + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, "instance_configuration_id": schema.StringAttribute{ Optional: true, Computed: true, diff --git a/ec/internal/converters/extract_endpoint.go b/ec/internal/converters/extract_endpoint.go index ba54100e1..108add5bd 100644 --- a/ec/internal/converters/extract_endpoint.go +++ b/ec/internal/converters/extract_endpoint.go @@ -25,8 +25,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) -func ExtractEndpointsToTypes(metadata *models.ClusterMetadataInfo) (httpEndpoint, httpsEndpoint types.String) { - httpEndpointStr, httpsEndpointStr := ExtractEndpoints(metadata) +func ExtractEndpointsToTypes(metadata *models.ClusterMetadataInfo) (httpEndpoint, httpsEndpoint, aliasedEndpoint types.String) { + httpEndpointStr, httpsEndpointStr, aliasedEndpointStr := ExtractEndpoints(metadata) if httpEndpointStr != nil { httpEndpoint = types.StringValue(*httpEndpointStr) @@ -36,10 +36,14 @@ func ExtractEndpointsToTypes(metadata *models.ClusterMetadataInfo) (httpEndpoint httpsEndpoint = types.StringValue(*httpsEndpointStr) } + if aliasedEndpointStr != nil { + aliasedEndpoint = types.StringValue(*aliasedEndpointStr) + } + return } -func ExtractEndpoints(metadata *models.ClusterMetadataInfo) (httpEndpoint, httpsEndpoint *string) { +func ExtractEndpoints(metadata *models.ClusterMetadataInfo) (httpEndpoint, httpsEndpoint, aliasedEndpoint *string) { if metadata == nil || metadata.Endpoint == "" || metadata.Ports == nil { return } @@ -52,5 +56,10 @@ func ExtractEndpoints(metadata *models.ClusterMetadataInfo) (httpEndpoint, https httpsEndpoint = ec.String(fmt.Sprintf("https://%s:%d", metadata.Endpoint, *metadata.Ports.HTTPS)) } + if metadata.AliasedURL != "" { + fmt.Printf("DID IT!\n") + aliasedEndpoint = ec.String(metadata.AliasedURL) + } + return }