Sha256: c53c20a12788dfd58e2fc00d871c98f24d9c2bb935bbeb9f52771d2e9a7d52e8

Contents?: true

Size: 806 Bytes

Versions: 15

Compression:

Stored size: 806 Bytes

Contents

module Lono::Template::Strategy::Dsl::Builder::Helpers
  module Ec2Helper
    extend Memoist

    def default_vpc
      resp = ec2.describe_vpcs(filters: [name: "isDefault", values: ["true"]])
      vpc = resp.vpcs.first
      vpc ? vpc.vpc_id : "no default vpc found"
    end
    memoize :default_vpc

    def default_subnets
      return "no default subnets because no default vpc found" if default_vpc == "no default vpc found"
      resp = ec2.describe_subnets(filters: [name: "vpc-id", values: [default_vpc]])
      subnets = resp.subnets
      subnets.map(&:subnet_id)
    end
    memoize :default_subnets

    def key_pairs(regexp=nil)
      resp = ec2.describe_key_pairs
      key_names = resp.key_pairs.map(&:key_name)
      key_names.select! { |k| k =~ regexp }
      key_names
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
lono-7.5.2 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.5.1 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.5.0 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.11 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.10 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.9 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.8 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.7 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.6 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.5 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.4 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.3 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.2 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.1 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb
lono-7.4.0 lib/lono/template/strategy/dsl/builder/helpers/ec2_helper.rb