This notebook is provided to help you clean up any resources you have created by running through the example. You should also go to the CloudFormation console and delete the stack that you created.
from sagemaker import get_execution_role
import sagemaker
import boto3
import json
import sys
role = get_execution_role()
sm = boto3.Session().client(service_name='sagemaker')
%store -r
try:
sm.delete_feature_group(FeatureGroupName=fg_name)
print('deleted '+fg_name)
except:
pass
sm.list_feature_groups()
%store -r
import boto3
kda_client = boto3.client('kinesisanalytics')
try:
kda_client.stop_application(ApplicationName=APPLICATION_NAME)
except:
pass
print('Stopped the KDA SQL app')
import time
%store -r
try:
ready = False
while not ready:
app_desc = kda_client.describe_application(ApplicationName=APPLICATION_NAME)['ApplicationDetail']
if app_desc['ApplicationStatus'] == 'READY':
ready = True
else:
print('Waiting for KDA SQL app to be ready for deletion...')
time.sleep(15)
create_timestamp = app_desc['CreateTimestamp']
response = kda_client.delete_application(ApplicationName=APPLICATION_NAME,
CreateTimestamp=create_timestamp)
print('Deleted KDA SQL app')
except:
print('FAILED to delete KDA sql app')
import boto3
%store -r
lambda_client = boto3.client('lambda')
paginator = lambda_client.get_paginator('list_event_source_mappings')
mapping_iterator = paginator.paginate(FunctionName=lambda_to_model_arn)
for m in mapping_iterator:
if len(m['EventSourceMappings']) > 0:
uuid = m['EventSourceMappings'][0]['UUID']
print(f'Deleting mapping: {uuid}...')
lambda_client.delete_event_source_mapping(UUID=uuid)
%store -r
kinesis_client = boto3.client('kinesis')
try:
kinesis_client.delete_stream(StreamName=STREAM_NAME)
except:
pass
print('deleted Kinesis stream')
%store -r
#endpoint_name="sagemaker-xgboost-2020-12-23-06-52-57-726"
try:
sm.delete_endpoint(EndpointName=endpoint_name)
except:
print("yes")
pass