methods/cf_client.rb
# Create AWS CF Stack from template
Create AWS CF Stack from template
Create AWS CF Stack from template
def configure_aws_cf_stack(options)
  if not options['name'].to_s.match(/[A-Z]|[a-z]|[0-9]/) or options['name'].to_s.match(/^none$/)
    handle_output(options,"Warning:\tNo name specified for AWS CloudFormation Stack")
    quit(options)
  end
  if not options['file'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
    if not options['bucket'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
      if not options['object'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
        handle_output(options,"Warning:\tNo file, bucket, or object specified for AWS CloudFormation Stack")
        quit(options)
      end
    else
      if not options['object'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
        handle_output(options,"Warning:\tNo object specified for AWS CloudFormation Stack")
        quit(options)
      else
        options['file'] = get_s3_bucket_private_url(options)
      end
    end
  end
  if not options['key'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
    handle_output(options,"Warning:\tNo Key Name given")
    if not options['keyfile'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
      options['key'] = options['name']
    else
      options['key'] = File.basename(options['keyfile'])
      options['key'] = options['key'].split(/\./)[0..-2].join
    end
    handle_output(options,"Information:\tSetting Key Name to #{options['key']}")
  end
  if not options['key'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
    options['group'] = options['name']
  end
  if options['nosuffix'] == false
    options['name']  = get_aws_uniq_name(options['name'],options['region'])
    options['key']   = get_aws_uniq_name(options['key'],options['region'])
    options['group'] = get_aws_uniq_name(options['group'],options['region'])
  end
  if not options['keyfile'].to_s.match(/[A-Z]|[a-z]|[0-9]/)
    options['keyfile'] = options['keydir']+"/"+options['key']+".pem"
    handle_output(options,"Information:\tSetting Key file to #{options['keyfile']}")
  end
  create_aws_cf_stack_config(options)
  create_aws_cf_stack(options)
  return
end
def configure_aws_cf_stack ( options ) if not options [ 'name' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) or options [ 'name' ] . to_s . match ( / ^none$ / ) handle_output ( options , "Warning:\tNo name specified for AWS CloudFormation Stack" ) quit ( options ) end if not options [ 'file' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) if not options [ 'bucket' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) if not options [ 'object' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) handle_output ( options , "Warning:\tNo file, bucket, or object specified for AWS CloudFormation Stack" ) quit ( options ) end else if not options [ 'object' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) handle_output ( options , "Warning:\tNo object specified for AWS CloudFormation Stack" ) quit ( options ) else options [ 'file' ] = get_s3_bucket_private_url ( options ) end end end if not options [ 'key' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) handle_output ( options , "Warning:\tNo Key Name given" ) if not options [ 'keyfile' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) options [ 'key' ] = options [ 'name' ] else options [ 'key' ] = File . basename ( options [ 'keyfile' ] ) options [ 'key' ] = options [ 'key' ] . split ( / \. / ) [ 0 .. - 2 ] . join end handle_output ( options , "Information:\tSetting Key Name to #{options['key']}" ) end if not options [ 'key' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) options [ 'group' ] = options [ 'name' ] end if options [ 'nosuffix' ] == false options [ 'name' ] = get_aws_uniq_name ( options [ 'name' ] , options [ 'region' ] ) options [ 'key' ] = get_aws_uniq_name ( options [ 'key' ] , options [ 'region' ] ) options [ 'group' ] = get_aws_uniq_name ( options [ 'group' ] , options [ 'region' ] ) end if not options [ 'keyfile' ] . to_s . match ( / [A-Z]|[a-z]|[0-9] / ) options [ 'keyfile' ] = options [ 'keydir' ] + "/" + options [ 'key' ] + ".pem" handle_output ( options , "Information:\tSetting Key file to #{options['keyfile']}" ) end create_aws_cf_stack_config ( options ) create_aws_cf_stack ( options ) return end
Create AWS CF Stack from template
Create AWS CF Stack from template
options
<not_specific>