Sha256: 38260334fd41a934bb25f15eeb0360089d97743c8f75a830dd06bc9706adcd22

Contents?: true

Size: 1.19 KB

Versions: 27

Compression:

Stored size: 1.19 KB

Contents

module DPL
  class Provider
    class S3 < Provider
      requires 'aws-sdk'

      def api
        @api ||= AWS::S3.new
      end

      def needs_key?
        false
      end

      def check_app

      end

      def setup_auth
        AWS.config(:access_key_id => option(:access_key_id), :secret_access_key => option(:secret_access_key))
      end

      def check_auth
        setup_auth
        log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
      end

      def push_app
        Dir.glob("**/*") do |fileName|
          api.buckets[option(:bucket)].objects.create(fileName, File.read(fileName)) unless File.directory?(fileName)
        end
      end

      def deploy
        super
      rescue AWS::S3::Errors::InvalidAccessKeyId
        raise Error, "Invalid S3 Access Key Id, Stopping Deploy"
      rescue AWS::S3::Errors::SignatureDoesNotMatch
        raise Error, "Aws Secret Key does not match Access Key Id, Stopping Deploy"
      rescue AWS::S3::Errors::AccessDenied
        raise Error, "Oops, It looks like you tried to write to a bucket that isn't yours or doesn't exist yet. Please create the bucket before trying to write to it."
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
dpl-1.5.2.travis.248.2 lib/dpl/provider/s3.rb
dpl-1.5.3.travis.249.2 lib/dpl/provider/s3.rb
dpl-1.5.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.245.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.244.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.243.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.242.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.241.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.240.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.226.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.220.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.218.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.217.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.216.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.211.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.208.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.206.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.201.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.200.2 lib/dpl/provider/s3.rb
dpl-1.5.2.travis.197.2 lib/dpl/provider/s3.rb