Skip to content

Instantly share code, notes, and snippets.

@garystafford
Created May 9, 2024 00:51
Show Gist options
  • Save garystafford/532da857a859cc843fbd976ed2e875b0 to your computer and use it in GitHub Desktop.
Save garystafford/532da857a859cc843fbd976ed2e875b0 to your computer and use it in GitHub Desktop.
Delete all Amazon SageMaker Endpoint Configs
# Author: Gary A. Stafford
# Purpose: Delete all SageMaker Endpoint Configs
# Date: 2024-05-08
# License: MIT License
# Based on https://gist.github.com/Nxtra/49cde5999de20023e2607433046ca6cf
import boto3
client = boto3.client("sagemaker")
def main():
endpoint_config_names = []
for key in paginate(client.list_endpoint_configs):
endpoint_config_names.append(key["EndpointConfigName"])
delete_multiple_endpoint_configs(endpoint_config_names)
def delete_multiple_endpoint_configs(endpoint_config_names):
for endpoint_config_name in endpoint_config_names:
print("Deleting endpoint config: {}".format(endpoint_config_name))
client.delete_endpoint_config(EndpointConfigName=endpoint_config_name)
def paginate(method, **kwargs):
client = method.__self__
paginator = client.get_paginator(method.__name__)
for page in paginator.paginate(**kwargs).result_key_iters():
for result in page:
yield result
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment