Class: Humidifier::AwsAdapters::Base

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

Overview

The parent class for the adapters for both versions of the SDK

Direct Known Subclasses

SDKV1, SDKV2

Instance Method Summary collapse

Instance Method Details

#create(payload) ⇒ Object

Create a CFN stack



7
8
9
10
11
12
13
# File 'lib/humidifier/aws_adapters/base.rb', line 7

def create(payload)
  try_valid do
    response = client.create_stack(payload.create_params)
    payload.id = response.stack_id
    response
  end
end

#delete(payload) ⇒ Object

Delete a CFN stack



16
17
18
19
# File 'lib/humidifier/aws_adapters/base.rb', line 16

def delete(payload)
  client.delete_stack(payload.delete_params)
  true
end

#deploy(payload) ⇒ Object

Update a CFN stack if it exists, otherwise create it



22
23
24
# File 'lib/humidifier/aws_adapters/base.rb', line 22

def deploy(payload)
  exists?(payload) ? update(payload) : create(payload)
end

#update(payload) ⇒ Object

Update a CFN stack



27
28
29
# File 'lib/humidifier/aws_adapters/base.rb', line 27

def update(payload)
  try_valid { client.update_stack(payload.update_params) }
end

#upload(payload) ⇒ Object

Upload a CFN stack to S3 so that it can be referenced via template_url



32
33
34
35
36
# File 'lib/humidifier/aws_adapters/base.rb', line 32

def upload(payload)
  Humidifier.config.ensure_upload_configured!(payload)
  filename = "#{Humidifier.config.s3_prefix}#{payload.identifier}.json"
  upload_object(payload, filename)
end

#valid?(payload) ⇒ Boolean

Validate a template in CFN

Returns:

  • (Boolean)


39
40
41
# File 'lib/humidifier/aws_adapters/base.rb', line 39

def valid?(payload)
  try_valid { client.validate_template(payload.validate_params) }
end