Skip to content

modify_rule

modify_rule(
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    rule_arn: Optional[RuleArn] = None,
    conditions: Optional[RuleConditionList] = None,
    actions: Optional[Actions] = None,
    transforms: Optional[RuleTransformList] = None,
    reset_transforms: Optional[ResetTransforms] = None,
) -> ModifyRuleOutput

Replaces the specified properties of the specified rule. Any properties that you do not specify are unchanged.

To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.

Parameters:

  • rule_arn (Optional[RuleArn], default: None ) –

    The Amazon Resource Name (ARN) of the rule.

  • conditions (Optional[RuleConditionList], default: None ) –

    The conditions.

  • actions (Optional[Actions], default: None ) –

    The actions.

  • transforms (Optional[RuleTransformList], default: None ) –

    The transforms to apply to requests that match this rule. You can add one host header rewrite transform and one URL rewrite transform. If you specify Transforms, you can't specify ResetTransforms.

  • reset_transforms (Optional[ResetTransforms], default: None ) –

    Indicates whether to remove all transforms from the rule. If you specify ResetTransforms, you can't specify Transforms.

Raises:

Examples:

To modify a rule This example modifies the condition for the specified rule.

>>> client.modify_rule(rule_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee', conditions=[{'Field': 'path-pattern', 'Values': ['/images/*']}])
To modify a Network Load Balancer listener rule
This example modifies an NLB listener rule to forward traffic to a different target group.
>>> client.modify_rule(rule_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/net/my-nlb/1234567890abcdef/1234567890abcdef/1234567890abcdef', actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-ipv4-targets/1234567890abcdef'}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
def modify_rule(
    self,
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    rule_arn: Optional[
        "capo_elastic_load_balancing_v2.types.rule_arn.RuleArn"
    ] = None,
    conditions: Optional[
        "capo_elastic_load_balancing_v2.types.rule_condition_list.RuleConditionList"
    ] = None,
    actions: Optional[
        "capo_elastic_load_balancing_v2.types.actions.Actions"
    ] = None,
    transforms: Optional[
        "capo_elastic_load_balancing_v2.types.rule_transform_list.RuleTransformList"
    ] = None,
    reset_transforms: Optional[
        "capo_elastic_load_balancing_v2.types.reset_transforms.ResetTransforms"
    ] = None,
) -> "capo_elastic_load_balancing_v2.types.modify_rule_output.ModifyRuleOutput":
    """<p>Replaces the specified properties of the specified rule. Any properties that you do not specify are unchanged.</p> <p>To add an item to a list, remove an item from a list, or update an item in a list, you must provide the entire list. For example, to add an action, specify a list with the current actions plus the new action.</p>

    Args:
        rule_arn: <p>The Amazon Resource Name (ARN) of the rule.</p>
        conditions: <p>The conditions.</p>
        actions: <p>The actions.</p>
        transforms: <p>The transforms to apply to requests that match this rule. You can add one host header rewrite transform and one URL rewrite transform. If you specify <code>Transforms</code>, you can't specify <code>ResetTransforms</code>.</p>
        reset_transforms: <p>Indicates whether to remove all transforms from the rule. If you specify <code>ResetTransforms</code>, you can't specify <code>Transforms</code>.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.incompatible_protocols_exception.IncompatibleProtocolsException: <p>The specified configuration is not valid with this protocol.</p>
        capo_elastic_load_balancing_v2.errors.invalid_load_balancer_action_exception.InvalidLoadBalancerActionException: <p>The requested action is not valid.</p>
        capo_elastic_load_balancing_v2.errors.operation_not_permitted_exception.OperationNotPermittedException: <p>This operation is not allowed.</p>
        capo_elastic_load_balancing_v2.errors.rule_not_found_exception.RuleNotFoundException: <p>The specified rule does not exist.</p>
        capo_elastic_load_balancing_v2.errors.target_group_association_limit_exception.TargetGroupAssociationLimitException: <p>You've reached the limit on the number of load balancers per target group.</p>
        capo_elastic_load_balancing_v2.errors.target_group_not_found_exception.TargetGroupNotFoundException: <p>The specified target group does not exist.</p>
        capo_elastic_load_balancing_v2.errors.too_many_actions_exception.TooManyActionsException: <p>You've reached the limit on the number of actions per rule.</p>
        capo_elastic_load_balancing_v2.errors.too_many_registrations_for_target_id_exception.TooManyRegistrationsForTargetIdException: <p>You've reached the limit on the number of times a target can be registered with a load balancer.</p>
        capo_elastic_load_balancing_v2.errors.too_many_targets_exception.TooManyTargetsException: <p>You've reached the limit on the number of targets.</p>
        capo_elastic_load_balancing_v2.errors.too_many_unique_target_groups_per_load_balancer_exception.TooManyUniqueTargetGroupsPerLoadBalancerException: <p>You've reached the limit on the number of unique target groups per load balancer across all listeners. If a target group is used by multiple actions for a load balancer, it is counted as only one use.</p>
        capo_elastic_load_balancing_v2.errors.unsupported_protocol_exception.UnsupportedProtocolException: <p>The specified protocol is not supported.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To modify a rule
        This example modifies the condition for the specified rule.

        >>> client.modify_rule(rule_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/app/my-load-balancer/50dc6c495c0c9188/f2f7dc8efc522ab2/9683b2d02a6cabee', conditions=[{'Field': 'path-pattern', 'Values': ['/images/*']}])
        To modify a Network Load Balancer listener rule
        This example modifies an NLB listener rule to forward traffic to a different target group.

        >>> client.modify_rule(rule_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:listener-rule/net/my-nlb/1234567890abcdef/1234567890abcdef/1234567890abcdef', actions=[{'Type': 'forward', 'TargetGroupArn': 'arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-new-ipv4-targets/1234567890abcdef'}])
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing_v2.types.modify_rule_input.ModifyRuleInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing_v2.types.modify_rule_output.ModifyRuleOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.modify_rule

        output, http_response = (
            capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.modify_rule.modify_rule(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyRule")
    )
    input_: capo_elastic_load_balancing_v2.types.modify_rule_input.ModifyRuleInput = {}
    if rule_arn is not None:
        input_["rule_arn"] = rule_arn
    if conditions is not None:
        input_["conditions"] = conditions
    if actions is not None:
        input_["actions"] = actions
    if transforms is not None:
        input_["transforms"] = transforms
    if reset_transforms is not None:
        input_["reset_transforms"] = reset_transforms

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