WAF Custom Policies
If the system-defined policies of WAF cannot meet your needs, you can create custom policies.
You can create custom policies in either of the following ways:
- Visual editor: Select cloud services, actions, resources, and request conditions. This does not require knowledge of policy syntax.
- JSON: Edit JSON policies from scratch or based on an existing policy.
For details, see Creating a Custom Policy.

WAF does not support the g:RequestedRegion request condition key. Do not select this condition key when adding a request condition. Otherwise, the custom policy does not take effect.
If the WAF console displays a message indicating that you do not have the permission to perform an operation, check whether the g:RequestedRegion condition key has been added to the request condition. If yes, deselect g:RequestedRegion from the visual editor or delete g:RequestedRegion from the JSON editor.
For details about the actions supported by custom policies, see WAF Permissions and Supported Actions.
WAF Example Custom Policies
You can configure custom policies by referring to the following examples.
{ "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "waf:instance:list" ] } ] }
A deny policy must be used together with other policies. If the permissions assigned to a user contain both "Allow" and "Deny", the "Deny" permissions take precedence over the "Allow" permissions.
The following method can be used if you need to assign permissions of the WAF FullAccess policy to a user but also forbid the user from deleting web tamper protection rules (waf:antiTamperRule:delete). Create a custom policy with the action to delete web tamper protection rules, set its Effect to Deny, and assign both this policy and the WAF FullAccess policy to the group the user belongs to. Then the user can perform all operations on WAF except deleting web tamper protection rules. The following is a policy for denying web tamper protection rule deletion.
{ "Version": "1.1", "Statement": [ { "Effect": "Deny", "Action": [ "waf:antiTamperRule:delete" ] }, ] }
A custom policy can contain the actions of multiple services that are of the project-level type. The following is an example policy containing actions of multiple services:
{ "Version": "1.1", "Statement": [ { "Effect": "Allow", "Action": [ "waf:instance:get", "waf:certificate:get" ] }, { "Effect": "Allow", "Action": [ "hss:hosts:switchVersion", "hss:hosts:manualDetect", "hss:manualDetectStatus:get" ] } ] }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot