AWS Doc SDK Examples
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
または RemoveTagsFromCertificate
で を使用する AWS SDK CLI
以下のコード例は、RemoveTagsFromCertificate
の使用方法を示しています。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- C++
-
- SDK C++ 用
-
注記
詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 //! Remove a tag from an ACM certificate. /*! \param certificateArn: The Amazon Resource Name (ARN) of a certificate. \param tagKey: The key for the tag. \param tagValue: The value for the tag. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::removeTagsFromCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.SetKey(tagKey); tags.push_back(tag); Aws::ACM::Model::RemoveTagsFromCertificateRequest request; request.WithCertificateArn(certificateArn) .WithTags(tags); Aws::ACM::Model::RemoveTagsFromCertificateOutcome outcome = acmClient.RemoveTagsFromCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: RemoveTagFromCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Tag with key '" << tagKey << "' removed from " << "certificate with ARN '" << certificateArn << "'." << std::endl; return true; } }
-
API 詳細については、「 AWS SDK for C++ APIリファレンスRemoveTagsFromCertificate」の「」を参照してください。
-
- CLI
-
- AWS CLI
-
ACM証明書からタグを削除するには
次の
remove-tags-from-certificate
コマンドは、指定された証明書から 2 つのタグを削除します。複数のタグは空白で区切ります。aws acm remove-tags-from-certificate --certificate-arn
arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012
--tagsKey=Admin,Value=Alice
Key=Purpose,Value=Website
-
API 詳細については、AWS CLI 「 コマンドリファレンスRemoveTagsFromCertificate
」の「」を参照してください。
-
- Java
-
- SDK for Java 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 RemoveTagsFromCert { 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]; removeTags(certArn); } /** * Removes tags from an AWS Certificate Manager (ACM) certificate. * * @param certArn the Amazon Resource Name (ARN) of the certificate from which to remove tags */ public static void removeTags(String certArn) { AcmClient acmClient = AcmClient.create(); List<Tag> expectedTags = List.of(Tag.builder().key("key").value("value").build()); RemoveTagsFromCertificateRequest req = RemoveTagsFromCertificateRequest.builder() .certificateArn(certArn) .tags(expectedTags) .build(); try { acmClient.removeTagsFromCertificate(req); System.out.println("Successfully removed tags from the certificate"); } catch (AcmException e) { System.err.println(e.getMessage()); } } }
-
API 詳細については、「 AWS SDK for Java 2.x APIリファレンスRemoveTagsFromCertificate」の「」を参照してください。
-
- Python
-
- SDK for Python (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_tags(self, certificate_arn, tags): """ Removes tags from a certificate. If the value of a tag is specified, the tag is removed only when the value matches the value of the certificate's tag. Otherwise, the tag is removed regardless of its value. :param certificate_arn: The ARN of the certificate. :param tags: The dictionary of tags to remove. """ try: cert_tags = [] for key, value in tags.items(): tag = {"Key": key} if value is not None: tag["Value"] = value cert_tags.append(tag) self.acm_client.remove_tags_from_certificate( CertificateArn=certificate_arn, Tags=cert_tags ) logger.info( "Removed %s tags from certificate %s.", len(tags), certificate_arn ) except ClientError: logger.exception( "Couldn't remove tags from certificate %s.", certificate_arn ) raise
-
API 詳細については、「 for AWS SDKPython (Boto3) APIリファレンスRemoveTagsFromCertificate」の「」を参照してください。
-