From 71ef68773d9408b17acee774100e7bba8d8a27dd Mon Sep 17 00:00:00 2001 From: cpinera Date: Sun, 7 Apr 2013 20:00:14 -0700 Subject: [PATCH 1/3] Added proxy support --- README.md | 8 ++++++++ src/leiningen/beanstalk/aws.clj | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64cd8c0..5dd67af 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,14 @@ The following regions are recognized: * `us-west-1` * `us-west-2` +### Proxy + +You can specify the proxy server to use for deployment +your `project.clj` file: +```clojure +:aws {:beanstalk {:proxy-host "proxy.host" + :proxy-port 1080}} +``` ## Trouble-Shooting diff --git a/src/leiningen/beanstalk/aws.clj b/src/leiningen/beanstalk/aws.clj index d0065c2..be78b39 100644 --- a/src/leiningen/beanstalk/aws.clj +++ b/src/leiningen/beanstalk/aws.clj @@ -7,6 +7,7 @@ java.text.SimpleDateFormat java.util.Date [java.util.logging Logger Level] + com.amazonaws.ClientConfiguration com.amazonaws.auth.BasicAWSCredentials com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalkClient com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting @@ -78,17 +79,24 @@ (when-not (.doesBucketExist client bucket) (.createBucket client bucket))) +(defn- client-configuration [project] + "Create an instance of ClientConfiguration with the proxies set, if available" + (let [client-config (ClientConfiguration.)] + (when (-> project :aws :beanstalk :proxy-host) (.setProxyHost client-config (-> project :aws :beanstalk :proxy-host))) + (when (-> project :aws :beanstalk :proxy-port) (.setProxyPort client-config (-> project :aws :beanstalk :proxy-port))) + client-config)) + (defn s3-upload-file [project filepath] (let [bucket (s3-bucket-name project) file (io/file filepath)] - (doto (AmazonS3Client. (credentials project)) + (doto (AmazonS3Client. (credentials project) (client-configuration project)) (.setEndpoint (project-endpoint project s3-endpoints)) (create-bucket bucket) (.putObject bucket (.getName file) file)) (println "Uploaded" (.getName file) "to S3 Bucket"))) (defn- beanstalk-client [project] - (doto (AWSElasticBeanstalkClient. (credentials project)) + (doto (AWSElasticBeanstalkClient. (credentials project) (client-configuration project)) (.setEndpoint (project-endpoint project beanstalk-endpoints)))) (defn create-app-version From 788bcc7ae5c126cafbe15371b322b3bb888e78c2 Mon Sep 17 00:00:00 2001 From: cpinera Date: Fri, 3 May 2013 10:15:47 -0700 Subject: [PATCH 2/3] Added support for defining VPC options as part of the environment keys --- src/leiningen/beanstalk/aws.clj | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/leiningen/beanstalk/aws.clj b/src/leiningen/beanstalk/aws.clj index be78b39..84bb841 100644 --- a/src/leiningen/beanstalk/aws.clj +++ b/src/leiningen/beanstalk/aws.clj @@ -148,6 +148,15 @@ key) value))) +(defn vpc-options [project options] + (for [[key value] (:vpc options)] + (ConfigurationOptionSetting. + "aws:ec2:vpc" + (if (keyword? key) + (-> key name str/upper-case (str/replace "-" "_")) + key) + value))) + (defn create-environment [project env] (println (str "Creating '" (:name env) "' environment") "(this may take several minutes)") @@ -157,7 +166,7 @@ (.setApplicationName (app-name project)) (.setEnvironmentName (:name env)) (.setVersionLabel (app-version project)) - (.setOptionSettings (env-var-options project env)) + (.setOptionSettings (into (env-var-options project env) (vpc-options project env))) (.setCNAMEPrefix (:cname-prefix env)) (.setSolutionStackName (or (-> project :aws :beanstalk :stack-name) "32bit Amazon Linux running Tomcat 7"))))) @@ -168,7 +177,7 @@ (doto (UpdateEnvironmentRequest.) (.setEnvironmentId (.getEnvironmentId env)) (.setEnvironmentName (.getEnvironmentName env)) - (.setOptionSettings (env-var-options project options))))) + (.setOptionSettings (into (env-var-options project env) (vpc-options project env)))))) (defn update-environment-version [project env] (.updateEnvironment From 00e28054e352b984304ae53e312736f6b0f4b010 Mon Sep 17 00:00:00 2001 From: cpinera Date: Fri, 3 May 2013 10:34:36 -0700 Subject: [PATCH 3/3] Updated readme with a description for the new VPC options --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 5dd67af..df8e6eb 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,20 @@ If the environment variable name is a keyword, it is upper-cased and underscores ("_") are substituted for dashes ("-"). e.g. `:database-url` becomes `"DATABASE_URL"`. +### VPC options + +You can specify the VPC options of an environment. +```clojure +:aws +{:beanstalk + {:environments + [{:name "dev" + :vpc {"VPCId" "vpc-43498" + "Subnets" "subnet-32c4595f" + "ELBSubnets" "subnet-35c4595d" + "DBSubnets" "subnet-38r4595f, subnet-4fdc9633, subnet-e9dc96554"}}]}} +``` + ### S3 Buckets [Amazon Elastic Beanstalk][1] uses