Path: blob/develop/awscli/customizations/emrcontainers/eks.py
1567 views
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.121314class EKS(object):15def __init__(self, eks_client):16self.eks_client = eks_client17self.cluster_info = {}1819def get_oidc_issuer_id(self, cluster_name):20"""Method to get OIDC issuer id for the given EKS cluster"""21if cluster_name not in self.cluster_info:22self.cluster_info[cluster_name] = self.eks_client.describe_cluster(23name=cluster_name24)2526oidc_issuer = self.cluster_info[cluster_name].get("cluster", {}).get(27"identity", {}).get("oidc", {}).get("issuer", "")2829return oidc_issuer.split('https://')[1]3031def get_account_id(self, cluster_name):32"""Method to get account id for the given EKS cluster"""33if cluster_name not in self.cluster_info:34self.cluster_info[cluster_name] = self.eks_client.describe_cluster(35name=cluster_name36)3738cluster_arn = self.cluster_info[cluster_name].get("cluster", {}).get(39"arn", "")4041return cluster_arn.split(':')[4]424344