clojureamazon-ec2jcloudspallet

Get ec2 dns name via pallet


I get back a list of ec2 nodes using pallet. I want to get the dns names of these. I see that in jclouds there is a dnsName method, but I see no way to access this for use with pallet in clojure. Is this possible?

Details

I'm trying to make a modification to the storm-deploy project to work with dns names so that security groups work correctly. Specifically, I'm trying to write something like this function to use in the code:

(defn zookeeper-dns-names [compute name]
  (let [running-nodes (filter running?
    (map (partial jclouds-node->node compute) (nodes-in-group compute (str "zookeeper-" name))))]
    (map dns-name running-nodes)))

Solution

  • I'm using this in our pallet deployer which derives the dns name via the public ip:

    (defn get-aws-name []
      (let [ip (-> (target-node) bean :publicAddresses first)]
        (str "ec2-" (apply str (replace {\. \-} ip)) ".compute-1.amazonaws.com")))
    

    private IPs also work via security groups:

    (defn ips-in-group [group-name public-or-private]
      "Sequence of the first public IP from each node in the group"
      (->> (nodes-in-group group-name)
           (map bean)
           (map public-or-private)
           (map first))
    
    (defn public-ips-in-group
      "Sequence of the first public IP from each node in the group"
      [group-name]
      (ips-in-group group-name :publicAddresses))
    
    (defn private-ips-in-group
      "Sequence of the first public IP from each node in the group"
      [group-name]
      (ips-in-group group-name :privateAddresses))