class CFnDK::GlobalConfig

Attributes

package[R]
post_command[R]
pre_command[R]
profile[R]
region[R]
role_arn[R]
s3_template_bucket[R]
s3_template_hash[R]
timeout_in_minutes[R]

Public Class Methods

new(data, option) click to toggle source
# File lib/cfndk/global_config.rb, line 4
def initialize(data, option)
  @timeout_in_minutes = 1
  @s3_template_bucket = 'cfndk-templates'
  @s3_template_hash = Uuid.instance.uuid
  @region = ENV['AWS_REGION'] || 'us-east-1'
  @package = false
  @profile = ENV['AWS_PROFILE'] || nil
  return unless data['global'].is_a?(Hash)
  @timeout_in_minutes = data['global']['timeout_in_minutes'] || 1
  @s3_template_bucket = data['global']['s3_template_bucket'] || 'cfndk-templates'
  @region = data['global']['region'] || ENV['AWS_REGION'] || 'us-east-1'
  @package = data['global']['package'] === 'true' ? true : false
  @role_arn = data['global']['role_arn'] || nil
  @profile = ENV['AWS_PROFILE'] || data['global']['default_profile'] || nil
  @pre_command = data['global']['pre_command'] || nil
  @post_command = data['global']['post_command'] || nil
end

Public Instance Methods

post_command_execute() click to toggle source
# File lib/cfndk/global_config.rb, line 34
def post_command_execute
  if @post_command
    CFnDK.logger.info(('execute global post command: ' + @post_command).color(:green))
    IO.popen(@post_command, :err => [:child, :out]) do |io|
      io.each_line do |line|
        CFnDK.logger.info((line).color(:green))
      end
    end
    raise 'global post command is error. status: ' + $?.exitstatus.to_s + ' command: ' + @post_command if $?.exitstatus != 0
  end
end
pre_command_execute() click to toggle source
# File lib/cfndk/global_config.rb, line 22
def pre_command_execute
  if @pre_command
    CFnDK.logger.info(('execute global pre command: ' + @pre_command).color(:green))
    IO.popen(@pre_command, :err => [:child, :out]) do |io|
      io.each_line do |line|
        CFnDK.logger.info((line).color(:green))
      end
    end
    raise 'global pre command is error. status: ' + $?.exitstatus.to_s + ' command: ' + @pre_command if $?.exitstatus != 0
  end
end