Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DeleteCertificate
dengan AWS SDK atau CLI
Contoh kode berikut menunjukkan cara menggunakanDeleteCertificate
.
Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:
- C++
-
- SDKuntuk C ++
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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();
}
- CLI
-
- AWS CLI
-
Untuk menghapus ACM sertifikat dari akun Anda
delete-certificate
Perintah berikut menghapus sertifikat dengan yang ditentukanARN:
aws acm delete-certificate --certificate-arn arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012
- PowerShell
-
- Alat untuk PowerShell
-
Contoh 1: Menghapus sertifikat yang diidentifikasi oleh kunci pribadi yang disediakan ARN dan terkait. Cmdlet akan meminta konfirmasi sebelum melanjutkan; tambahkan sakelar -Force untuk menekan konfirmasi.
Remove-ACMCertificate -CertificateArn "arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012"
- Python
-
- SDKuntuk Python (Boto3)
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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