Úselo ListTagsForCertificate con un o AWS SDK CLI - Ejemplos de código de AWS SDK

Hay más AWS SDK ejemplos disponibles en el GitHub repositorio de AWS Doc SDK Examples.

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Úselo ListTagsForCertificate con un o AWS SDK CLI

En los siguientes ejemplos de código, se muestra cómo utilizar ListTagsForCertificate.

Los ejemplos de acciones son extractos de código de programas más grandes y deben ejecutarse en contexto. Puede ver esta acción en contexto en el siguiente ejemplo de código:

C++
SDKpara C++
nota

Hay más información GitHub. Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de 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 enumerar las etiquetas aplicadas a un ACM certificado

El siguiente comando list-tags-for-certificate muestra las etiquetas aplicadas a un certificado de su cuenta:

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

El comando anterior produce un resultado similar al siguiente:

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

Hay más información. GitHub Busque el ejemplo completo y aprenda a configurar y ejecutar en el Repositorio de ejemplos de código de 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
  • Para API obtener más información, consulte ListTagsForCertificatela AWS SDKreferencia de Python (Boto3). API