Sha256: dc34abfab19a160cd9695c95080247eb343838ef80af7d28c5bfae9f8b06ad70

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

module Jets::Cfn
  class Download
    include Jets::AwsServices

    def download_templates(version)
      bucket = s3_resource.bucket(bucket_name)
      unless bucket.exists?
        puts "ERROR: The bucket #{bucket_name} does not exist.".color(:red)
        exit 1
      end

      # Cleanup templates folder
      FileUtils.rm_rf(Jets::Names.templates_folder)
      FileUtils.mkdir_p(Jets::Names.templates_folder)

      key_path = "jets/cfn-templates/versions/#{version}"
      objects = bucket.objects(prefix: key_path)
      if objects.count > 0
        objects.each do |object|
          file_name = "#{Jets::Names.templates_folder}/#{object.key.split('/').last}"
          object.get(response_target: file_name)
          puts "Downloaded #{file_name} from s3://#{bucket_name}/#{object.key}" if ENV['JETS_DEBUG']
        end
      else
        puts "ERROR: Cannot rollback to this version because the CloudFormation templates are not available.".color(:red)
        puts <<~EOL
          This can happen the app was deployed before Jets Pro features were enabled,
          or if the stack was delete and redeployed. Deleted stacks history are not
          rollbackable because their original s3 bucket is deleted.
        EOL
        exit 1
      end
    end

    def bucket_name
      Jets.s3_bucket
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/cfn/download.rb
jets-5.0.12 lib/jets/cfn/download.rb
jets-5.0.11 lib/jets/cfn/download.rb
jets-5.0.10 lib/jets/cfn/download.rb
jets-5.0.9 lib/jets/cfn/download.rb
jets-5.0.8 lib/jets/cfn/download.rb
jets-5.0.7 lib/jets/cfn/download.rb
jets-5.0.6 lib/jets/cfn/download.rb
jets-5.0.5 lib/jets/cfn/download.rb
jets-5.0.4 lib/jets/cfn/download.rb
jets-5.0.3 lib/jets/cfn/download.rb
jets-5.0.2 lib/jets/cfn/download.rb
jets-5.0.1 lib/jets/cfn/download.rb
jets-5.0.0 lib/jets/cfn/download.rb
jets-5.0.0.beta1 lib/jets/cfn/download.rb