aws

http://status.aws.amazon.com/ https://www.expeditedssl.com/aws-in-plain-english
2019-01-03T00:14:50.018400Z

hi! Does anyone know if there is a programmatic way to discover what AMIs are available in the marketplace? e.g. the identifier of all deep learning AMIs?

2019-01-03T16:17:21.019300Z

@dottedmag that looks interesting. I will check it out. Thank-you

2019-01-03T18:16:40.019800Z

hmmm. not sure this is working well just yet, but something along these lines:

(defn find-AMIs
  "Search the `Name` field for a matching string in all available AMIs."
  ;; <https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html>
  [regex-string]
  (let [re (re-pattern (str ".*" regex-string ".*"))
        ami-maps (:Images (aws/invoke ec2-client {:op :DescribeImages
                                                  :request {:Filters [{:Public true}]
                                                            ;;:DryRun true
                                                            }}))
        ami-names (-&gt;&gt; ami-maps
                      (mapv :Name)
                      (filterv #(not (nil? %))))
        ami-name-matches (-&gt;&gt; ami-names
                              (filterv #(re-matches re)))
        ]
    (vec ami-name-matches)
    ))

2019-01-03T18:17:46.020700Z

the idea is that you could then seek out deeplearning AMI’s with (find-AMIs “deeplearning”) or so

gws 2019-01-03T19:04:34.022100Z

you can also use their filter syntax, this one filters on the Description field but you can do it with Name as well: aws ec2 describe-images --owners amazon --filters 'Name=description,Values=*deep learning*' 'Name=state,Values=available' --output json - it should be easy enough to do something like that with the function you have there

2019-01-03T19:06:03.023500Z

I saw that but I didn’t have time to figure it out just yet. If you have a sense for it, please lmk

2019-01-03T19:07:17.024900Z

also, I believe the AMIs would need “deep*learning” since deeplearning strings are common

gws 2019-01-03T19:07:18.025Z

Something like: {:Filters [{:State "available"} {:Description (str "*" regex-string "*")}]}

gws 2019-01-03T19:07:45.026Z

yeah, you can do that too

2019-01-03T19:07:48.026100Z

I’ll give that a try

gws 2019-01-03T19:11:36.026500Z

this helps explain what you can do: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html#Filtering_Resources_CLI

gws 2019-01-03T19:12:43.027600Z

it's a case-sensitive search, so you might still need to fetch all of them and run them through a filter as you've done, just depends on your requirements

2019-01-03T19:12:46.027700Z

I recall now, I tried what you suggest and it doesn’t return any results

2019-01-03T19:13:00.028100Z

That’s why I opted to just use clojure’s filterv

2019-01-03T19:13:17.028400Z

but I think it was an error on my part

2019-01-03T19:13:32.028700Z

give me a few minutes, I think I can get it working

2019-01-03T19:17:24.029400Z

interesting. I ran one without the filter and one with the filter. Both return a count of 84214.

2019-01-03T19:17:52.029800Z

I think there are roughly 116 or so deeplearning AMIs

2019-01-03T19:20:20.030200Z

…which is what the filterv version returns

gws 2019-01-03T22:56:57.032800Z

well feel free to ignore that suggestion if it doesn't work! I kind of want to know why now though, but there's nothing incorrect about the filter solution certainly, unless you're worried about API limits or conservation of network resources

grzm 2019-01-03T23:13:06.033900Z

I think I must be missing it, but I don’t see Cloudwatch among the releases for the cognitect aws client api. https://github.com/cognitect-labs/aws-api/blob/master/latest-releases.edn

alexmiller 2019-01-03T23:39:43.035900Z

Might be best to file a github issue so this doesn’t get lost - I don’t know off the top of my head

👍 1
2019-01-03T23:59:56.038200Z

@gws, I don’t doubt there is a way to make the filter part work in the request. I just haven’t found it yet and the clojure side filter does in fact work. At some point, I hope to be able to devote time to figuring out the request side filter but can’t at the moment (and the workaround suffices)