Skip to content

attach_certificate_to_distribution

attach_certificate_to_distribution(
    distribution_name: ResourceName,
    certificate_name: ResourceName,
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
) -> AttachCertificateToDistributionResult

Attaches an SSL/TLS certificate to your Amazon Lightsail content delivery network (CDN) distribution.

After the certificate is attached, your distribution accepts HTTPS traffic for all of the domains that are associated with the certificate.

Use the CreateCertificate action to create a certificate that you can attach to your distribution.

Only certificates created in the us-east-1 Amazon Web Services Region can be attached to Lightsail distributions. Lightsail distributions are global resources that can reference an origin in any Amazon Web Services Region, and distribute its content globally. However, all distributions are located in the us-east-1 Region.

Parameters:

  • distribution_name (ResourceName) –

    The name of the distribution that the certificate will be attached to.

    Use the GetDistributions action to get a list of distribution names that you can specify.

  • certificate_name (ResourceName) –

    The name of the certificate to attach to a distribution.

    Only certificates with a status of ISSUED can be attached to a distribution.

    Use the GetCertificates action to get a list of certificate names that you can specify.

    This is the name of the certificate resource type and is used only to reference the certificate in other API actions. It can be different than the domain name of the certificate. For example, your certificate name might be WordPress-Blog-Certificate and the domain name of the certificate might be example.com.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • OperationFailureException –

    Lightsail throws this exception when an operation fails to execute.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/lightsail.py
def attach_certificate_to_distribution(
    self,
    distribution_name: "capo_lightsail.types.resource_name.ResourceName",
    certificate_name: "capo_lightsail.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[LightsailClientConfig] = None,
) -> "capo_lightsail.types.attach_certificate_to_distribution_result.AttachCertificateToDistributionResult":
    """<p>Attaches an SSL/TLS certificate to your Amazon Lightsail content delivery network (CDN) distribution.</p> <p>After the certificate is attached, your distribution accepts HTTPS traffic for all of the domains that are associated with the certificate.</p> <p>Use the <code>CreateCertificate</code> action to create a certificate that you can attach to your distribution.</p> <important> <p>Only certificates created in the <code>us-east-1</code> Amazon Web Services Region can be attached to Lightsail distributions. Lightsail distributions are global resources that can reference an origin in any Amazon Web Services Region, and distribute its content globally. However, all distributions are located in the <code>us-east-1</code> Region.</p> </important>

    Args:
        distribution_name: <p>The name of the distribution that the certificate will be attached to.</p> <p>Use the <code>GetDistributions</code> action to get a list of distribution names that you can specify.</p>
        certificate_name: <p>The name of the certificate to attach to a distribution.</p> <p>Only certificates with a status of <code>ISSUED</code> can be attached to a distribution.</p> <p>Use the <code>GetCertificates</code> action to get a list of certificate names that you can specify.</p> <note> <p>This is the name of the certificate resource type and is used only to reference the certificate in other API actions. It can be different than the domain name of the certificate. For example, your certificate name might be <code>WordPress-Blog-Certificate</code> and the domain name of the certificate might be <code>example.com</code>.</p> </note>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.operation_failure_exception.OperationFailureException: <p>Lightsail throws this exception when an operation fails to execute.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lightsail.types.attach_certificate_to_distribution_request.AttachCertificateToDistributionRequest]",
    ) -> OperationResponse[
        "capo_lightsail.types.attach_certificate_to_distribution_result.AttachCertificateToDistributionResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.attach_certificate_to_distribution

        output, http_response = (
            capo_lightsail._operations.lightsail_20161128.attach_certificate_to_distribution.attach_certificate_to_distribution(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AttachCertificateToDistribution")
    )
    input_: capo_lightsail.types.attach_certificate_to_distribution_request.AttachCertificateToDistributionRequest = {
        "distribution_name": distribution_name,
        "certificate_name": certificate_name,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output