Created
February 18, 2020 12:24
-
-
Save samof76/d7e6d9ec1b55a62df61c435381d81cf6 to your computer and use it in GitHub Desktop.
Update the NLB targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The following code gets the EKS endpoint IPs | |
endpoint = $eks_client.describe_cluster({name: eks_name}).data.cluster.endpoint | |
u = URI.parse(endpoint) | |
ips = [] | |
txt = Resolv::DNS.open do |dns| | |
records = dns.getresources(u.host, Resolv::DNS::Resource::IN::A) | |
records.each {|r| | |
ips << r.address.to_s | |
} | |
… | |
# The following registers the IP on the target groups of the NLB | |
ips.each {|ip| | |
tgs << {:id => ip} | |
} | |
$elbv2_client.register_targets({:target_group_arn => tg_arn, :targets => tgs}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment