Skip to content

Commit

Permalink
Add aliased_url parameter for deployment resource and data source
Browse files Browse the repository at this point in the history
This implements elastic#778 by adding an `aliased_url` parameter to each cluster definition on both the deployment resource and data source.
  • Loading branch information
mark-adams committed Aug 15, 2024
1 parent a2f2a1d commit 10300f4
Show file tree
Hide file tree
Showing 30 changed files with 123 additions and 25 deletions.
5 changes: 5 additions & 0 deletions docs/data-sources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
5 changes: 5 additions & 0 deletions docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ec/ecdatasource/deploymentdatasource/flatteners_apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ec/ecdatasource/deploymentdatasource/flatteners_kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
5 changes: 5 additions & 0 deletions ec/ecdatasource/deploymentdatasource/schema_apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
Expand Down
25 changes: 15 additions & 10 deletions ec/ecdatasource/deploymentdatasource/schema_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
Expand Down
5 changes: 5 additions & 0 deletions ec/ecdatasource/deploymentdatasource/schema_kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"`
Expand Down
3 changes: 3 additions & 0 deletions ec/ecresource/deploymentresource/apm/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func ApmSchema() schema.Attribute {
"https_endpoint": schema.StringAttribute{
Computed: true,
},
"aliased_endpoint": schema.StringAttribute{
Computed: true,
},
"topology": ApmTopologySchema(),
"config": ApmConfigSchema(),
},
Expand Down
1 change: 1 addition & 0 deletions ec/ecresource/deploymentresource/apm/v2/apm_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion ec/ecresource/deploymentresource/apm/v2/apm_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions ec/ecresource/deploymentresource/apm/v2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions ec/ecresource/deploymentresource/elasticsearch/v1/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 9 additions & 2 deletions ec/ecresource/deploymentresource/elasticsearch/v2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 10300f4

Please sign in to comment.