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.
AddTagsToCertificate
Úselo con un AWS SDK o CLI
En los siguientes ejemplos de código, se muestra cómo utilizar AddTagsToCertificate
.
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
. //! 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(); }
-
Para API obtener más información, consulte AddTagsToCertificatela AWS SDK for C++ APIReferencia.
-
- CLI
-
- AWS CLI
-
Para añadir etiquetas a un ACM certificado existente
El siguiente comando
add-tags-to-certificate
añade dos etiquetas al certificado especificado. Utilice un espacio para separar varias etiquetas:aws acm add-tags-to-certificate --certificate-arn
arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012
--tagsKey=Admin,Value=Alice
Key=Purpose,Value=Website
-
Para API obtener más información, consulte AddTagsToCertificate
la Referencia de AWS CLI comandos.
-
- 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 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
-
Para API obtener más información, consulte AddTagsToCertificatela AWS SDKreferencia de Python (Boto3). API
-