I’m using @rupert the-sett/elm-aws-core to get information from the AWS API, which unfortunately is very inconsistent. Most of the endpoints return JSON and that works fine with that lib (I’m using auto scaling and ecs without issues), but the EC2 endpoint returns XML.
The lib doesn’t have any options not to decode JSON as far as I can tell, which does not work at all :
let ec2 region = Service.defineRegional "ec2" "2016-11-15" Service.QUERY Service.SignV4 (Service.setXmlNamespace "https://ec2.amazonaws.com/doc/2016-11-15/") region in let params = [("Action", "DescribeImages"), ("Version", "2016-11-15"), ("Owner.1", "self")] in Http.request "DescribeImages" GET "/" Http.emptyBody JSONDECODERHERE |> Http.addQuery params |> Http.send (ec2 region) creds |> Task.attempt msg
Failed : Problem with the given value: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<DescribeImagesResponse .......
As you can see in there you need to pass a JSON Decoder to Http.request, but that, of course, fails when receiving XML. I asked the question on SO where it was suggested to use elm’s HTTP package directly, which can return the raw string instead of trying to parse it, but that doesn’t look simple to integrate with the package, or at least I don’t see how without re-implementing a good chunk of it.
Any suggestions on how to query the EC2 API ?