Class: CloudFormula::CloudFormation

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudformula/cloud_formation.rb

Class Method Summary collapse

Class Method Details

.create_stack(region, stack_name, template, override_options = {}, parameters = {}, aws_access_key_id = nil, aws_secret_key = nil) ⇒ AWS::CloudFormation::Stack

Convenience method which creates a new CloudFormation stack.

Parameters:

  • region (String)

    A valid AWS region, e.g. “us-east-1”, “us-west-2”, etc

  • stack_name (String)
  • template (CloudFormula::Template)
  • override_options (Hash) (defaults to: {})

    Optional. Stack options to override. See README.md “CloudFormation stack options” for details

  • parameters (Hash) (defaults to: {})

    Optional. Parameters to supply to the template.

  • aws_access_key_id (String) (defaults to: nil)

    Optional. If not supplied, AWS_ACCESS_KEY_ID must exist in ENV

  • aws_secret_key (String) (defaults to: nil)

    Optional. If not supplied, AWS_SECRET_ACCESS_KEY must exist in ENV

Returns:

  • (AWS::CloudFormation::Stack)


16
17
18
19
20
# File 'lib/cloudformula/cloud_formation.rb', line 16

def create_stack(region, stack_name, template, override_options = {}, parameters = {}, aws_access_key_id = nil, aws_secret_key = nil)
  validate template
  cfm = get_cloud_formation region, aws_access_key_id, aws_secret_key
  cfm.stacks.create(stack_name, template.generate, template.aws_options(override_options, parameters))
end

.update_stack(region, stack_name, template, parameters = {}, aws_access_key_id = nil, aws_secret_key = nil) ⇒ Object

Convenience method which updates an existing CloudFormation stack.

Parameters:

  • region (String)

    A valid AWS region, e.g. “us-east-1”, “us-west-2”, etc

  • stack_name (String)
  • template (CloudFormula::Template)
  • parameters (Hash) (defaults to: {})

    Optional. Parameters to supply to the template.

  • aws_access_key_id (String) (defaults to: nil)

    Optional. If not supplied, AWS_ACCESS_KEY_ID must exist in ENV

  • aws_secret_key (String) (defaults to: nil)

    Optional. If not supplied, AWS_SECRET_ACCESS_KEY must exist in ENV

Returns:

  • nil



31
32
33
34
35
36
# File 'lib/cloudformula/cloud_formation.rb', line 31

def update_stack(region, stack_name, template, parameters = {}, aws_access_key_id = nil, aws_secret_key = nil)
  validate template
  cfm = get_cloud_formation region, aws_access_key_id, aws_secret_key
  stack = cfm.stacks[stack_name]
  stack.update({ :template => template.generate, :parameters => parameters })
end