AWS CLI命令以获取ELB的Route 53记录集

时间:2019-01-03 07:55:54

标签: amazon-web-services aws-cli

我有一个ELB(abeXXXXXXXXXXX-12345XX.us-east-2.elb.amazonaws.com)附加到route53(test.kubernates.com)上的记录集。 aws cli命令将使用什么命令将记录集附加到elb?我想在控制台上打印 test.kubernates.com

我尝试将elb端点传递给list-resource-record-sets,但没有获得test.kubernates.com作为输出。

3 个答案:

答案 0 :(得分:1)

假设您已将route53记录设置为ELB的别名目标,则此方法应该有效:

import ctypes


def hexTobinary(hexdigits):
    binarydigits = ""
    for hexdigit in hexdigits:
        binarydigits += bin(int(hexdigit, 16))[2:].zfill(4)
    return binarydigits


t_offset = [['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'],
            ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'],
            ['0', '2', '4', '6', '8', 'A', 'C', 'E', '3', '1', '7', '5', 'B', '9', 'F', 'D'],
            ['0', '3', '6', '5', 'C', 'F', 'A', '9', 'B', '8', 'D', 'E', '7', '4', '1', '2'],
            ['0', '4', '8', 'C', '3', '7', 'B', 'F', '6', '2', 'E', 'A', '5', '1', 'D', '9'],
            ['0', '5', 'A', 'F', '7', '2', 'D', '8', 'E', 'B', '4', '1', '9', 'C', '3', '6'],
            ['0', '6', 'C', 'A', 'B', 'D', '7', '1', '5', '3', '9', 'F', 'E', '8', '2', '4'],
            ['0', '7', 'E', '9', 'F', '8', '1', '6', 'D', 'A', '3', '4', '2', '5', 'C', 'B'],
            ['0', '8', '3', 'B', '6', 'E', '5', 'D', 'C', '4', 'F', '7', 'A', '2', '9', '1'],
            ['0', '9', '1', '8', '2', 'B', '3', 'A', '4', 'D', '5', 'C', '6', 'F', '7', 'E'],
            ['0', 'A', '7', 'D', 'E', '4', '9', '3', 'F', '5', '8', '2', '1', 'B', '6', 'C'],
            ['0', 'B', '5', 'E', 'A', '1', 'F', '4', '7', 'C', '2', '9', 'D', '6', '8', '3'],
            ['0', 'C', 'B', '7', '5', '9', 'E', '2', 'A', '6', '1', 'D', 'F', '3', '4', '8'],
            ['0', 'D', '9', '4', '1', 'C', '8', '5', '2', 'F', 'B', '6', '3', 'E', 'A', '7'],
            ['0', 'E', 'F', '1', 'D', '3', '2', 'C', '9', '7', '6', '8', '4', 'A', 'B', '5'],
            ['0', 'F', 'D', '2', '9', '6', '4', 'B', '1', 'E', 'C', '3', '8', '7', '5', 'A']]

tu = ['1', '0', '3', '2', '5', '4', '7', '6',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '5', '4', '7', '6', '1', '0', '3', '2',
      '4', '5', '6', '7', '0', '1', '2', '3',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '1', '0', '3', '2', '5', '4', '7', '6',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '5', '4', '7', '6', '1', '0', '3', '2',
      '4', '5', '6', '7', '0', '1', '2', '3',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '1', '0', '3', '2', '5', '4', '7', '6',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '4', '5', '6', '7', '0', '1', '2', '3',
      '5', '4', '7', '6', '1', '0', '3', '2']

tl = ['4', '5', '6', '7', '0', '1', '2', '3',
      '5', '4', '7', '6', '1', '0', '3', '2',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '1', '0', '3', '2', '5', '4', '7', '6',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '5', '4', '7', '6', '1', '0', '3', '2',
      '4', '5', '6', '7', '0', '1', '2', '3',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '1', '0', '3', '2', '5', '4', '7', '6',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '6', '7', '4', '5', '2', '3', '0', '1',
      '7', '6', '5', '4', '3', '2', '1', '0',
      '4', '5', '6', '7', '0', '1', '2', '3',
      '5', '4', '7', '6', '1', '0', '3', '2',
      '2', '3', '0', '1', '6', '7', '4', '5',
      '3', '2', '1', '0', '7', '6', '5', '4',
      '0', '1', '2', '3', '4', '5', '6', '7',
      '1', '0', '3', '2', '5', '4', '7', '6']

w = 0xFFFFFF00
val = ctypes.c_uint32(~w).value

kg = [val]

kq = ['1', '2', '3', '0', '0', '0', '0', '0']

kt = ['1', '2', '3', '0', '0', '0', '0', '0',
      '0', '0', '0', '0', '0', '0', '0', '0']

AUT64_key = []
AUT64_key.extend(kg)
AUT64_key.extend(kq)
AUT64_key.extend(kt)


def apply_permutation_r(P_TABLE, PLAINTEXT):
    permutated_M = ""
    for index in P_TABLE:
        permutated_M += PLAINTEXT[int(index) - 1]
    return permutated_M


def apply_compression_g(o1, r_no, lk, uk):
    ln = int(o1[0:4], 2)
    un = int(o1[4:8], 2)
    gl = int(t_offset[int(lk)][int(ln)], 16)
    gu = int(t_offset[int(uk)][int(un)], 16)
    g = gl >> 4 | gu
    return g


def uk_round_key(i, r_no):
    uk = int(tu[(r_no * 8) + i])
    return uk


def lk_round_key(i, r_no):
    lk = int(tl[(r_no * 8) + i])
    return lk


def apply_fiestel_f(o1, r_no, i):
    uk = uk_round_key(i, r_no)
    lk = lk_round_key(i, r_no)
    o2 = apply_compression_g(o1, r_no, lk, uk)
    # o3 = apply_substitution_s(o2)
    # o4 = apply_permutation_bitwise(o3)
    # o5 = apply_permutation_substitution_s(o4)
    # return o5
    return o2


M = '01234567'
plaintext = hexTobinary(M)

enc = []

for r_no in range(8):
    o1 = apply_permutation_r(kq, plaintext)
    for i in range(8):
        enc.append(apply_fiestel_f(o1, r_no, i))

print enc

只需用托管区域ID代替您要查询的域以及相关的Elb域名即可。

注意:此处的ELB域名必须包含尾随时间段(注意,查询参数的结尾以“ amazonaws.com。”结尾)。

答案 1 :(得分:0)

如果您使用的是CNAME,则可以执行以下操作:

aws route53 list-resource-record-sets --output text --hosted-zone-id ZXXXXXXXXXX --query "ResourceRecordSets[?ResourceRecords[?Value == 'abeXXXXXXXXXXX-12345XX.us-east-2.elb.amazonaws.com']].Name"

答案 2 :(得分:0)

您必须添加一个--query选项以获取记录集。 并避免打印最后的'。字符添加| sed 's/.$//'

aws route53 list-resource-record-sets --hosted-zone-id <ZONE_ID>
--query "ResourceRecordSets[?ResourceRecords[?Value == 'abeXXXXXXXXXXX-12345XX.us-east-2.elb.amazonaws.com']].Name" --output text | sed 's/.$//'