Skip to content

create_app_cookie_stickiness_policy

create_app_cookie_stickiness_policy(
    load_balancer_name: AccessPointName,
    policy_name: PolicyName,
    cookie_name: CookieName,
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> CreateAppCookieStickinessPolicyOutput

Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This policy can be associated only with HTTP/HTTPS listeners.

This policy is similar to the policy created by CreateLBCookieStickinessPolicy, except that the lifetime of the special Elastic Load Balancing cookie, AWSELB, follows the lifetime of the application-generated cookie specified in the policy configuration. The load balancer only inserts a new stickiness cookie when the application response includes a new application cookie.

If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.

For more information, see Application-Controlled Session Stickiness in the Classic Load Balancers Guide.

Parameters:

  • load_balancer_name (AccessPointName) –

    The name of the load balancer.

  • policy_name (PolicyName) –

    The name of the policy being created. Policy names must consist of alphanumeric characters and dashes (-). This name must be unique within the set of policies for this load balancer.

  • cookie_name (CookieName) –

    The name of the application cookie used for stickiness.

Raises:

Examples:

To generate a stickiness policy for your load balancer This example generates a stickiness policy that follows the sticky session lifetimes of the application-generated cookie.

>>> client.create_app_cookie_stickiness_policy(load_balancer_name='my-load-balancer', policy_name='my-app-cookie-policy', cookie_name='my-app-cookie')
Source code in docs_src/capo_elastic_load_balancing/_services/elastic_load_balancing.py
def create_app_cookie_stickiness_policy(
    self,
    load_balancer_name: "capo_elastic_load_balancing.types.access_point_name.AccessPointName",
    policy_name: "capo_elastic_load_balancing.types.policy_name.PolicyName",
    cookie_name: "capo_elastic_load_balancing.types.cookie_name.CookieName",
    *,
    config_overrides: Optional[ElasticLoadBalancingClientConfig] = None,
) -> "capo_elastic_load_balancing.types.create_app_cookie_stickiness_policy_output.CreateAppCookieStickinessPolicyOutput":
    """<p>Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This policy can be associated only with HTTP/HTTPS listeners.</p> <p>This policy is similar to the policy created by <a>CreateLBCookieStickinessPolicy</a>, except that the lifetime of the special Elastic Load Balancing cookie, <code>AWSELB</code>, follows the lifetime of the application-generated cookie specified in the policy configuration. The load balancer only inserts a new stickiness cookie when the application response includes a new application cookie.</p> <p>If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html#enable-sticky-sessions-application">Application-Controlled Session Stickiness</a> in the <i>Classic Load Balancers Guide</i>.</p>

    Args:
        load_balancer_name: <p>The name of the load balancer.</p>
        policy_name: <p>The name of the policy being created. Policy names must consist of alphanumeric characters and dashes (-). This name must be unique within the set of policies for this load balancer.</p>
        cookie_name: <p>The name of the application cookie used for stickiness.</p>

    Raises:
        capo_elastic_load_balancing.errors.access_point_not_found_exception.AccessPointNotFoundException: <p>The specified load balancer does not exist.</p>
        capo_elastic_load_balancing.errors.duplicate_policy_name_exception.DuplicatePolicyNameException: <p>A policy with the specified name already exists for this load balancer.</p>
        capo_elastic_load_balancing.errors.invalid_configuration_request_exception.InvalidConfigurationRequestException: <p>The requested configuration change is not valid.</p>
        capo_elastic_load_balancing.errors.too_many_policies_exception.TooManyPoliciesException: <p>The quota for the number of policies for this load balancer has been reached.</p>
        capo_elastic_load_balancing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To generate a stickiness policy for your load balancer
        This example generates a stickiness policy that follows the sticky session lifetimes of the application-generated cookie.

        >>> client.create_app_cookie_stickiness_policy(load_balancer_name='my-load-balancer', policy_name='my-app-cookie-policy', cookie_name='my-app-cookie')
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing.types.create_app_cookie_stickiness_policy_input.CreateAppCookieStickinessPolicyInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing.types.create_app_cookie_stickiness_policy_output.CreateAppCookieStickinessPolicyOutput"
    ]:
        import capo_elastic_load_balancing._operations.elastic_load_balancing_v7.create_app_cookie_stickiness_policy

        output, http_response = (
            capo_elastic_load_balancing._operations.elastic_load_balancing_v7.create_app_cookie_stickiness_policy.create_app_cookie_stickiness_policy(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAppCookieStickinessPolicy")
    )
    input_: capo_elastic_load_balancing.types.create_app_cookie_stickiness_policy_input.CreateAppCookieStickinessPolicyInput = {
        "load_balancer_name": load_balancer_name,
        "policy_name": policy_name,
        "cookie_name": cookie_name,
    }

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