module Backends::Ec2::Helpers::ComputeCreateHelper

Constants

COMPUTE_BASE64_REGEXP
COMPUTE_DN_BASED_AUTHS
COMPUTE_DONT_WAIT_FOR_STATUSES
COMPUTE_USER_DATA_SIZE_LIMIT

Public Instance Methods

compute_create_with_os_tpl(compute) click to toggle source
# File lib/backends/ec2/helpers/compute_create_helper.rb, line 11
def compute_create_with_os_tpl(compute)
  @logger.debug "[Backends] [Ec2Backend] Deploying #{compute.inspect}"

  # generate and amend inst options
  instance_opts = compute_create_instance_opts(compute)
  instance_opts = compute_create_add_inline_ntwrkintfs_vpc(compute, instance_opts)
  tags = compute_create_instance_tags(compute, instance_opts)

  instance_id = nil
  Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do
    ec2_response = @ec2_client.run_instances(instance_opts)
    instance_id = ec2_response.instances.first[:instance_id]

    @ec2_client.create_tags(
      resources: [instance_id],
      tags: tags
    )
  end

  # run post-inst actions
  compute_create_add_inline_strglnks(compute, instance_id)
  compute_create_add_inline_ntwrkintfs_elastic(compute, instance_id)

  instance_id
end