umegaya / lua-aws

pure-lua implementation of aws REST APIs
122 stars 35 forks source link

TagSpecification does not have rules to serialize #53

Closed aryajur closed 6 years ago

aryajur commented 6 years ago

Hi, I was trying to add Tags when executing RunInstances. On stepping through the code I notice that there are no rules for TagSpecification Array and the function serialize_Struct in request/query_string_serializer.lua prints the message "has no rule to handle. ignored". How are these rules populated? How can we get the rule for TagSpecification?

Thanks, Milind

aryajur commented 6 years ago

I updated the APIs from aws sdk js and then ran it. It found tag specification this time but it complained about unknown parameter resourceType, key and value. So I had to go into ec2-2016-11-15.min.json and change those for TagSpecification to ResourceType, Key and Value. Now it works. I have created a pull request with those updates. I have also created a pull request into aws-sdk-js to get those changes in their json file.

umegaya commented 6 years ago

I guess first error is typo "TagSpecification", which should be "TagSpecifications". because current ec2 service definition already has TagSpecifications member in its request shape.

code to specify tag should be as following:

local cr = aws.EC2:api():runInstances({
        InstanceType = "t2.nano",
        MinCount = 2, 
        MaxCount = 2,
        TagSpecifications = { 
            -- according to aws doc, ResourceType is not necessary but moto_server (mock of ec2 API) crashes
            {ResourceType = "instance", Tags = {{Key = "name", Value = "lua-aws"}}},
        },
})

but even if I use correct name, there is error like following should happen, as you described.

<Response><Errors><Error><Code>UnknownParameter</Code><Message>The parameter resourceType is not recognized</Message></Error></Errors><RequestID>a5f36eb8-4144-4447-8f33-28a6252d7261</RequestID></Response>

after investigation, I found first character of struct or list request parameter member have to be upper case for query serializer. #55 is that fix (+ service definition update).

can you test your example also work with the fix? sorry for inconvenience caused again.

regards,

aryajur commented 6 years ago

Yes that works. Thanks!

aryajur commented 6 years ago

I am having a strange problem. If I use the latest commit then it is working fine on my windows computer but as soon as I use the same commit on an ubuntu server I get this error again:

parameter TagSpecifications has no rule to handle. ignored.

Driving me crazy. I don't know why it behaves differently there.

aryajur commented 6 years ago

Ok, when I deleted the ec2-2015* files from the services/specs directory then it worked. Somehow it was picking the older file. Is there an option I need to set to always choose the latest file?

aryajur commented 6 years ago

I think I found the problem. In the file services/base.lua the latest variable was not getting updated. I fixed that and created a pull request.

umegaya commented 6 years ago

ya, I see your #56 . sorry for taking your time. I will merge this after add proper test case. thanks!

also you can fix your version like following:

aws.Kinesis:api_by_version('2013-12-02')
umegaya commented 6 years ago

ok #56 merged. if you have any issue, feel free to reopen this :D

aryajur commented 6 years ago

Thank you very much!