Paws XXXXII (A little help from my friends)
Now that I have at least one call working 'ListJobs' I reran the full test suit and to my surprise I got no fails. So maybe it is going to be an easy ride?
Well I was dead wrong.
Just spent the last few days banging my head against the AWS servers thinking that if the first 825 attempts to get 'CreateJob' to work, the 826th would of work.
I think I got sucked into the gambler's fallacy.
Well lets just say 826 attempt is most likely an order of magnitude under the number of differing combinations and iterations I went though on getting the call working all with the same failed of '403' status and the error 'SignatureDoesNotMatch'!
Desperate for help I search all over web for some sort of answer and I know I was in very uncharted territory when some of the answers to my plethora of questions, I was getting back where links back to my own posts on https://blogs.perl.org. No use using google to solve this problem for me.
The real frustrating thing was I had to call of 'CreateJob' at least working on a separate box using AWS2 CLI.
The number of rabbit holes I went down was astonishing. I had debugging everywhere in PAWs and a good number of of other perl mods peppered with debug as well.
I eventually tried a different call 'PutPublicAccessBlock' that had XML in the content. Of course I got that one to work. Alas that got me no closer to solution just many more iterations and frustrations.
In real desperation I reached out to a friend of mine David, a true master of all things server and perl related who can write more bug free code in an hour that I can in a month to ask, if he could give me a hand.
Well long story short he created a little test script, on his day of yet, that was isolated from PAWS and we set about recreating the call out to S3Control and all its signing parts.
Well after a good morning of playing about with our script and we finally got the good call 'ListJobs' to work and as expected the 'PutPublicAccessBlock' worked as well and all of the signing was correct.
We then tried the 'CreateJob' and we got a '405' response and a 'Missing sigining element' but at least our signatures matched and where being accepted by the server. While David was busily trying to spot a bug in the encoding, I had a closer look at the differences between the request we where sending on our isolated test script and the PAWs request.
Then I blundered upon the problem, in the headers of the PAWS request I had
'content-type' => 'application/x-www-form-urlencoded',
but on the successful 'PutPublicAccessBlock' we had ;
'content-type' => 'application/xml'
Well a quick add of that header in my Paws call and we started to get a '400' response with the error; 'InvalidRequest' Missing role arn.
Well I don't think I have ever been so happy to get an error on the server before.
Well it seems that this AWS service is very picky when it comes to expected content-type and REST Verbs. The GET, PUT and I would guess DELETE as well, all work fine with any content-type while the POST will only work with the XML type.
I guess this is a case of 'Occams Razor' but it was great working with David again all be it ever so briefly and another a big thank you out to him.
Now time to put all this code back into a clean state and get on with my life and another thanks to Skylos
Leave a comment