From 2dd81d203ed0c54bb0f4fa56d06e09ff7b3cf943 Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Mon, 10 Oct 2022 11:10:08 +1100 Subject: [PATCH] Explicitly capture apm and fleet endpoints as part of the integrations server schema (#548) * Explicitly capture apm and fleet endpoints as part of the integrations server schema * Add changelog --- .changelog/548.txt | 2 + docs/resources/ec_deployment.md | 4 +- ec/acc/deployment_integrations_server_test.go | 2 + .../integrations_server_flatteners.go | 5 ++ .../integrations_server_flatteners_test.go | 46 +++++++++++++++++++ .../schema_integrations_server.go | 8 ++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .changelog/548.txt diff --git a/.changelog/548.txt b/.changelog/548.txt new file mode 100644 index 000000000..dc581f303 --- /dev/null +++ b/.changelog/548.txt @@ -0,0 +1,2 @@ +```release-note:feature +resource/deployment: Adds fleet_https_endpoint and apm_https_endpoint to integrations server resources. This allows consumers to explicitly capture service urls for dependent modules.``` diff --git a/docs/resources/ec_deployment.md b/docs/resources/ec_deployment.md index 305cad354..d7fad1283 100644 --- a/docs/resources/ec_deployment.md +++ b/docs/resources/ec_deployment.md @@ -396,7 +396,7 @@ The optional `elasticsearch.strategy` allows you to choose the configuration str * `grow_and_shrink` Add all nodes with the new changes before to stop any node. * `rolling_grow_and_shrink` Add nodes one by one replacing the existing ones when the new node is ready. * `rolling_all` Stop all nodes, perform the changes and start all nodes. - + #### Kibana The optional `kibana` block supports the following arguments: @@ -539,6 +539,8 @@ In addition to all the arguments above, the following attributes are exported: * `integrations_server.#.region` - Integrations Server region. * `integrations_server.#.http_endpoint` - Integrations Server resource HTTP endpoint. * `integrations_server.#.https_endpoint` - Integrations Server resource HTTPs endpoint. +* `integrations_server.#.fleet_https_endpoint` - HTTPs endpoint for Fleet Server. +* `integrations_server.#.apm_https_endpoint` - HTTPs endpoint for APM Server. * `apm.#.resource_id` - APM resource unique identifier. * `apm.#.region` - APM region. * `apm.#.http_endpoint` - APM resource HTTP endpoint. diff --git a/ec/acc/deployment_integrations_server_test.go b/ec/acc/deployment_integrations_server_test.go index 2bc714aba..5cf172b9d 100644 --- a/ec/acc/deployment_integrations_server_test.go +++ b/ec/acc/deployment_integrations_server_test.go @@ -52,6 +52,8 @@ func TestAccDeployment_integrationsServer(t *testing.T) { resource.TestCheckResourceAttrSet(resName, "integrations_server.0.topology.0.instance_configuration_id"), resource.TestCheckResourceAttr(resName, "integrations_server.0.topology.0.size", "1g"), resource.TestCheckResourceAttr(resName, "integrations_server.0.topology.0.size_resource", "memory"), + resource.TestCheckResourceAttrSet(resName, "integrations_server.0.apm_https_endpoint"), + resource.TestCheckResourceAttrSet(resName, "integrations_server.0.fleet_https_endpoint"), ), }, { diff --git a/ec/ecresource/deploymentresource/integrations_server_flatteners.go b/ec/ecresource/deploymentresource/integrations_server_flatteners.go index 7dd5e5261..700c3c21f 100644 --- a/ec/ecresource/deploymentresource/integrations_server_flatteners.go +++ b/ec/ecresource/deploymentresource/integrations_server_flatteners.go @@ -20,6 +20,7 @@ package deploymentresource import ( "bytes" "encoding/json" + "fmt" "github.com/elastic/cloud-sdk-go/pkg/models" @@ -60,6 +61,10 @@ func flattenIntegrationsServerResources(in []*models.IntegrationsServerResourceI m[k] = v } + for _, url := range res.Info.Metadata.ServicesUrls { + m[fmt.Sprintf("%s_https_endpoint", *url.Service)] = *url.URL + } + if cfg := flattenIntegrationsServerConfig(plan.IntegrationsServer); len(cfg) > 0 { m["config"] = cfg } diff --git a/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go b/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go index 9ae0ec20c..9d751cf75 100644 --- a/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go +++ b/ec/ecresource/deploymentresource/integrations_server_flatteners_test.go @@ -72,6 +72,16 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { HTTP: ec.Int32(9200), HTTPS: ec.Int32(9243), }, + ServicesUrls: []*models.ServiceURL{ + { + Service: ec.String("apm"), + URL: ec.String("https://apm_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("fleet"), + URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), + }, + }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ Plan: &models.IntegrationsServerPlan{ @@ -101,6 +111,8 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { "region": "some-region", "http_endpoint": "http://integrations_serverresource.cloud.elastic.co:9200", "https_endpoint": "https://integrations_serverresource.cloud.elastic.co:9243", + "fleet_https_endpoint": "https://fleet_endpoint.cloud.elastic.co", + "apm_https_endpoint": "https://apm_endpoint.cloud.elastic.co", "topology": []interface{}{ map[string]interface{}{ "instance_configuration_id": "aws.integrations_server.r4", @@ -130,6 +142,16 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { HTTP: ec.Int32(9200), HTTPS: ec.Int32(9243), }, + ServicesUrls: []*models.ServiceURL{ + { + Service: ec.String("apm"), + URL: ec.String("https://apm_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("fleet"), + URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), + }, + }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ Plan: &models.IntegrationsServerPlan{ @@ -174,6 +196,16 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { HTTP: ec.Int32(9200), HTTPS: ec.Int32(9243), }, + ServicesUrls: []*models.ServiceURL{ + { + Service: ec.String("apm"), + URL: ec.String("https://apm_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("fleet"), + URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), + }, + }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ Plan: &models.IntegrationsServerPlan{ @@ -211,6 +243,8 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { "region": "some-region", "http_endpoint": "http://integrations_serverresource.cloud.elastic.co:9200", "https_endpoint": "https://integrations_serverresource.cloud.elastic.co:9243", + "fleet_https_endpoint": "https://fleet_endpoint.cloud.elastic.co", + "apm_https_endpoint": "https://apm_endpoint.cloud.elastic.co", "topology": []interface{}{map[string]interface{}{ "instance_configuration_id": "aws.integrations_server.r4", "size": "1g", @@ -243,6 +277,16 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { HTTP: ec.Int32(9200), HTTPS: ec.Int32(9243), }, + ServicesUrls: []*models.ServiceURL{ + { + Service: ec.String("apm"), + URL: ec.String("https://apm_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("fleet"), + URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), + }, + }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ Plan: &models.IntegrationsServerPlan{ @@ -282,6 +326,8 @@ func Test_flattenIntegrationsServerResource(t *testing.T) { "region": "some-region", "http_endpoint": "http://integrations_serverresource.cloud.elastic.co:9200", "https_endpoint": "https://integrations_serverresource.cloud.elastic.co:9243", + "fleet_https_endpoint": "https://fleet_endpoint.cloud.elastic.co", + "apm_https_endpoint": "https://apm_endpoint.cloud.elastic.co", "topology": []interface{}{map[string]interface{}{ "instance_configuration_id": "aws.integrations_server.r4", "size": "1g", diff --git a/ec/ecresource/deploymentresource/schema_integrations_server.go b/ec/ecresource/deploymentresource/schema_integrations_server.go index 83aa14db8..70cadfe82 100644 --- a/ec/ecresource/deploymentresource/schema_integrations_server.go +++ b/ec/ecresource/deploymentresource/schema_integrations_server.go @@ -50,6 +50,14 @@ func newIntegrationsServerResource() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "fleet_https_endpoint": { + Type: schema.TypeString, + Computed: true, + }, + "apm_https_endpoint": { + Type: schema.TypeString, + Computed: true, + }, "topology": integrationsServerTopologySchema(), "config": integrationsServerConfig(),