Use ListTagsForCertificate com um AWS SDK ou CLI - AWS SDKExemplos de código

Há mais AWS SDK exemplos disponíveis no GitHub repositório AWS Doc SDK Examples.

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Use ListTagsForCertificate com um AWS SDK ou CLI

Os exemplos de código a seguir mostram como usar o ListTagsForCertificate.

Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação no contexto no seguinte exemplo de código:

C++
SDKpara C++
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da 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; } }
CLI
AWS CLI

Para listar as tags aplicadas a um ACM certificado

O seguinte comando list-tags-for-certificate lista as tags aplicadas a um certificado na conta:

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

O comando anterior produz uma saída semelhante à seguinte:

{ "Tags": [ { "Value": "Website", "Key": "Purpose" }, { "Value": "Alice", "Key": "Admin" } ] }
Python
SDKpara Python (Boto3)
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da 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