create_policy
async
¶
create_policy(
policy_name: PolicyName,
priority: Priority,
firewall_type: PolicyFirewallType,
policy_configuration: PolicyConfiguration,
*,
config_overrides: Optional[AsyncNetworkSecurityManagerClientConfig] = None,
client_token: Optional[IdempotencyToken] = None,
policy_description: Optional[Description] = None,
associated_template_and_rule_list: Optional[TemplateAndRuleReferenceList] = None,
is_published: Optional[IsPublished] = None,
tags: Optional[TagMap] = None,
) -> CreatePolicyOutput
Creates a policy. A policy combines templates and rules with enforcement settings for a firewall type, such as AWS WAF or AWS Shield Advanced. Use isPublished to create the policy 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.
-
policy_name(PolicyName) –The name of the policy.
-
policy_description(Optional[Description], default:None) –A description of the policy.
-
priority(Priority) –The priority of the resource. A lower number indicates a higher priority.
-
associated_template_and_rule_list(Optional[TemplateAndRuleReferenceList], default:None) –The templates and rules to associate with the policy. For AWS WAF policies, specify 1 to 100 templates or rules, of which at most 2 can be templates. For AWS Shield Advanced policies, this list must be empty.
-
firewall_type(PolicyFirewallType) –The firewall type associated with the resource.
-
policy_configuration(PolicyConfiguration) –The configuration settings that control the policy's behavior, including remediation and firewall-type-specific settings.
-
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 policy Creates a new WAF policy in draft state with a template association.
>>> await client.create_policy(client_token='550e8400-e29b-41d4-a716-446655440002', policy_name='web-app-waf-policy', policy_description='WAF policy for web application protection', firewall_type='WAF', priority=1, associated_template_and_rule_list=[{'templateIdentifier': 'arn:aws:network-security-manager:us-east-1:123456789012:template:xyz789'}], policy_configuration={'remediationEnabled': False, 'resourcesCleanUp': False, 'wafConfig': {'existingCustomerWebACLResolution': 'NO_REMEDIATION', 'conflictResolution': 'MERGE_WHERE_APPLICABLE'}}, is_published=False)
Source code in docs_src/capo_network_security_manager/_services/async_network_security_manager.py
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 | |