Sha256: 3522ec5453669796ae41ea0f1191da12aa1d841e3dd0ed137228491e825e73c4

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "aws_as_code"
require "thor"
require "cfndsl"
require "ostruct"

DEFAULT_RUBY_DIR = "cfn".freeze
DEFAULT_JSON_DIR = "cfn-compiled".freeze
DEFAULT_STACK = "master".freeze
DEFAULT_TEMPLATE = "environment".freeze

# Main CLI application for aws-as-code gem
class AwsAsCodeCli < Thor
  class_option :config_dir, default: DEFAULT_RUBY_DIR
  class_option :ruby_dir, default: DEFAULT_RUBY_DIR
  class_option :json_dir, default: DEFAULT_JSON_DIR
  class_option :bucket, required: true
  class_option :template, default: DEFAULT_TEMPLATE
  class_option :stack, default: DEFAULT_STACK
  class_option :stack_params, type: :hash, default: Hash[]
  class_option :version, required: true

  desc "compile", "compile cfndsl to CF JSON"
  def compile
    AwsAsCode::Task::Compile.new(config).execute
  end

  desc "upload", "upload compiled data to S3 bucket"
  def upload
    AwsAsCode::Task::Upload.new(config).execute
  end

  desc "do-create", "create a new stack"
  def do_create
    exit AwsAsCode::Task::Create.new(config).execute
  end

  desc "do-update", "update existing stack"
  def do_update
    exit AwsAsCode::Task::Update.new(config).execute
  end

  desc "create", "create a new stack"
  def create
    invoke :compile
    invoke :upload
    invoke :do_create
  end

  desc "update", "update existing stack"
  def update
    invoke :compile
    invoke :upload
    invoke :do_update
  end

  private

  def config
    @config ||= OpenStruct.new options
  end
end

AwsAsCodeCli.start(ARGV)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws_as_code-1.0.4 exe/aws-as-code
aws_as_code-1.0.3 exe/aws-as-code