terraform-provider-splunk icon indicating copy to clipboard operation
terraform-provider-splunk copied to clipboard

URL with path provides invalid port error

Open vertex opened this issue 3 years ago • 3 comments

Configuring a URL with a PATH provides an error, for example:

provider "splunk" {
    url                  = "https://hostname:443/some/path"
    auth_token           = var.splunk_auth_token
    insecure_skip_verify = true
}

Provides the error:

> terraform apply
splunk_saved_searches.saved_search: Refreshing state... [id=Test New Alert]
╷
│ Error: parse "https://https:%2F%2Fhostname:443%2Fsome%2Fpath/servicesNS/-/-/saved/searches?count=-1&output_mode=json": invalid port ":443%2Fsome%2Fpath" after host
│ 
│   with splunk_saved_searches.saved_search,
│   on main.tf line 17, in resource "splunk_saved_searches" "saved_search":
│   17: resource "splunk_saved_searches" "saved_search" {
│ 

vertex avatar Sep 24 '21 19:09 vertex

try https://hostname:443/some/path -> hostname:443/some/path

lnwu avatar Dec 14 '22 09:12 lnwu

I have a similar problem. In my organization splunk url looks like this <hostname>/observability/splunk. I get the error:

Error: parse "https://<hostname>%2Fobservability%2Fsplunk/servicesNS/<irrelevant_url_part>": invalid URL escape "%2F"

I looked into the code and this is what I found: url is not parsed as URL but used as host. Looks like when Provider is built, url is passed to client.NewSplunkdClient to build a new Client. So url is assigned to Client.host https://github.com/splunk/terraform-provider-splunk/blob/0cb4f0706dfc0dea10c5ec89fae192e98341a5db/splunk/provider.go#L125 When url.URL is built, the BuildSplunkURL method uses Client.host as Host. The method doesn't parse host and doesn't interpret the part after / as Path. https://github.com/splunk/terraform-provider-splunk/blob/0cb4f0706dfc0dea10c5ec89fae192e98341a5db/client/client.go#L91

vvbogdanov87 avatar Dec 14 '22 22:12 vvbogdanov87

I am still getting error.

splunk_saved_searches.new-search-01: Creating... ╷ │ Error: parse "https://myURL%2Fen-US%2Fapp%2Fsearch/servicesNS/user01/search/saved/searches?count=-1&output_mode=json": invalid URL escape "%2F" │ │ with splunk_saved_searches.new-search-01, │ on main.tf line 15, in resource "splunk_saved_searches" "new-search-01": │ 15: resource "splunk_saved_searches" "new-search-01" {

bhosaleswapnil2103 avatar Dec 07 '23 23:12 bhosaleswapnil2103