Class: StackMaster::StackDefinition

Inherits:
Object
  • Object
show all
Includes:
Utils::Initializable
Defined in:
lib/stack_master/stack_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Initializable

#attributes=

Constructor Details

#initialize(attributes = {}) ⇒ StackDefinition

Returns a new instance of StackDefinition.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/stack_master/stack_definition.rb', line 28

def initialize(attributes = {})
  @compiler_options = {}
  @notification_arns = []
  @s3 = {}
  @files = []
  @allowed_accounts = nil
  @ejson_file_kms = true
  @compiler = nil
  super
  @additional_parameter_lookup_dirs ||= []
  @base_dir ||= ""
  @template_dir ||= File.join(@base_dir, 'templates')
  @parameters_dir ||= File.join(@base_dir, 'parameters')
  @allowed_accounts = Array(@allowed_accounts)
  @parameters ||= {}
  @parameter_files ||= []
end

Instance Attribute Details

#additional_parameter_lookup_dirsObject

Returns the value of attribute additional_parameter_lookup_dirs.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def additional_parameter_lookup_dirs
  @additional_parameter_lookup_dirs
end

#allowed_accountsObject

Returns the value of attribute allowed_accounts.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def allowed_accounts
  @allowed_accounts
end

#base_dirObject

Returns the value of attribute base_dir.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def base_dir
  @base_dir
end

#compilerObject (readonly)

Returns the value of attribute compiler.



24
25
26
# File 'lib/stack_master/stack_definition.rb', line 24

def compiler
  @compiler
end

#compiler_optionsObject

Returns the value of attribute compiler_options.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def compiler_options
  @compiler_options
end

#ejson_fileObject

Returns the value of attribute ejson_file.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def ejson_file
  @ejson_file
end

#ejson_file_kmsObject

Returns the value of attribute ejson_file_kms.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def ejson_file_kms
  @ejson_file_kms
end

#ejson_file_regionObject

Returns the value of attribute ejson_file_region.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def ejson_file_region
  @ejson_file_region
end

#filesObject

Returns the value of attribute files.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def files
  @files
end

#notification_arnsObject

Returns the value of attribute notification_arns.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def notification_arns
  @notification_arns
end

#parameter_filesObject

Returns the value of attribute parameter_files.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def parameter_files
  @parameter_files
end

#parametersObject

Returns the value of attribute parameters.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def parameters
  @parameters
end

#parameters_dirObject

Returns the value of attribute parameters_dir.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def parameters_dir
  @parameters_dir
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def region
  @region
end

#role_arnObject

Returns the value of attribute role_arn.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def role_arn
  @role_arn
end

#s3Object

Returns the value of attribute s3.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def s3
  @s3
end

#stack_nameObject

Returns the value of attribute stack_name.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def stack_name
  @stack_name
end

#stack_policy_fileObject

Returns the value of attribute stack_policy_file.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def stack_policy_file
  @stack_policy_file
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def tags
  @tags
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def template
  @template
end

#template_dirObject

Returns the value of attribute template_dir.



3
4
5
# File 'lib/stack_master/stack_definition.rb', line 3

def template_dir
  @template_dir
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/stack_master/stack_definition.rb', line 46

def ==(other)
  self.class === other &&
    @region == other.region &&
    @stack_name == other.stack_name &&
    @template == other.template &&
    @tags == other.tags &&
    @role_arn == other.role_arn &&
    @allowed_accounts == other.allowed_accounts &&
    @notification_arns == other.notification_arns &&
    @base_dir == other.base_dir &&
    @ejson_file == other.ejson_file &&
    @ejson_file_region == other.ejson_file_region &&
    @ejson_file_kms == other.ejson_file_kms &&
    @stack_policy_file == other.stack_policy_file &&
    @additional_parameter_lookup_dirs == other.additional_parameter_lookup_dirs &&
    @s3 == other.s3 &&
    @compiler == other.compiler &&
    @compiler_options == other.compiler_options
end

#all_parameter_filesObject



91
92
93
94
95
96
97
# File 'lib/stack_master/stack_definition.rb', line 91

def all_parameter_files
  if parameter_files.empty?
    parameter_files_from_globs
  else
    parameter_files
  end
end

#files_dirObject



71
72
73
# File 'lib/stack_master/stack_definition.rb', line 71

def files_dir
  File.join(base_dir, 'files')
end

#parameter_file_globsObject



103
104
105
# File 'lib/stack_master/stack_definition.rb', line 103

def parameter_file_globs
  [ default_parameter_glob, region_parameter_glob ] + additional_parameter_lookup_globs
end

#parameter_files_from_globsObject



99
100
101
# File 'lib/stack_master/stack_definition.rb', line 99

def parameter_files_from_globs
  parameter_file_globs.map(&Dir.method(:glob)).flatten
end

#s3_configured?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/stack_master/stack_definition.rb', line 111

def s3_configured?
  !s3.nil?
end

#s3_filesObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/stack_master/stack_definition.rb', line 75

def s3_files
  files.inject({}) do |hash, file|
    path = File.join(files_dir, file)
    hash[file] = {
      path: path,
      body: File.read(path)
    }
    hash
  end
end

#s3_template_file_nameObject



86
87
88
89
# File 'lib/stack_master/stack_definition.rb', line 86

def s3_template_file_name
  return template if ['.json', '.yaml', '.yml'].include?(File.extname(template))
  Utils.change_extension(template, 'json')
end

#stack_policy_file_pathObject



107
108
109
# File 'lib/stack_master/stack_definition.rb', line 107

def stack_policy_file_path
  File.join(base_dir, 'policies', stack_policy_file) if stack_policy_file
end

#template_file_pathObject



66
67
68
69
# File 'lib/stack_master/stack_definition.rb', line 66

def template_file_path
  return unless template
  File.expand_path(template, template_dir)
end