Method: Stackup::Stack#create_or_update

Defined in:
lib/stackup/stack.rb

#create_or_update(options) ⇒ String Also known as: up

Create or update the stack.

Parameters:

Options Hash (options):

  • :capabilities (Array<String>) — default: CAPABILITY_NAMED_IAM

    list of capabilities required for stack template

  • :disable_rollback (boolean) — default: false

    if true, disable rollback if stack creation fails

  • :notification_arns (String)

    ARNs for the Amazon SNS topics associated with this stack

  • :on_failure (String) — default: ROLLBACK

    if stack creation fails: DO_NOTHING, ROLLBACK, or DELETE

  • :parameters (Hash, Array<Hash>)

    stack parameters, either as a Hash, or an Array of Aws::CloudFormation::Types::Parameter structures

  • :tags (Hash, Array<Hash>)

    stack tags, either as a Hash, or an Array of Aws::CloudFormation::Types::Tag structures

  • :resource_types (Array<String>)

    resource types that you have permissions to work with

  • :stack_policy (Hash)

    stack policy, as Ruby data

  • :stack_policy_body (String)

    stack policy, as JSON

  • :stack_policy_url (String)

    location of stack policy

  • :stack_policy_during_update (Hash)

    temporary stack policy, as Ruby data

  • :stack_policy_during_update_body (String)

    temporary stack policy, as JSON

  • :stack_policy_during_update_url (String)

    location of temporary stack policy

  • :template (Hash)

    stack template, as Ruby data

  • :template_body (String)

    stack template, as JSON or YAML

  • :template_url (String)

    location of stack template

  • :timeout_in_minutes (Integer)

    stack creation timeout

  • :use_previous_template (boolean)

    if true, reuse the existing template

Returns:

  • (String)

    resulting stack status

Raises:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/stackup/stack.rb', line 114

def create_or_update(options)
  options = options.dup
  if (template_data = options.delete(:template))
    options[:template_body] = MultiJson.dump(template_data)
  end
  if (parameters = options[:parameters])
    options[:parameters] = Parameters.new(parameters).to_a
  end
  if (tags = options[:tags])
    options[:tags] = normalize_tags(tags)
  end
  if (policy_data = options.delete(:stack_policy))
    options[:stack_policy_body] = MultiJson.dump(policy_data)
  end
  if (policy_data = options.delete(:stack_policy_during_update))
    options[:stack_policy_during_update_body] = MultiJson.dump(policy_data)
  end
  options[:capabilities] ||= ["CAPABILITY_NAMED_IAM"]
  delete if ALMOST_DEAD_STATUSES.include?(status)
  update(options)
rescue NoSuchStack
  create(options)
end