Deleting a stream in the AWS SDK
Written by
Updated at July 15, 2025
Python
To delete a stream, use the delete_stream method. When you invoke this method, specify the following parameters:
- Name of the stream to delete, e.g.,
example-stream. - ID of the cloud in which to delete a stream, e.g.,
b1gi1kuj2dht********. - ID of the YDB database containing the stream, e.g.,
cc8028jgtuab********.
You also need to configure the AWS SDK and assign the service account the yds.editor role.
To delete a stream with the above parameters:
-
Create the
stream_delete.pyfile and paste the following code to it:import boto3 from pprint import pprint def delete_stream(cloud, database, stream_name): client = boto3.client('kinesis', endpoint_url="https://yds.serverless.yandexcloud.net") response = client.delete_stream( StreamName="/ru-central1/{cloud}/{database}/{stream}".format(cloud=cloud, database=database, stream=stream_name) ) return response if __name__ == '__main__': delete_stream_response = delete_stream( cloud="b1gi1kuj2dht********", database="cc8028jgtuab********", stream_name="example-stream") print("The stream has been deleted successfully") pprint(delete_stream_response) -
Run the program:
python3 stream_delete.pyResult:
The stream has been deleted successfully { 'ResponseMetadata': { 'HTTPHeaders': { 'connection': 'keep-alive', 'content-length': '3', 'content-type': 'application/json', 'date': '' 'GMT', 'server': 'nginx/1.19.5' }, 'HTTPStatusCode': 200, 'RetryAttempts': 0 } }