文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DeleteCertificate
与 AWS SDK 或 CLI 配合使用
以下代码示例演示如何使用 DeleteCertificate
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- C++
-
- SDK for C++
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 //! Delete an AWS Certificate Manager (ACM) certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::deleteCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::DeleteCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::DeleteCertificateOutcome outcome = acmClient.DeleteCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: DeleteCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: The certificate with the ARN '" << certificateArn << "' is deleted." << std::endl; } return outcome.IsSuccess(); }
-
有关 API 的详细信息,请参阅 AWS SDK for C++ API 参考DeleteCertificate中的。
-
- CLI
-
- AWS CLI
-
从账户中删除 ACM 证书
以下
delete-certificate
命令删除具有指定 ARN 的证书:aws acm delete-certificate --certificate-arn
arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012
-
有关 API 的详细信息,请参阅AWS CLI 命令参考DeleteCertificate
中的。
-
- Java
-
- 适用于 Java 的 SDK 2.x
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * <p> * For more information, see the following documentation topic: * <p> * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DeleteCert { public static void main(String[] args) { final String usage = """ Usage: <certArn> Where: certArn - the ARN of the certificate. """; if (args.length != 1) { System.out.println(usage); return; } String certArn = args[0]; deleteCertificate(certArn); } /** * Deletes an SSL/TLS certificate from the AWS Certificate Manager (ACM). * * @param certArn the Amazon Resource Name (ARN) of the certificate to be deleted */ public static void deleteCertificate( String certArn) { AcmClient acmClient = AcmClient.create(); DeleteCertificateRequest request = DeleteCertificateRequest.builder() .certificateArn(certArn) .build(); try { acmClient.deleteCertificate(request); System.out.println("The certificate was deleted"); } catch (AcmException e) { System.out.println(e.getMessage()); } } }
-
有关 API 的详细信息,请参阅 AWS SDK for Java 2.x API 参考DeleteCertificate中的。
-
- PowerShell
-
- 用于 PowerShell
-
示例 1:删除由提供的 ARN 和关联的私钥标识的证书。在继续操作之前,cmdlet 将提示您进行确认;添加-Force 开关以禁止确认。
Remove-ACMCertificate -CertificateArn "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
-
有关 API 的详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考DeleteCertificate中的。
-
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 class AcmCertificate: """ Encapsulates ACM functions. """ def __init__(self, acm_client): """ :param acm_client: A Boto3 ACM client. """ self.acm_client = acm_client def remove(self, certificate_arn): """ Removes a certificate. :param certificate_arn: The ARN of the certificate to remove. """ try: self.acm_client.delete_certificate(CertificateArn=certificate_arn) logger.info("Removed certificate %s.", certificate_arn) except ClientError: logger.exception("Couldn't remove certificate %s.", certificate_arn) raise
-
有关 API 的详细信息,请参阅适用DeleteCertificate于 Python 的AWS SDK (Boto3) API 参考。
-
AddTagsToCertificate
DescribeCertificate