# Runtime Policies

{% hint style="info" %}
This is an older version of the document. To view the most recent version of the document, click [here](https://docs.opsmx.com/products/data-and-intelligence-module-autopilot/continuous-compliance-policy/runtime-policies).
{% endhint %}

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 the New Policy button as shown below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MUSyQE1oQzXJJZ2fXBN%2F-MUSz1ZM2ewULxJDQjF7%2Fimage.png?alt=media\&token=67d9b70e-e21b-443c-a9e6-fa4a204d11e4)

2\. The Policy Management screen appears as shown below:

![](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MUSyQE1oQzXJJZ2fXBN%2F-MUSzKGA5ofN6c3dwW5y%2Fimage.png?alt=media\&token=c42b5ecd-e9f2-41d5-8602-0d6055f598b8)

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-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MUSyQE1oQzXJJZ2fXBN%2F-MUT-889cyZSOCxLHTbn%2Fimage.png?alt=media\&token=31f9e6f4-e743-4471-9907-b6bb19b2dd89)

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:

![Save Policy Details](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MHKNkMa2HseVJWWGC0V%2F-MHKVrv6qBaZwuTtNxfD%2Fpolicy_management7.png?alt=media\&token=a3127215-a331-4b2d-b2e1-dceb6199e53b)

### &#x20; **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-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MUSyQE1oQzXJJZ2fXBN%2F-MUT-KBBiNn1cIaiHHsn%2Fimage.png?alt=media\&token=e85616c7-59cb-4b9c-b222-5d2921e2876b)

2\. The Policy Management screen appears. Edit the 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-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MUSyQE1oQzXJJZ2fXBN%2F-MUT-VUPxVRkNqEeK5TT%2Fimage.png?alt=media\&token=d503cc0f-471a-453d-a500-e0fd7443ffbf)

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

![Delete Policy Confirmation ](https://2047464521-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBEa1hoX6SqpDj-ymNs%2F-MHKW2aYHMjGXkNBp_IZ%2F-MHMyBK_VXt7k-86VTSN%2Fimage.png?alt=media\&token=c10238ad-c271-434c-9465-b06126605f3d)

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