または ListTagsForCertificateAWS SDKで を使用する CLI - AWS SDK CLI コードの例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

または ListTagsForCertificateAWS SDKで を使用する CLI

以下のコード例は、ListTagsForCertificate の使用方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

C++
SDK C++ 用
注記

については、「」を参照してください GitHub。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。

//! List the tags for 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::listTagsForCertificate(const Aws::String &certificateArn, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acm_client(clientConfiguration); Aws::ACM::Model::ListTagsForCertificateRequest request; request.WithCertificateArn(certificateArn); Aws::ACM::Model::ListTagsForCertificateOutcome outcome = acm_client.ListTagsForCertificate(request); if (!outcome.IsSuccess()) { std::cout << "Error: ListTagsForCertificate: " << outcome.GetError().GetMessage() << std::endl; return false; } else { std::cout << "Success: Information about tags for " "certificate with ARN '" << certificateArn << "':" << std::endl << std::endl; auto result = outcome.GetResult(); Aws::Vector<Aws::ACM::Model::Tag> tags = result.GetTags(); if (tags.size() > 0) { for (const Aws::ACM::Model::Tag &tag: tags) { std::cout << "Key: " << tag.GetKey() << std::endl; std::cout << "Value: " << tag.GetValue() << std::endl << std::endl; } } else { std::cout << "No tags found." << std::endl; } return true; } }
  • API 詳細については、「 リファレンスListTagsForCertificate」の「」を参照してください。 AWS SDK for C++ API

CLI
AWS CLI

ACM証明書に適用されたタグを一覧表示するには

次の list-tags-for-certificate コマンドは、アカウント内の証明書に適用されたタグを一覧表示します。

aws acm list-tags-for-certificate --certificate-arn arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012

このコマンドを処理すると、次のような出力が生成されます。

{ "Tags": [ { "Value": "Website", "Key": "Purpose" }, { "Value": "Alice", "Key": "Admin" } ] }
  • API 詳細については、「 コマンドリファレンスListTagsForCertificate」の「」を参照してください。 AWS CLI

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 list_tags(self, certificate_arn): """ Lists the tags attached to a certificate. :param certificate_arn: The ARN of the certificate. :return: The dictionary of certificate tags. """ try: response = self.acm_client.list_tags_for_certificate( CertificateArn=certificate_arn ) tags = {tag["Key"]: tag["Value"] for tag in response["Tags"]} logger.info("Got %s tags for certificates %s.", len(tags), certificate_arn) except ClientError: logger.exception("Couldn't get tags for certificate %s.", certificate_arn) raise else: return tags
  • API 詳細については、ListTagsForCertificate「 for AWS SDK Python (Boto3) APIリファレンス」の「」を参照してください。