Add a Hook to an Environment Template - Rafay Product Documentation

Hooks

In this section, you will insert custom logic into your "environment template" using a HTTPS based hook. The HTTPS hook will be used to demonstrate a simple GET request to a well known endpoint.

You will implement the steps described below

  1. You will update your existing environment template from the prior step to use a HTTPS hook
  2. You will then launch the template and view the results of the hook

Step 1: Create Hook

In this step, you will update the existing environment template used in the previous step by adding a hook to the template. The hook will perform a simple HTTP GET request on a well known website to retrieve the content of the webpage.

if #status.http.statusCode == 200 {
  success: true
  reason: #status.http.body
}

if #status.http.statusCode != 200 {
  failed: true
  reason: "Did not get a 200 response code."
}

- Click Save Changes


Step 2: Create Environment

In this step, we will create a new environment using the recently updated environment template. The environment will perform the same actions as before, however, during this run it will execute the HTTP hook.

After the environment has been deployed, we will review the output of the newly added hook.

You will see the HTML output of the webpage that was used in our hook configuration.


Recap

In this part, you updated the the environment template to use a HTTPS hook that performed a simple GET request to an external endpoint.