Using Console
Using CLI
aws eks describe-cluster --name <cluster_name> --query "cluster.logging"
aws eks update-cluster-config --name <cluster_name> --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'
Using Python
import boto3 from botocore.exceptions import ClientError
session = boto3.session.Session(region_name='your_region') eks_client = session.client('eks')
describe_cluster
response = eks_client.describe_cluster(name='your_cluster_name') logging_enabled = response['cluster']['logging']['clusterLogging'][0]['enabled']
logging_enabled
False
update_cluster_config
if not logging_enabled: logging_config = { 'types': ['api', 'audit', 'authenticator', 'controllerManager', 'scheduler'], 'enabled': True } update_config = { 'logging': logging_config } eks_client.update_cluster_config(name='your_cluster_name', resourcesVpcConfig=update_config)
print('Logging has been enabled for the EKS cluster.')