Module: Enscalator::Helpers::Wrappers

Included in:
Enscalator::Helpers
Defined in:
lib/enscalator/helpers/wrappers.rb

Overview

Helpers that wrap some

Instance Method Summary collapse

Instance Method Details

#cfn_client(region) ⇒ Aws::CloudFormation::Client

Cloudformation client

Parameters:

  • region (String)

    Region in Amazon AWS

Returns:

  • (Aws::CloudFormation::Client)

Raises:

  • (ArgumentError)

    when region is not given



10
11
12
13
14
15
# File 'lib/enscalator/helpers/wrappers.rb', line 10

def cfn_client(region)
  fail ArgumentError, 'Unable to proceed without region' if region.blank? && !Aws.config.key?(:region)
  opts = {}
  opts[:region] = region unless Aws.config.key?(:region)
  Aws::CloudFormation::Client.new(opts)
end

#cfn_resource(client) ⇒ Aws::CloudFormation::Resource

Cloudformation resource

Parameters:

  • client (Aws::CloudFormation::Client)

    instance of AWS Cloudformation client

Returns:

  • (Aws::CloudFormation::Resource)

Raises:

  • (ArgumentError)

    when client is not provided or its not expected class type



48
49
50
51
52
# File 'lib/enscalator/helpers/wrappers.rb', line 48

def cfn_resource(client)
  fail ArgumentError,
       'must be instance of Aws::CloudFormation::Client' unless client.instance_of?(Aws::CloudFormation::Client)
  Aws::CloudFormation::Resource.new(client: client)
end

#ec2_client(region) ⇒ Aws::EC2::Client

EC2 client

Parameters:

  • region (String)

    Region in Amazon AWS

Returns:

  • (Aws::EC2::Client)

Raises:

  • (ArgumentError)

    when region is not given



22
23
24
25
26
27
28
# File 'lib/enscalator/helpers/wrappers.rb', line 22

def ec2_client(region)
  fail ArgumentError, 'Unable to proceed without region' if region.blank? && !Aws.config.key?(:region)
  opts = {}
  opts[:region] = region unless Aws.config.key?(:region)
  # noinspection RubyArgCount
  Aws::EC2::Client.new(opts)
end

#route53_client(region) ⇒ Aws::Route53::Client

Route 53 client

Parameters:

  • region (String)

    AWS region identifier

Returns:

  • (Aws::Route53::Client)

Raises:

  • (ArgumentError)

    when region is not given



35
36
37
38
39
40
41
# File 'lib/enscalator/helpers/wrappers.rb', line 35

def route53_client(region)
  fail ArgumentError, 'Unable to proceed without region' if region.blank? && !Aws.config.key?(:region)
  opts = {}
  opts[:region] = region unless Aws.config.key?(:region)
  # noinspection RubyArgCount
  Aws::Route53::Client.new(opts)
end