Skip to content

Commit

Permalink
If application version already exists, use it
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjurkiewicz committed Mar 31, 2020
1 parent 793b282 commit 7c13c22
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions lib/dpl/providers/elasticbeanstalk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Elasticbeanstalk < Provider
zip_add: 'Adding %s'

msgs clean_description: 'Removed non-printable characters from the version description'
app_ver_exists: 'Application version already exists, skipping upload and using existing version'

attr_reader :started, :object, :version

Expand Down Expand Up @@ -109,16 +110,28 @@ def upload
end

def create_version
@version = eb.create_application_version(
application_name: app,
version_label: label,
description: clean(description[0, 200]),
source_bundle: {
s3_bucket: bucket.name,
s3_key: object.key
},
auto_create_application: false
)
begin
@version = eb.create_application_version(
application_name: app,
version_label: label,
description: clean(description[0, 200]),
source_bundle: {
s3_bucket: bucket.name,
s3_key: object.key
},
auto_create_application: false
)
rescue rescue Aws::ElasticBeanstalk::Errors::ServiceError => e
raise e unless e.message.match?(/^Application Version [^ ]+ already exists.$/)
info :app_ver_exists
ver = eb.describe_application_versions({
application_name: app,
version_labels: [label],
}).application_versions[0]
@version = { application_version: ver }
end


end

def update_app
Expand Down

0 comments on commit 7c13c22

Please sign in to comment.