Description
Describe the bug
I am trying to import an elasticstack_fleet_output
which always fails and I do not have any idea what I am doing wrong. According to the docs, it is as simple as configuring the kibana connection and executing terraform import elasticstack_fleet_output.my_output <space id>/<output id>
To Reproduce
My Connection config is:
provider "elasticstack" {
elasticsearch {
username = "elastic"
password = ""
endpoints = "https://elastichost:9200"
ca_file = "./certs/root.crt"
}
kibana {
username = "elastic"
password = ""
endpoints = "https://elastichost:5601"
insecure = true
}
fleet {
username = "elastic"
password = ""
endpoint = "https://elastichost:8220"
ca_certs = ["./certs/root.crt", "./certs/intermediate.crt"]
}
}
My output config is:
resource "elasticstack_fleet_output" "default_output" {
name = "default"
type = "elasticsearch"
default_integrations = true
default_monitoring = true
hosts = ["https://elastichost:9200"]
}
Expected behavior
I would expect that the output is successfully imported.
Debug output
When running terraform import -var-file="test.tfvars" elasticstack_fleet_output.default_output default/fleet-default-output
, I get the following HTTP404 error:
2023-06-27T09:46:46.963+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/fleet/outputs/ HTTP/1.1
Host: elastichost:8220
User-Agent: Go-http-client/1.1
Authorization: ***********************************************
Accept-Encoding: gzip
2023-06-27T09:46:47.028+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 404 Not Found
Content-Length: 19
Content-Type: text/plain; charset=utf-8
Date: Tue, 27 Jun 2023 07:46:47 GMT
X-Content-Type-Options: nosniff404 page not found
I don't know why the provider tried to connect to the fleet server when the docs say that Kibana is required, so I temporarily removed the fleet server. After this, I get:
2023-06-27T10:02:06.627+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Request Details:
---[ REQUEST ]---------------------------------------
GET /api/fleet/outputs/ HTTP/1.1
Host: elastichost:5601
User-Agent: Go-http-client/1.1
Authorization: ***********************************************
Accept-Encoding: gzip
2023-06-27T10:02:06.708+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 302 Found
Cache-Control: private, no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Security-Policy: script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'
Cross-Origin-Opener-Policy: same-origin
Date: Tue, 27 Jun 2023 08:02:06 GMT
Kbn-License-Sig: 03419a885e4908987730578d44854c956b83a3a5e2eba9735cf01d5f98c1f99b
Kbn-Name: elastic-q
Keep-Alive: timeout=120
Location: /api%2Ffleet%2Foutputs
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block
Content-Length: 0
2023-06-27T10:02:06.708+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Request Details:
---[ REQUEST ]---------------------------------------
GET /api%2Ffleet%2Foutputs HTTP/1.1
Host: elastichost:5601
User-Agent: Go-http-client/1.1
Authorization: ***********************************************
Referer: https://elastichost:5601/api/fleet/outputs/
Accept-Encoding: gzip
2023-06-27T10:02:06.735+0200 [DEBUG] provider.terraform-provider-elasticstack_v0.6.2.exe: Fleet API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 404 Not Found
Content-Length: 60
Cache-Control: private, no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Security-Policy: script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self'
Content-Type: application/json; charset=utf-8
Cross-Origin-Opener-Policy: same-origin
Date: Tue, 27 Jun 2023 08:02:06 GMT
Kbn-License-Sig: 03419a885e4908987730578d44854c956b83a3a5e2eba9735cf01d5f98c1f99b
Kbn-Name: elastic-q
Keep-Alive: timeout=120
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
X-Xss-Protection: 1; mode=block{
"statusCode": 404,
"error": "Not Found",
"message": "Not Found"
}
Maybe, only the trailing slash is wrong? The same call fails in Kibana DevTools:
GET kbn:api/fleet/outputs/
But this succeeds:
GET kbn:api/fleet/outputs
Versions (please complete the following information):
- OS: [e.g. Linux] Terraform - Windows, Elastic Stack - Linux
- Terraform Version 1.5.0
- Provider version 0.6.2
- Elasticsearch Version 8.7.0