pokepay / aws-sdk-lisp

AWS-SDK for Common Lisp
87 stars 19 forks source link

ec2 doesn't work with :filters parameter #30

Open Gleefre opened 1 year ago

Gleefre commented 1 year ago

Consider the following request:

(aws/ec2:describe-instances :filters (list (aws/ec2:make-filter :name "filter-1"
                                                                :values (list "val-1" "val-2"))
                                           (aws/ec2:make-filter :name "filter-2"
                                                                :values (list "val-3"))))

An error occurs:

;; sbcl
The value of QURI.ENCODE::VALUE is #S(AWS-SDK/SERVICES/EC2/API:FILTER
                                      :NAME "filter-1"
                                      :VALUES ("val-1" "val-2")), which is not of type (OR
                                                                                        STRING
                                                                                        NUMBER
                                                                                        (SIMPLE-ARRAY
                                                                                         (UNSIGNED-BYTE
                                                                                          8)
                                                                                         (*))).
   [Condition of type SIMPLE-TYPE-ERROR]

After some investigation, it seems that ec2-request is not generated properly when :filters argument is presented. The generated request has following request-params:

(("Action" . "DescribeInstances") ("Version" . "2016-11-15")
 ("Filters.member.1"
  . #S(AWS-SDK/SERVICES/EC2/API:FILTER
       :NAME "filter-1"
       :VALUES ("val-1" "val-2")))
 ("Filters.member.2"
  . #S(AWS-SDK/SERVICES/EC2/API:FILTER :NAME "filter-2" :VALUES ("val-3"))))

instead of something like this:

(("Action" . "DescribeInstances") ("Version" . "2016-11-15")
 ("Filters.member.1.Name" . "filter-1")
 ("Filters.member.1.Values.member.1" . "val-1")
 ("Filters.member.1.Values.member.2" . "val-2")
 ("Filters.member.2.Name" . "filter-2")
 ("Filters.member.2.Values.member.1" . "val-3"))
dtenny commented 1 year ago

Just to follow up here, the ec2 describe-instances logic has a number of problems,

Here's the sample incorrect params for :instance-ids

    (let ((dex:*verbose* :debug))
           (aws/ec2:describe-instances :instance-ids '("i-0ff9a89a4b89353c0")))

    POST /?Action=DescribeInstances&Version=2016-11-15&InstanceIds.1=i-0ff9a89a4b89353c0 HTTP/1.1

Sorry there won't be any patches from me, I solved my problem other ways and have moved on. I like that the project is trying to build a comprehensive interface, good luck!