Class: Humidifier::AwsAdapters::SDKV2

Inherits:
Base
  • Object
show all
Defined in:
lib/humidifier/aws_adapters/sdkv2.rb

Overview

The adapter for v2 of aws-sdk

Direct Known Subclasses

SDKV3

Constant Summary collapse

TIME_FORMAT =

Format of the timestamp used in changeset naming

'%Y-%m-%d-%H-%M-%S'

Instance Method Summary collapse

Methods inherited from Base

#create, #delete, #deploy, #update, #upload, #valid?

Instance Method Details

#create_change_set(payload) ⇒ Object

Create a change set in CFN



11
12
13
14
15
# File 'lib/humidifier/aws_adapters/sdkv2.rb', line 11

def create_change_set(payload)
  change_set_name = "changeset-#{Time.now.strftime(TIME_FORMAT)}"
  payload.merge(change_set_name: change_set_name)
  try_valid { client.create_change_set(payload.create_change_set_params) }
end

#deploy_change_set(payload) ⇒ Object

Create a change set if the stack exists, otherwise create the stack



18
19
20
# File 'lib/humidifier/aws_adapters/sdkv2.rb', line 18

def deploy_change_set(payload)
  exists?(payload) ? create_change_set(payload) : create(payload)
end

#exists?(payload) ⇒ Boolean

True if the stack exists in CFN

Returns:

  • (Boolean)


23
24
25
# File 'lib/humidifier/aws_adapters/sdkv2.rb', line 23

def exists?(payload)
  base_module::CloudFormation::Stack.new(name: payload.identifier).exists?
end