<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: python script to delete s3 objects and bucket in Object Storage</title>
    <link>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447151#M225</link>
    <description>&lt;P&gt;The error isn't generic.&lt;/P&gt;&lt;P&gt;If the lines took effect, validation should not have happened:&lt;/P&gt;&lt;P&gt;s3 = session.resource(service_name='s3', endpoint_url=endpoint, verify=&lt;STRONG&gt;False&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;But you instead got CERTIFICATE_VERIFY_FAILED.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A step-by-step Boto 3 example for StorageGRID 11 can be found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/NetApp/storagegrid-examples/blob/master/s3-python/README.md" target="_blank"&gt;https://github.com/NetApp/storagegrid-examples/blob/master/s3-python/README.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to connect with certificate validation off and my certificate was ignored like it's supposed to.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elementx_0-1692717058547.png" style="width: 400px;"&gt;&lt;img src="https://community.netapp.com/t5/image/serverpage/image-id/26792i97759FEE18B4C3F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="elementx_0-1692717058547.png" alt="elementx_0-1692717058547.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;All S3-compliant storage should work the same way; you don't need a NetApp-specific example.&lt;/P&gt;&lt;P&gt;(I'm not sure what product you're inquiring about, StorageGRID or ONTAP S3, but I haven't asked because it shouldn't matter. In fact I used that StorageGRID example with ONTAP S3 (9.12.1), and it worked fine.&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2023 15:16:47 GMT</pubDate>
    <dc:creator>elementx</dc:creator>
    <dc:date>2023-08-22T15:16:47Z</dc:date>
    <item>
      <title>python script to delete s3 objects and bucket</title>
      <link>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447139#M222</link>
      <description>&lt;P&gt;I had putt gather from public forum. but its erroring with certificate. would appreciate any assistance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[test-profile1]&lt;BR /&gt;aws_access_key_id=myAccessKey&lt;BR /&gt;aws_secret_access_key=mySecretAccessKey&lt;/P&gt;&lt;P&gt;import sys&lt;BR /&gt;import boto3&lt;BR /&gt;import boto3.session&lt;/P&gt;&lt;P&gt;## Configure the StorageGRID S3 endpoint and profile name ##&lt;BR /&gt;session = boto3.session.Session(profile_name='test-profile1')&lt;BR /&gt;endpoint = '&lt;A href="https://s3.mycompany.com:8080/" target="_blank"&gt;https://s3.mycompany.com:8080/&lt;/A&gt;'&lt;/P&gt;&lt;P&gt;# Ignore SSL verification&lt;BR /&gt;s3 = session.resource(service_name='s3', endpoint_url=endpoint, verify=False)&lt;BR /&gt;client = s3.meta.client&lt;/P&gt;&lt;P&gt;# Get the target bucket name from the command line argument&lt;BR /&gt;if len(sys.argv) &amp;lt; 2:&lt;BR /&gt;print("Please provide the target bucket name as a command line argument")&lt;BR /&gt;sys.exit(1)&lt;/P&gt;&lt;P&gt;target_bucket_name = sys.argv[1]&lt;/P&gt;&lt;P&gt;# Create an S3 client&lt;BR /&gt;s3_client = boto3.client("s3")&lt;/P&gt;&lt;P&gt;# create an S3 resource&lt;BR /&gt;s3 = boto3.resource("s3")&lt;/P&gt;&lt;P&gt;# Get a list of all S3 buckets&lt;BR /&gt;response = s3_client.list_buckets()&lt;/P&gt;&lt;P&gt;# Iterate over the buckets&lt;BR /&gt;for bucket in response["Buckets"]:&lt;BR /&gt;bucket_name = bucket["Name"]&lt;/P&gt;&lt;P&gt;# Check if the bucket name contains the target string&lt;BR /&gt;if target_bucket_name in bucket_name:&lt;BR /&gt;print(f"Found bucket: {bucket_name}")&lt;/P&gt;&lt;P&gt;versioning = s3_client.get_bucket_versioning(Bucket=bucket_name)&lt;BR /&gt;bucket = s3.Bucket(bucket_name)&lt;/P&gt;&lt;P&gt;if versioning.get("Status") == "Enabled":&lt;BR /&gt;bucket.object_versions.delete()&lt;BR /&gt;else:&lt;BR /&gt;bucket.objects.delete()&lt;/P&gt;&lt;P&gt;# Finally, delete the bucket&lt;BR /&gt;s3_client.delete_bucket(Bucket=bucket_name)&lt;BR /&gt;print(f"Deleted bucket: {bucket_name}")&lt;BR /&gt;&lt;BR /&gt;execute the script - python search_bucket_and_delete.py test-bucket&lt;BR /&gt;&lt;BR /&gt;ERROR - File "C:\Program Files\Python38\lib\ssl.py", line 1309, in do_handshake&lt;BR /&gt;self._sslobj.do_handshake()&lt;BR /&gt;ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)&lt;/P&gt;&lt;P&gt;During handling of the above exception, another exception occurred:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;urllib3.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)&lt;/P&gt;&lt;P&gt;raise SSLError(endpoint_url=request.url, error=e)&lt;BR /&gt;botocore.exceptions.SSLError: SSL validation failed for &lt;A href="https://s3.eu-west-1.amazonaws.com/" target="_blank"&gt;https://s3.eu-west-1.amazonaws.com/&lt;/A&gt; [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 09:45:48 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447139#M222</guid>
      <dc:creator>manistorage</dc:creator>
      <dc:date>2025-06-04T09:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: python script to delete s3 objects and bucket</title>
      <link>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447140#M223</link>
      <description>&lt;P&gt;So your configured domain is mycompany.com and you're trying to use the script to delete data at amazonaws.com. That won't work. You need to fill in the correct, valid values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:44:02 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447140#M223</guid>
      <dc:creator>elementx</dc:creator>
      <dc:date>2023-08-22T10:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: python script to delete s3 objects and bucket</title>
      <link>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447143#M224</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;appreciate the response. i have defined the endpoint.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;## Configure the StorageGRID S3 endpoint and profile name ##&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;session = boto3.session.Session(profile_name='test-profile1')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;endpoint = '&lt;/SPAN&gt;&lt;A href="https://s3.mycompany.com:8080/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://s3.mycompany.com:8080/&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i believe&amp;nbsp;the script hits SLL cert authentication&amp;nbsp;error. the output might be generic.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Mani&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 12:56:16 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447143#M224</guid>
      <dc:creator>manistorage</dc:creator>
      <dc:date>2023-08-22T12:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: python script to delete s3 objects and bucket</title>
      <link>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447151#M225</link>
      <description>&lt;P&gt;The error isn't generic.&lt;/P&gt;&lt;P&gt;If the lines took effect, validation should not have happened:&lt;/P&gt;&lt;P&gt;s3 = session.resource(service_name='s3', endpoint_url=endpoint, verify=&lt;STRONG&gt;False&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;But you instead got CERTIFICATE_VERIFY_FAILED.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A step-by-step Boto 3 example for StorageGRID 11 can be found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/NetApp/storagegrid-examples/blob/master/s3-python/README.md" target="_blank"&gt;https://github.com/NetApp/storagegrid-examples/blob/master/s3-python/README.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to connect with certificate validation off and my certificate was ignored like it's supposed to.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="elementx_0-1692717058547.png" style="width: 400px;"&gt;&lt;img src="https://community.netapp.com/t5/image/serverpage/image-id/26792i97759FEE18B4C3F3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="elementx_0-1692717058547.png" alt="elementx_0-1692717058547.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;All S3-compliant storage should work the same way; you don't need a NetApp-specific example.&lt;/P&gt;&lt;P&gt;(I'm not sure what product you're inquiring about, StorageGRID or ONTAP S3, but I haven't asked because it shouldn't matter. In fact I used that StorageGRID example with ONTAP S3 (9.12.1), and it worked fine.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 15:16:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Object-Storage/python-script-to-delete-s3-objects-and-bucket/m-p/447151#M225</guid>
      <dc:creator>elementx</dc:creator>
      <dc:date>2023-08-22T15:16:47Z</dc:date>
    </item>
  </channel>
</rss>

