brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

amazonka timestream query prefix results in 404 #985

Open jappeace opened 4 months ago

jappeace commented 4 months ago

the current implementation of default service returns a 404:

[2024-04-18 10:39:44][beacon-locator.amazonka][Info][14c503cab06d][PID 1][ThreadId 19] [Client Response] {
  status  = 404 Not Found
  headers = x-amzn-requestid: 81b0faa1-aca7-4b91-a44f-7b066609e2f5; content-type: application/x-amz-json-1.0; content-length: 63; date: Thu, 18 Apr 2024 10:39:43 GMT
}
[2024-04-18 10:39:44][beacon-locator.amazonka][Debug][14c503cab06d][PID 1][ThreadId 19] [Raw Response Body] {
{"__type":"com.amazon.coral.service#UnknownOperationException"}
}
[2024-04-18 10:39:44][beacon-locator.amazonka][Error][14c503cab06d][PID 1][ThreadId 19] [ServiceError] {
  service    = TimeStreamQuery
  status     = 404 Not Found
  code       = UnknownOperation
  message    = Nothing
  request-id = Just 81b0faa1-aca7-4b91-a44f-7b066609e2f5
}

It should be changed to:

defaultService =
  Core.Service
    { Core.endpointPrefix = "query-cell1.timestream",
    ...
    }

you can verify this by running describe endpoints:

aws timestream-query describe-endpoints --region eu-west-1
{
    "Endpoints": [
        {
            "Address": "query-cell1.timestream.eu-west-1.amazonaws.com",
            "CachePeriodInMinutes": 1440
        }
    ]
}

to work around this issue is kinda difficult because by defeault the prefix field get's ignored by the instances, you've to also override the endpoint generation function:

setEndpoint :: Service -> Service
setEndpoint y = let z = y{
  endpointPrefix = "query-cell1.timestream",
  endpoint = Core.defaultEndpoint z
  }
  in z

which you now can use to modify your enviroment:

envMod :: Env -> Env
envMod x = x{overrides = setEndpoint}
main =   runResourceT $ do
    runConduit $
      paginate (envMod env) query
      .| sinkList