Class: CloudfrontS3Invalidator::CloudfrontClient

Inherits:
Object
  • Object
show all
Defined in:
lib/cf-s3-invalidator.rb

Instance Method Summary collapse

Constructor Details

#initialize(aws_account, aws_secret, distribution) ⇒ CloudfrontClient

Returns a new instance of CloudfrontClient.



10
11
12
13
14
# File 'lib/cf-s3-invalidator.rb', line 10

def initialize(, aws_secret, distribution)
  @aws_account = 
  @aws_secret = aws_secret
  @distribution = distribution
end

Instance Method Details

#get_s3_bucket_nameObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cf-s3-invalidator.rb', line 16

def get_s3_bucket_name
  res = sign_and_call(
    "https://cloudfront.amazonaws.com/2012-05-05/distribution/#{@distribution}",
    Net::HTTP::Get)
  matches =
    res.body.scan(/<DomainName>([\w|\.|\-]+)\.s3([\w|\-]*)\.amazonaws\.com<\/DomainName>/)
  if matches.empty?
    nil
  else
    s3_bucket_name = matches.first.first
    s3_bucket_name
  end
end