# Runtime Policies

The runtime policies allows you to validate policies in runtime through 3rd party policy engines (like Open Policy Agent) using REST API.

### Create Policy

To create a new policy follow the steps below:

1. Click “**Compliance**” → Click “**Policy Management**” → “+**New Policy**” button as shown below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FAlyGWBPkrylcfSWNgnAT%2F39.png?alt=media\&token=aea757f9-f389-4e94-a463-852b0d12b8e1)

2\. The Policy Management screen appears and select "**Runtime**" policy type as shown below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FpYcitQWLbGxVdN9XVE3N%2F40.png?alt=media\&token=e2a21512-2313-4ae2-b96f-6248218ededf)

Enter the following details:

* Enter the Name of the policy in the text box.
* Select the Policy type as Runtime from the drop-down.
* Select the Policy Engine as OPA from the drop-down.
* Select the Policy Engine Account from the drop-down.
* Enter the Policy Description in the text box.
* Select and add any available Policy file.
* Enter the **Policy Details** in the text box. Refer to the image below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FgnTLa5myQ2RHjiaYmNrh%2F41.png?alt=media\&token=66c6d94c-3fcd-4dc0-884e-120f14da1228)

The Policy details is explained below:

**Step 1**

The start time is converted to nanoseconds and the Time zone is set to `America/Los_Angeles`.

```
# convert to nanoseconds
startTime := input.startTime * 1000000
# define time zone
tz = "America/Los_Angeles"
```

&#x20;**Step 2**&#x20;

A rule is set that if the pipeline has no start time then it will not execute the pipeline.

```
deny["Pipeline has no start time"] {
   startTime == 0
}
```

&#x20;**Step 3**

A rule is set that no pipeline will be deployed between 2nd - 27th September 2020.

```
deny["No deploys between 2nd - 27th sept 2020"] {
   [year, month, day] := time.date(time.now_ns())
   year == 2020
   month == 9
   day > 2
   day < 27
 }
```

3\. After entering the details click **Save & Finish** to create the policy as shown in the image below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FNSq2q12COj19S91jsYM9%2F42.png?alt=media\&token=34d57a71-c08b-414f-b2d6-266135a99526)

### **Edit Policy**

To edit a policy follow the steps below:

1. Click the icon beside the name of the policy and select Edit as shown in the image below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FdQOcM2zIXVygWHxbZtfG%2F43.png?alt=media\&token=da52e389-2cdb-4972-bcaa-6f5eeb7811a2)

2\. Edit the required details and click **Save & Finish.**

### **Delete Policy**

To delete a policy follow the steps given below:

1. Click the icon beside the name of the policy and select Delete as shown in the image below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FEgMrpZXbHnXfXmw7Rvp1%2F44.png?alt=media\&token=b7da16aa-0c5a-46db-8373-175da0f84697)

2\. The confirmation pop-up appears as shown below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBEa1hoX6SqpDj-ymNs%2Fuploads%2FYKP3L0rFuxwgn1a8t511%2F45.png?alt=media\&token=c18a967c-26f6-465f-b1cf-0e0ae9a40682)

3\. Click **Yes, delete it!** to delete the policy.
