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
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 | |