AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2026-01-25 · Documentation low

File: code-library/latest/ug/iot_example_iot_DeleteCertificate_section.md

Summary

Added Python code example for certificate deactivation and deletion

Security assessment

The change documents certificate lifecycle management (security feature), showing proper deactivation before deletion. No evidence of addressing specific vulnerabilities.

Diff

diff --git a/code-library/latest/ug/iot_example_iot_DeleteCertificate_section.md b/code-library/latest/ug/iot_example_iot_DeleteCertificate_section.md
index f41c21b5d..779339cb9 100644
--- a//code-library/latest/ug/iot_example_iot_DeleteCertificate_section.md
+++ b//code-library/latest/ug/iot_example_iot_DeleteCertificate_section.md
@@ -214,0 +215,59 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+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](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/python/example_code/iot#code-examples). 
+    
+    
+    class IoTWrapper:
+        """Encapsulates AWS IoT actions."""
+    
+        def __init__(self, iot_client, iot_data_client=None):
+            """
+            :param iot_client: A Boto3 AWS IoT client.
+            :param iot_data_client: A Boto3 AWS IoT Data Plane client.
+            """
+            self.iot_client = iot_client
+            self.iot_data_client = iot_data_client
+    
+        @classmethod
+        def from_client(cls):
+            iot_client = boto3.client("iot")
+            iot_data_client = boto3.client("iot-data")
+            return cls(iot_client, iot_data_client)
+    
+        def delete_certificate(self, certificate_id):
+            """
+            Deletes an AWS IoT certificate.
+    
+            :param certificate_id: The ID of the certificate to delete.
+            """
+            try:
+                self.iot_client.update_certificate(
+                    certificateId=certificate_id, newStatus="INACTIVE"
+                )
+                self.iot_client.delete_certificate(certificateId=certificate_id)
+                logger.info("Deleted certificate %s.", certificate_id)
+            except ClientError as err:
+                if err.response["Error"]["Code"] == "ResourceNotFoundException":
+                    logger.error("Cannot delete certificate. Resource not found.")
+                    return
+                logger.error(
+                    "Couldn't delete certificate. Here's why: %s: %s",
+                    err.response["Error"]["Code"],
+                    err.response["Error"]["Message"],
+                )
+                raise
+    
+    
+    
+
+  * For API details, see [DeleteCertificate](https://docs.aws.amazon.com/goto/boto3/iot-2015-05-28/DeleteCertificate) in _AWS SDK for Python (Boto3) API Reference_. 
+
+
+
+