create_policy
¶
create_policy(
policy_name: PolicyName,
priority: Priority,
firewall_type: PolicyFirewallType,
policy_configuration: PolicyConfiguration,
*,
config_overrides: Optional[NetworkSecurityManagerClientConfig] = 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.
>>> 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/network_security_manager.py
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 | |