create_rule
¶
create_rule(
rule_name: RuleName,
firewall_type: RuleFirewallType,
rule_type: RuleType,
configuration: JsonDocument,
*,
config_overrides: Optional[NetworkSecurityManagerClientConfig] = None,
client_token: Optional[IdempotencyToken] = None,
rule_description: Optional[Description] = None,
is_published: Optional[IsPublished] = None,
tags: Optional[TagMap] = None,
) -> CreateRuleOutput
Creates a rule. A rule defines a network security configuration to enforce, such as an AWS WAF rule group or configuration data. Use isPublished to create the rule in published (ACTIVE) or draft (DRAFT) state.
Parameters:
-
client_token(Optional[IdempotencyToken], default:None) –A unique, case-sensitive token that you provide to ensure that the operation completes no more than one time. If you retry a request with the same client token and the same parameters, the service returns the result of the original successful request.
-
rule_name(RuleName) –The name of the rule.
-
firewall_type(RuleFirewallType) –The firewall type associated with the resource.
-
rule_type(RuleType) –The type of the rule.
CONFIGURATIONrules contain firewall settings, andINSPECTIONrules contain rule groups. -
rule_description(Optional[Description], default:None) –A description of the rule.
-
configuration(JsonDocument) –The firewall configuration for the rule, as a JSON document. The structure depends on the rule's firewall type and rule type. For an AWS WAF
INSPECTIONrule, provide an AWS WAF rule group. For an AWS WAFCONFIGURATIONrule, provide a single web ACL setting, such asDefaultActionorVisibilityConfig; usewafConfigDataTypeto declare which setting the document contains. For the schema of each setting and complete examples, see Writing rule configurations in the AWS Network Security Manager Developer Guide. -
is_published(Optional[IsPublished], default:None) –Specifies whether to publish the resource. When
true, the resource is saved in published (ACTIVE) state. Whenfalse, it is saved as a draft (DRAFT). Default:true. -
tags(Optional[TagMap], default:None) –The tags to add to the resource when it is created.
Raises:
-
AccessDeniedException–You do not have sufficient permissions to perform this action.
-
ConflictException–The request conflicts with the current state of the resource. For example, the resource was modified concurrently, or it is in a state that does not allow the requested operation.
-
InternalServerException–The request processing failed because of an internal error in the service. This is a retryable error.
-
ServiceQuotaExceededException–The request would exceed a service quota.
-
ServiceUnavailableException–The service is temporarily unavailable. This is a retryable error.
-
TagPolicyViolationException–The request violates a tag policy that is in effect for the account or organization.
-
ThrottlingException–The request was denied because of request throttling. Reduce your request rate and try again.
-
ValidationException–The request failed validation. For details, see the
reasonandfieldListmembers of the response. -
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Create a WAF rule Creates a new WAF inspection rule in draft state.
>>> client.create_rule(client_token='550e8400-e29b-41d4-a716-446655440000', rule_name='block-known-bad-ips', firewall_type='WAF', rule_type='INSPECTION', rule_description='Blocks requests from known malicious IP addresses', configuration={}, is_published=False)
Source code in docs_src/capo_network_security_manager/_services/network_security_manager.py
2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 | |