Declare the Flow

Now comes the fun part! We'll create the actual Sym Flow which will wrap an approval workflow around your existing user impersonation screen.

Let's create a Terraform file at sym/flows/main.tf.

Setup

We need a bit of a preamble.

terraform {
  required_version = ">= 0.14"
  required_providers {
    sym = {
      source = "terraform.symops.com/symopsio/sym"
      version = "0.1"
    }
  }
}

provider "sym" {
  org = "healthy-health"
}

Declare Flow

Our flow will inherit from the sym:approval template.

# A Flow that will receive API calls from Django,
# route for approval in Slack, 
# then save the approval state in Sym.
resource "sym_flow" "this" {
  name = "user_impersonation"
  label = "User Impersonation"
    
  template = "sym:approval:1.0"
  # We'll cover this file in the next section:
  implementation = "impl.py"

  params = {
    # The Sym middleware integration from Django will submit these values.
    # `customer_id` & `customer_plan` will be looked up programatically,
    # and the user will supply a `reason`.
    fields = [{
      name = "customer_id"
      type = "int"
      required = true
    }, {
      name = "customer_plan"
      type = "string"
      required = true
    }, {
      name = "reason"
      type = "string"
      required = true
    }]
  }
}

Escalation Logic

Before we can provision this flow, we'll have to implement impl.py from above with our get_approvers reducer.


Did this page help you?