in projects/enable-irsa/src/main.py [0:0]
def describe_cluster(ClusterName: str):
print('Obtaining OIDC URL and thumbprint.')
try:
api_response = eks.describe_cluster(name=ClusterName)
except eks.exceptions.ResourceNotFoundException as e:
print('Cluster {} does not exist.').format(ClusterName)
cluster = Cluster(**api_response['cluster'])
oidc_url = cluster.issuer
response = request('GET', oidc_url + "/.well-known/openid-configuration", verify=True)
jwks_uri = json.loads(response.text)['jwks_uri']
hostname = parse.urlparse(jwks_uri).hostname
ctx = SSL.Context(SSL.TLSv1_2_METHOD)
sock = socket.socket()
conn = SSL.Connection(ctx, sock)
conn.connect((hostname, 443))
conn.set_connect_state()
conn.do_handshake()
certs = conn.get_peer_cert_chain()
thumbprint = certs[-1].digest('sha1').decode('utf-8').replace(':', "")
return cluster, thumbprint