create_automation_rule
¶
create_automation_rule(
*,
config_overrides: Optional[SecurityHubClientConfig] = None,
tags: Optional[TagMap] = None,
rule_status: Optional[RuleStatus] = None,
rule_order: Optional[RuleOrderValue] = None,
rule_name: Optional[NonEmptyString] = None,
description: Optional[NonEmptyString] = None,
is_terminal: Optional[Boolean] = None,
criteria: Optional[AutomationRulesFindingFilters] = None,
actions: Optional[ActionList] = None,
) -> CreateAutomationRuleResponse
Creates an automation rule based on input parameters.
Parameters:
-
tags(Optional[TagMap], default:None) –User-defined tags associated with an automation rule.
-
rule_status(Optional[RuleStatus], default:None) –Whether the rule is active after it is created. If this parameter is equal to
ENABLED, Security Hub CSPM starts applying the rule to findings and finding updates after the rule is created. To change the value of this parameter after creating a rule, useBatchUpdateAutomationRules. -
rule_order(Optional[RuleOrderValue], default:None) –An integer ranging from 1 to 1000 that represents the order in which the rule action is applied to findings. Security Hub CSPM applies rules with lower values for this parameter first.
-
rule_name(Optional[NonEmptyString], default:None) –The name of the rule.
-
description(Optional[NonEmptyString], default:None) –A description of the rule.
-
is_terminal(Optional[Boolean], default:None) –Specifies whether a rule is the last to be applied with respect to a finding that matches the rule criteria. This is useful when a finding matches the criteria for multiple rules, and each rule has different actions. If a rule is terminal, Security Hub CSPM applies the rule action to a finding that matches the rule criteria and doesn't evaluate other rules for the finding. By default, a rule isn't terminal.
-
criteria(Optional[AutomationRulesFindingFilters], default:None) –A set of ASFF finding field attributes and corresponding expected values that Security Hub CSPM uses to filter findings. If a rule is enabled and a finding matches the conditions specified in this parameter, Security Hub CSPM applies the rule action to the finding.
-
actions(Optional[ActionList], default:None) –One or more actions to update finding fields if a finding matches the conditions specified in
Criteria.
Raises:
-
AccessDeniedException–You don't have permission to perform the action specified in the request.
-
InternalException–Internal server error.
-
InvalidAccessException–The account doesn't have permission to perform this action.
-
InvalidInputException–The request was rejected because you supplied an invalid or out-of-range value for an input parameter.
-
LimitExceededException–The request was rejected because it attempted to create resources beyond the current Amazon Web Services account or throttling limits. The error code describes the limit exceeded.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an automation rule The following example creates an automation rule.
>>> client.create_automation_rule(tags={'important-resources-rule': 's3-bucket'}, rule_status='ENABLED', rule_order=1, rule_name='Elevate severity for important resources', description='Elevate finding severity to Critical for important resources', is_terminal=False, criteria={'ProductName': [{'Value': 'Security Hub', 'Comparison': 'EQUALS'}], 'ComplianceStatus': [{'Value': 'FAILED', 'Comparison': 'EQUALS'}], 'RecordState': [{'Value': 'ACTIVE', 'Comparison': 'EQUALS'}], 'WorkflowStatus': [{'Value': 'NEW', 'Comparison': 'EQUALS'}], 'ResourceId': [{'Value': 'arn:aws:s3:::examplebucket/developers/design_info.doc', 'Comparison': 'EQUALS'}]}, actions=[{'Type': 'FINDING_FIELDS_UPDATE', 'FindingFieldsUpdate': {'Severity': {'Label': 'CRITICAL'}, 'Note': {'Text': 'This is a critical S3 bucket, please look into this ASAP', 'UpdatedBy': 'test-user'}}}])
Source code in docs_src/capo_securityhub/_services/security_hub.py
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 | |