@@ -102,9 +102,10 @@ def update_eb_environment(options = {})
102102 version_label = options [ :version_label ]
103103 auto_create = options [ :auto_create ]
104104
105- envs = AWS . elastic_beanstalk . client . describe_environments ( :application_name => ENV [ 'APP_NAME' ] , :environment_names => [ ENV [ 'ENVIRONMENT' ] ] )
106- puts "envs[:environments] = #{ envs [ :environments ] } "
107- env = envs [ 0 ]
105+ env = AWS . elastic_beanstalk . client . describe_environments ( :application_name => ENV [ 'APP_NAME' ] , :environment_names => [ ENV [ 'ENVIRONMENT' ] ] ) [ :environments ] . first
106+
107+ raise "Enviroment status \" #{ env [ :status ] } \" not supported" unless env [ :status ] =="Terminated" || env [ :status ] =="Ready"
108+
108109 unless env . nil? || env [ :status ] =="Terminated"
109110 if version_label . nil?
110111 AWS . elastic_beanstalk . client . update_environment ( :environment_name => ENV [ 'ENVIRONMENT' ] ,
@@ -254,9 +255,14 @@ def print_env
254255 desc "print the current env status"
255256 task :print_current_status do
256257 set_vars
257- env = AWS . elastic_beanstalk . client . describe_environments ( :application_name => ENV [ 'APP_NAME' ] , :environment_names => [ ENV [ 'ENVIRONMENT' ] ] ) . first
258- configuration_settings = AWS . elastic_beanstalk . client . describe_configuration_settings ( :application_name => ENV [ 'APP_NAME' ] , :environment_name => ENV [ 'ENVIRONMENT' ] ) [ :configuration_settings ] . first
259- configuration_settings [ :option_settings ] . each { |o | puts "#{ o [ :namespace ] } #{ o [ :option_name ] } =#{ o [ :value ] } " }
258+ env = AWS . elastic_beanstalk . client . describe_environments ( :application_name => ENV [ 'APP_NAME' ] , :environment_names => [ ENV [ 'ENVIRONMENT' ] ] ) [ :environments ] . first
259+ if env
260+ puts "Environment Status = #{ env [ :status ] } "
261+ configuration_settings = AWS . elastic_beanstalk . client . describe_configuration_settings ( :application_name => ENV [ 'APP_NAME' ] , :environment_name => ENV [ 'ENVIRONMENT' ] ) [ :configuration_settings ] . first
262+ configuration_settings [ :option_settings ] . each { |o | puts "#{ o [ :namespace ] } #{ o [ :option_name ] } =#{ o [ :value ] } " }
263+ else
264+ puts "(Warning) Environment \" #{ ENV [ 'ENVIRONMENT' ] } \" doesn't exist"
265+ end
260266 end
261267
262268 desc "upload project to s3"
0 commit comments