lib/dpl/provider/code_deploy.rb in dpl-1.8.46.travis.2444.5 vs lib/dpl/provider/code_deploy.rb in dpl-1.8.46.travis.2449.5

- old
+ new

@@ -7,10 +7,14 @@ def code_deploy @code_deploy ||= Aws::CodeDeploy::Client.new(code_deploy_options) end + def s3api + @s3api ||= Aws::S3::Client.new(code_deploy_options) + end + def code_deploy_options code_deploy_options = { region: options[:region] || 'us-east-1', credentials: Aws::Credentials.new(access_key_id, secret_access_key) } @@ -37,17 +41,27 @@ when "" then options[:bucket] ? s3_revision : github_revision else error("unknown revision type %p" % options[:revision_type]) end end + def revision_version_info + s3obj = s3api.head_object({ + bucket: option(:bucket), + key: s3_key + }) + end + def s3_revision + s3info = revision_version_info { revision_type: 'S3', s3_location: { bucket: option(:bucket), bundle_type: bundle_type, - key: s3_key + key: s3_key, + version: s3info[:version_id], + e_tag: s3info[:etag] } } end def github_revision @@ -59,9 +73,19 @@ } } end def push_app + rev = revision() + if rev[:s3_location] + rev_info = rev[:s3_location] + log "Registering app revision with version=#{rev_info[:version]}, etag=#{rev_info[:e_tag]}" + end + code_deploy.register_application_revision({ + revision: rev, + application_name: options[:application] || option(:application_name), + description: options[:description] || default_description + }) data = code_deploy.create_deployment({ revision: revision, application_name: options[:application] || option(:application_name), deployment_group_name: options[:deployment_group] || option(:deployment_group_name), description: options[:description] || default_description