Skip to content

update_distribution async

update_distribution(
    distribution_name: ResourceName,
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    origin: Optional[InputOrigin] = None,
    default_cache_behavior: Optional[CacheBehavior] = None,
    cache_behavior_settings: Optional[CacheSettings] = None,
    cache_behaviors: Optional[CacheBehaviorList] = None,
    is_enabled: Optional[boolean] = None,
    viewer_minimum_tls_protocol_version: Optional[
        ViewerMinimumTlsProtocolVersionEnum
    ] = None,
    certificate_name: Optional[ResourceName] = None,
    use_default_certificate: Optional[boolean] = None,
    enable_private_origin_access: Optional[boolean] = None,
    default_root_object: Optional[string] = None,
    custom_error_responses: Optional[DistributionCustomErrorResponseList] = None,
) -> UpdateDistributionResult

Updates an existing Amazon Lightsail content delivery network (CDN) distribution.

Use this action to update the configuration of your existing distribution.

Parameters:

  • distribution_name (ResourceName) –

    The name of the distribution to update.

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

  • origin (Optional[InputOrigin], default: None ) –

    An object that describes the origin resource for the distribution, such as a Lightsail instance, bucket, or load balancer.

    The distribution pulls, caches, and serves content from the origin.

  • default_cache_behavior (Optional[CacheBehavior], default: None ) –

    An object that describes the default cache behavior for the distribution.

  • cache_behavior_settings (Optional[CacheSettings], default: None ) –

    An object that describes the cache behavior settings for the distribution.

    The cacheBehaviorSettings specified in your UpdateDistributionRequest will replace your distribution's existing settings.

  • cache_behaviors (Optional[CacheBehaviorList], default: None ) –

    An array of objects that describe the per-path cache behavior for the distribution.

  • is_enabled (Optional[boolean], default: None ) –

    Indicates whether to enable the distribution.

  • viewer_minimum_tls_protocol_version (Optional[ViewerMinimumTlsProtocolVersionEnum], default: None ) –

    Use this parameter to update the minimum TLS protocol version for the SSL/TLS certificate that's attached to the distribution.

  • certificate_name (Optional[ResourceName], default: None ) –

    The name of the SSL/TLS certificate that you want to attach to the 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.

  • use_default_certificate (Optional[boolean], default: None ) –

    Indicates whether the default SSL/TLS certificate is attached to the distribution. The default value is true. When true, the distribution uses the default domain name such as d111111abcdef8.cloudfront.net.

    Set this value to false to attach a new certificate to the distribution.

  • enable_private_origin_access (Optional[boolean], default: None ) –

    Specifies whether to enable private origin access for the distribution. With private origin access, the distribution can serve objects that aren't publicly accessible from a Lightsail bucket.

    Lightsail grants the distribution permission to read the bucket's objects. Enabling private origin access doesn't change the bucket's access settings, and you can still retrieve publicly accessible objects directly from the bucket's endpoint.

    When you include this parameter, you must also include the origin parameter with the resource name, even if the origin is not changing.

    You can enable private origin access only when the distribution's origin is a Lightsail bucket. If the origin is another resource type, the request fails.

  • default_root_object (Optional[string], default: None ) –

    The object (for example, index.html) that the distribution returns when a viewer requests the root URL of the distribution (/) instead of a specific object. The object that you specify must be available from the origin.

  • custom_error_responses (Optional[DistributionCustomErrorResponseList], default: None ) –

    An array of objects that describe the custom error responses for the distribution. With a custom error response, you can specify the page to return when the origin responds with a given HTTP error code. You can also specify the HTTP status code to send to the viewer.

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/async_lightsail.py
async def update_distribution(
    self,
    distribution_name: "capo_lightsail.types.resource_name.ResourceName",
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    origin: Optional["capo_lightsail.types.input_origin.InputOrigin"] = None,
    default_cache_behavior: Optional[
        "capo_lightsail.types.cache_behavior.CacheBehavior"
    ] = None,
    cache_behavior_settings: Optional[
        "capo_lightsail.types.cache_settings.CacheSettings"
    ] = None,
    cache_behaviors: Optional[
        "capo_lightsail.types.cache_behavior_list.CacheBehaviorList"
    ] = None,
    is_enabled: Optional["capo_lightsail.types.boolean.boolean"] = None,
    viewer_minimum_tls_protocol_version: Optional[
        "capo_lightsail.types.viewer_minimum_tls_protocol_version_enum.ViewerMinimumTlsProtocolVersionEnum"
    ] = None,
    certificate_name: Optional[
        "capo_lightsail.types.resource_name.ResourceName"
    ] = None,
    use_default_certificate: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    enable_private_origin_access: Optional[
        "capo_lightsail.types.boolean.boolean"
    ] = None,
    default_root_object: Optional["capo_lightsail.types.string.string"] = None,
    custom_error_responses: Optional[
        "capo_lightsail.types.distribution_custom_error_response_list.DistributionCustomErrorResponseList"
    ] = None,
) -> "capo_lightsail.types.update_distribution_result.UpdateDistributionResult":
    """<p>Updates an existing Amazon Lightsail content delivery network (CDN) distribution.</p> <p>Use this action to update the configuration of your existing distribution.</p>

    Args:
        distribution_name: <p>The name of the distribution to update.</p> <p>Use the <code>GetDistributions</code> action to get a list of distribution names that you can specify.</p>
        origin: <p>An object that describes the origin resource for the distribution, such as a Lightsail instance, bucket, or load balancer.</p> <p>The distribution pulls, caches, and serves content from the origin.</p>
        default_cache_behavior: <p>An object that describes the default cache behavior for the distribution.</p>
        cache_behavior_settings: <p>An object that describes the cache behavior settings for the distribution.</p> <note> <p>The <code>cacheBehaviorSettings</code> specified in your <code>UpdateDistributionRequest</code> will replace your distribution's existing settings.</p> </note>
        cache_behaviors: <p>An array of objects that describe the per-path cache behavior for the distribution.</p>
        is_enabled: <p>Indicates whether to enable the distribution.</p>
        viewer_minimum_tls_protocol_version: <p>Use this parameter to update the minimum TLS protocol version for the SSL/TLS certificate that's attached to the distribution.</p>
        certificate_name: <p>The name of the SSL/TLS certificate that you want to attach to the distribution.</p> <p>Only certificates with a status of <code>ISSUED</code> can be attached to a distribution.</p> <p>Use the <a href="https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetCertificates.html">GetCertificates</a> action to get a list of certificate names that you can specify.</p>
        use_default_certificate: <p>Indicates whether the default SSL/TLS certificate is attached to the distribution. The default value is <code>true</code>. When <code>true</code>, the distribution uses the default domain name such as <code>d111111abcdef8.cloudfront.net</code>.</p> <p> Set this value to <code>false</code> to attach a new certificate to the distribution.</p>
        enable_private_origin_access: <p>Specifies whether to enable private origin access for the distribution. With private origin access, the distribution can serve objects that aren't publicly accessible from a Lightsail bucket.</p> <p>Lightsail grants the distribution permission to read the bucket's objects. Enabling private origin access doesn't change the bucket's access settings, and you can still retrieve publicly accessible objects directly from the bucket's endpoint.</p> <note> <p>When you include this parameter, you must also include the <code>origin</code> parameter with the resource name, even if the origin is not changing.</p> <p>You can enable private origin access only when the distribution's origin is a Lightsail bucket. If the origin is another resource type, the request fails.</p> </note>
        default_root_object: <p>The object (for example, <code>index.html</code>) that the distribution returns when a viewer requests the root URL of the distribution (<code>/</code>) instead of a specific object. The object that you specify must be available from the origin.</p>
        custom_error_responses: <p>An array of objects that describe the custom error responses for the distribution. With a custom error response, you can specify the page to return when the origin responds with a given HTTP error code. You can also specify the HTTP status code to send to the viewer.</p>

    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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lightsail.types.update_distribution_request.UpdateDistributionRequest]",
    ) -> AsyncOperationResponse[
        "capo_lightsail.types.update_distribution_result.UpdateDistributionResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.update_distribution

        (
            output,
            http_response,
        ) = await capo_lightsail._operations.lightsail_20161128.update_distribution.async_update_distribution(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateDistribution")
    )
    input_: capo_lightsail.types.update_distribution_request.UpdateDistributionRequest = {
        "distribution_name": distribution_name
    }
    if origin is not None:
        input_["origin"] = origin
    if default_cache_behavior is not None:
        input_["default_cache_behavior"] = default_cache_behavior
    if cache_behavior_settings is not None:
        input_["cache_behavior_settings"] = cache_behavior_settings
    if cache_behaviors is not None:
        input_["cache_behaviors"] = cache_behaviors
    if is_enabled is not None:
        input_["is_enabled"] = is_enabled
    if viewer_minimum_tls_protocol_version is not None:
        input_["viewer_minimum_tls_protocol_version"] = (
            viewer_minimum_tls_protocol_version
        )
    if certificate_name is not None:
        input_["certificate_name"] = certificate_name
    if use_default_certificate is not None:
        input_["use_default_certificate"] = use_default_certificate
    if enable_private_origin_access is not None:
        input_["enable_private_origin_access"] = enable_private_origin_access
    if default_root_object is not None:
        input_["default_root_object"] = default_root_object
    if custom_error_responses is not None:
        input_["custom_error_responses"] = custom_error_responses

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output