class GeoEngineer::Resources::AwsAlb

AwsAlb is the aws_alb terrform resource,

{www.terraform.io/docs/providers/aws/r/alb.html Terraform Docs}

Public Class Methods

_fetch_remote_resources(provider) click to toggle source
# File lib/geoengineer/resources/aws_alb.rb, line 30
def self._fetch_remote_resources(provider)
  albs = AwsClients.alb(provider).describe_load_balancers['load_balancers'].map(&:to_h)
  return [] if albs.empty?

  tags = AwsClients.alb(provider)
                   .describe_tags({ resource_arns: albs.map { |alb| alb[:load_balancer_arn] } })
                   .tag_descriptions
                   .map(&:to_h)

  _merge_attributes(albs, tags)
end
_merge_attributes(albs, tags) click to toggle source
# File lib/geoengineer/resources/aws_alb.rb, line 18
def self._merge_attributes(albs, tags)
  albs.map do |alb|
    alb_tags = tags.find { |desc| desc[:resource_arn] == alb[:load_balancer_arn] }
    alb.merge(
      {
        _terraform_id: alb[:load_balancer_arn],
        _geo_id: alb_tags[:tags]&.find { |tag| tag[:key] == "Name" }.dig(:value)
      }
    )
  end
end

Public Instance Methods

short_type() click to toggle source
# File lib/geoengineer/resources/aws_alb.rb, line 14
def short_type
  "alb"
end