Module: Backends::Ec2::Helpers::ComputeCreateHelper

Included in:
Compute
Defined in:
lib/backends/ec2/helpers/compute_create_helper.rb

Constant Summary collapse

COMPUTE_BASE64_REGEXP =
/^[A-Za-z0-9+\/]+={0,2}$/
COMPUTE_USER_DATA_SIZE_LIMIT =
16384
COMPUTE_DONT_WAIT_FOR_STATUSES =
['shutting-down', 'terminated', 'stopping', 'stopped'].freeze
COMPUTE_DN_BASED_AUTHS =
%w(x509 voms).freeze

Instance Method Summary collapse

Instance Method Details

#create_with_os_tpl(compute) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/backends/ec2/helpers/compute_create_helper.rb', line 10

def create_with_os_tpl(compute)
  @logger.debug "[Backends] [Ec2] Deploying #{compute.inspect}"

  # generate and amend inst options
  instance_opts = create_instance_opts(compute)
  instance_opts = create_add_inline_ntwrkintfs_vpc(compute, instance_opts)
  tags = 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
  create_add_inline_strglnks(compute, instance_id)
  create_add_inline_ntwrkintfs_elastic(compute, instance_id)

  instance_id
end