Method: Stackup::ChangeSet#create

Defined in:
lib/stackup/change_set.rb

#create(options = {}) ⇒ String

Create the change-set.

Refer Aws::CloudFormation::Client#create_change_set

(see http://docs.aws.amazon.com/sdkforruby/api/Aws/CloudFormation/Client.html#create_change_set-instance_method)

Parameters:

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

    change-set options

Options Hash (options):

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

    list of capabilities required for stack template

  • :description (String)

    change-set description

  • :notification_arns (String)

    ARNs for the Amazon SNS topics associated with this stack

  • :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

  • :template (Hash)

    stack template, as Ruby data

  • :template_body (String)

    stack template, as JSON or YAML

  • :template_url (String)

    location of stack template

  • :use_previous_template (boolean)

    if true, reuse the existing template

  • :force (boolean)

    if true, delete any existing change-set of the same name

Returns:

  • (String)

    change-set id

Raises:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/stackup/change_set.rb', line 53

def create(options = {})
  options = options.dup
  options[:stack_name] = stack.name
  options[:change_set_name] = name
  options[:change_set_type] = stack.exists? ? "UPDATE" : "CREATE"
  force = options.delete(:force)
  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
  options[:capabilities] ||= ["CAPABILITY_NAMED_IAM"]
  delete if force
  handling_cf_errors do
    cf_client.create_change_set(options)
    loop do
      current = describe
      logger.debug("change_set_status=#{current.status}")
      case current.status
      when /COMPLETE/
        return current.status
      when "FAILED"
        logger.error(current.status_reason)
        fail StackUpdateError, "change-set creation failed" if status == "FAILED"
      end
      sleep(wait_poll_interval)
    end
    status
  end
end