Class: AwsHelpers::ElasticBeanstalk::VersionFile

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_helpers/elastic_beanstalk/version_file.rb

Direct Known Subclasses

VersionZipFolder

Instance Method Summary collapse

Constructor Details

#initialize(s3_client, iam_client, application, version, contents) ⇒ VersionFile

Returns a new instance of VersionFile


5
6
7
8
9
10
11
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 5

def initialize(s3_client, iam_client, application, version, contents)
  @s3_client = s3_client
  @iam_client = iam_client
  @application = application
  @version = version
  @contents = contents
end

Instance Method Details

#bucketObject


30
31
32
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 30

def bucket
  @bucket ||= query_bucket_name
end

#file_nameObject


26
27
28
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 26

def file_name
  @file_name ||= "#{@application}-#{@version}.aws.json"
end

#query_bucket_nameObject


34
35
36
37
38
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 34

def query_bucket_name
  region = @iam_client.config.region
   = @iam_client.list_users[:users].first[:arn][/::(.*):/, 1]
  "elasticbeanstalk-#{region}-#{}"
end

#upload_to_s3Object


13
14
15
16
17
18
19
20
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 13

def upload_to_s3
  puts "Uploading #{file_name} to S3 bucket #{bucket} "
  @s3_client.put_object(
    bucket: bucket,
    key: file_name,
    body: @contents
  )
end

#versionObject


22
23
24
# File 'lib/aws_helpers/elastic_beanstalk/version_file.rb', line 22

def version
  @version
end