Code Editor

Creating Custom Policies in Code

To build a Custom Policy in code:

  1. Under Policies, select New Policy.
  2. Select the code editor option at the top of the page - [ ].

The code editor displays a basic YAML-based Policy template. You can use the template or create your Custom Policy in an external editor and paste it here when ready.
See Policy Definition Structure and Syntax and examples of Custom Policies in code.

Check Code

You can check for errors in:

  • Generic YAML syntax
  • Policy Definition Structure

Check YAML Syntax

If your code includes YAML syntax errors, the first instance is indicated by an X next to the relevant row and details of the error above the editor.
change the image below

Check Policy Definition Structure

Once all YAML syntax issues are resolved, you can press Test, at the top of the page, to validate the Custom Policy.

  • If the Policy is error-free, a Bridgecrew scan will be run for the Policy and the results (up to a maximum of 30) will appear on the right side of the page. This allows you to check your Custom Policy.
  • If the Policy contains errors, the number of errors and their details appear above the editor.

Saving Code Policies

When all errors have been corrected, you can select DONE to save your Custom policy.
Upon a successful save, the Policies grid will be displayed.

📘

Note

Saved custom policies can be inspected, edited or deleted from the Policies grid .

Additional Functions

Selecting the menu at the top of the editor will give you options to:

  • Format YAML - this applies indentation based on standard YAML format
  • Clear Editor - to delete the code currently in the editor

Did this page help you?