Class: Automan::Cloudformation::Uploader
- Inherits:
-
Base
- Object
- Base
- Automan::Cloudformation::Uploader
show all
- Defined in:
- lib/automan/cloudformation/uploader.rb
Constant Summary
Mixins::AwsCaller::S3_PROTO
Instance Attribute Summary
Attributes inherited from Base
#logger, #wait
#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3
Instance Method Summary
collapse
Methods inherited from Base
add_option, #initialize, #log_options, #wait_until
#account, #configure_aws, #looks_like_s3_path?, #parse_s3_path, #s3_object_exists?, #s3_read
Constructor Details
This class inherits a constructor from Automan::Base
Instance Method Details
#all_templates_valid? ⇒ Boolean
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/automan/cloudformation/uploader.rb', line 22
def all_templates_valid?
if templates.empty?
raise NoTemplatesError, "No stack templates found for #{template_files}"
end
valid = true
templates.each do |template|
unless template_valid?(template)
valid = false
end
end
valid
end
|
#template_valid?(template) ⇒ Boolean
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/automan/cloudformation/uploader.rb', line 11
def template_valid?(template)
contents = File.read template
response = cfn.validate_template(contents)
if response.has_key?(:code)
logger.warn "#{template} is invalid: #{response[:message]}"
return false
else
return true
end
end
|
#templates ⇒ Object
7
8
9
|
# File 'lib/automan/cloudformation/uploader.rb', line 7
def templates
Dir.glob(template_files)
end
|
#upload_file(file) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/automan/cloudformation/uploader.rb', line 36
def upload_file(file)
opts = {
localfile: file,
s3file: "#{s3_path}/#{File.basename(file)}"
}
s = Automan::S3::Uploader.new opts
s.upload
end
|
#upload_templates ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/automan/cloudformation/uploader.rb', line 45
def upload_templates
log_options
unless all_templates_valid?
raise InvalidTemplateError, "There are invalid templates. Halting upload."
end
templates.each do |template|
upload_file(template)
end
end
|