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 00cb7c6
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions lib/dpl/providers/elasticbeanstalk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Elasticbeanstalk < Provider
msgs login: 'Using Access Key: %{access_key_id}',
zip_add: 'Adding %s'

msgs clean_description: 'Removed non-printable characters from the version description'
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 00cb7c6

Please sign in to comment.