View a markdown version of this page

Use ListCoreDevices with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use ListCoreDevices with an AWS SDK or CLI

The following code examples show how to use ListCoreDevices.

Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:

CLI
AWS CLI

To list core devices

The following list-core-devices example lists the AWS IoT Greengrass core devices in your AWS account in the current Region.

aws greengrassv2 list-core-devices

Output:

{ "coreDevices": [ { "coreDeviceThingName": "MyGreengrassCore", "status": "HEALTHY", "lastStatusUpdateTimestamp": "2021-01-08T04:57:58.838000-08:00" } ] }

For more information, see Check core device status in the AWS IoT Greengrass V2 Developer Guide.

Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

def list_core_devices(self, status: Optional[str] = None) -> list[dict[str, Any]]: """ Lists Greengrass core devices registered in the account. Uses a paginator to handle large result sets. :param status: Optional filter by device status ('HEALTHY' or 'UNHEALTHY'). :return: A list of core device dictionaries. """ try: devices = list() paginator = self.client.get_paginator("list_core_devices") params = dict() if status is not None: params["status"] = status for page in paginator.paginate(**params): devices.extend(page.get("coreDevices", list())) logger.info("Listed %d core device(s).", len(devices)) return devices except ClientError as err: if err.response["Error"]["Code"] == "ValidationException": logger.error( "Invalid request parameters for ListCoreDevices. " "Verify the status filter value is HEALTHY or UNHEALTHY. %s", err.response["Error"]["Message"], ) raise
  • For API details, see ListCoreDevices in AWS SDK for Python (Boto3) API Reference.