class GeoEngineer::Resources::AwsAlbTargetGroup

AwsAlbTargetGroup is the aws_alb_target_group terrform resource,

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

Public Class Methods

_fetch_remote_resources(provider) click to toggle source
# File lib/geoengineer/resources/aws_alb_target_group.rb, line 31
def self._fetch_remote_resources(provider)
  target_groups = AwsClients.alb(provider).describe_target_groups.target_groups
  return [] if target_groups.empty?

  tags = AwsClients.alb(provider)
                   .describe_tags({ resource_arns: target_groups.map(&:target_group_arn) })
                   .tag_descriptions
                   .map(&:to_h)

  _merge_attributes(target_groups.map(&:to_h), tags)
end
_merge_attributes(target_groups, tags) click to toggle source
# File lib/geoengineer/resources/aws_alb_target_group.rb, line 19
def self._merge_attributes(target_groups, tags)
  target_groups.map do |target_group|
    target_tags = tags.find { |desc| desc[:resource_arn] == target_group[:target_group_arn] }
    target_group.merge(
      {
        _terraform_id: target_group[:target_group_arn],
        _geo_id: (target_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_target_group.rb, line 15
def short_type
  "alb_target_group"
end