Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly capture apm and fleet endpoints as part of the integrations server schema #548

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changelog/548.txt
Original file line number Diff line number Diff line change
@@ -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.```
4 changes: 3 additions & 1 deletion docs/resources/ec_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions ec/acc/deployment_integrations_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package deploymentresource
import (
"bytes"
"encoding/json"
"fmt"

"github.com/elastic/cloud-sdk-go/pkg/models"

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