Skip to content Skip to sidebar Skip to footer

List All "active" Emr Cluster Using Boto3

I'm trying to list all active clusters on EMR using boto3 but my code doesn't seem to be working it just returns null. Im trying to do this using boto3 1) list all Active EMR clust

Solution 1:

The following codes can print the active emr name and id:

import boto3
client = boto3.client("emr")
response = client.list_clusters(
    ClusterStates=[
        'STARTING', 'BOOTSTRAPPING', 'RUNNING', 'WAITING', 'TERMINATING'
    ]
)
for cluster in response['Clusters']:
    print(cluster['Name'])
    print(cluster['Id'])

Solution 2:

slightly updated on @shifu.zheng's answer:

import boto3
client = boto3.client("emr",region_name = "us-west-1", aws_access_key_id = "sdufashdifos123121", aws_secret_access_key ="sjdfnsaldfoasd1231312")
response = client.list_clusters(ClusterStates=['STARTING', 'BOOTSTRAPPING', 'RUNNING', 'WAITING', 'TERMINATING'])
for cluster in response['Clusters']:
print(cluster['Name'])
print(cluster['Id'])

You need to have the required parameters in the boto3.client object.

Post a Comment for "List All "active" Emr Cluster Using Boto3"