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

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

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

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

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

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

C++
SDK C++ 用
注記

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

//! Add tags to an AWS Certificate Manager (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::addTagsToCertificate(const Aws::String &certificateArn, const Aws::String &tagKey, const Aws::String &tagValue, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::AddTagsToCertificateRequest request; Aws::Vector<Aws::ACM::Model::Tag> tags; Aws::ACM::Model::Tag tag; tag.WithKey(tagKey).WithValue(tagValue); tags.push_back(tag); request.WithCertificateArn(certificateArn).WithTags(tags); Aws::ACM::Model::AddTagsToCertificateOutcome outcome = acmClient.AddTagsToCertificate(request); if (!outcome.IsSuccess()) { std::cerr << "Error: addTagsToCertificate: " << outcome.GetError().GetMessage() << std::endl; } else { std::cout << "Success: Tag with key '" << tagKey << "' and value '" << tagValue << "' added to certificate with ARN '" << certificateArn << "'." << std::endl; } return outcome.IsSuccess(); }
  • API 詳細については、「 リファレンスAddTagsToCertificate」の「」を参照してください。 AWS SDK for C++ API

CLI
AWS CLI

既存のACM証明書にタグを追加するには

次の add-tags-to-certificate コマンドは、指定された証明書に 2 つのタグを追加します。複数のタグは空白で区切ります。

aws acm add-tags-to-certificate --certificate-arn arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012 --tags Key=Admin,Value=Alice Key=Purpose,Value=Website
  • API 詳細については、「 コマンドリファレンスAddTagsToCertificate」の「」を参照してください。 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 add_tags(self, certificate_arn, tags): """ Adds tags to a certificate. Tags are key-value pairs that contain custom metadata. :param certificate_arn: The ARN of the certificate. :param tags: A dictionary of key-value tags to add to the certificate. """ try: self.acm_client.add_tags_to_certificate( CertificateArn=certificate_arn, Tags=[{"Key": key, "Value": value} for key, value in tags.items()], ) logger.info("Added %s tags to certificate %s.", len(tags), certificate_arn) except ClientError: logger.exception("Couldn't add tags to certificate %s.", certificate_arn) raise
  • API 詳細については、「 for Python (Boto3) リファレンスAddTagsToCertificate」の「」を参照してください。 AWS SDK API