Creating Custom Actions

Overview

Platform or DevOps engineers can define custom Actions for any module in Facets.cloud. Once defined, these actions automatically become available for all resource instances of that module in every environment.

Custom Actions are implemented using containerised workflows managed by Facets. You define the logic, environment, and parameters — Facets handles authentication, execution, and UI integration.


Defining an Action (Terraform Resource)

Actions are defined using the Terraform resource facets_tekton_action_kubernetes.

Example

resource "facets_tekton_action_kubernetes" "restart_app" {
  name                  = "Restart Application"
  description           = "Performs a rollout restart of the app deployment"
  facets_resource_name  = var.instance_name
  facets_environment    = var.environment
  facets_resource       = var.instance

  steps = [
    {
      name   = "rollout-restart"
      image  = "bitnami/kubectl:latest"
      script = <<-EOT
        kubectl rollout restart deployment/${var.instance.metadata.name} -n ${var.environment.namespace}
      EOT
    }
  ]
}

Key Arguments

FieldDescriptionRequired
nameDisplay name of the action (shown in UI)
descriptionShort description shown in the Actions tab
facets_resource_nameBlueprint resource name (var.instance_name)
facets_environmentEnvironment reference (var.environment)
facets_resourceResource instance (var.instance)
steps[]List of workflow steps to execute
steps[].imageContainer image for the step
steps[].scriptShell script or command to execute
params[]Optional input parameters for user-provided values

Runtime Environment

Each Action runs in an isolated Pod with:

  • Auto-injected credentials for scoped Kubernetes access (FACETS_USER_KUBECONFIG)
  • Injected environment variables:
    • FACETS_USER_EMAIL – email of the user who triggered the action
    • KUBECONFIG – preconfigured path (/workspace/.kube/config)

This ensures all steps execute with proper RBAC-based permissions of the triggering user.


Labeling and Discovery

Facets automatically tags all Action resources with standardized labels for tracking and discovery:

LabelDescription
display_nameHuman-readable name of the Action
resource_nameFacets blueprint resource name
resource_kindResource kind (e.g., application, service)
environment_unique_nameEnvironment identifier
cluster_idInternal cluster label (auto-assigned)

These labels allow the Facets backend to dynamically surface the right Actions for each resource type in the UI.


Tips and Best Practices

  • Keep scripts lightweight — each step runs inside a short-lived container.
  • Use official container images whenever possible (e.g., bitnami/kubectl, alpine, python).
  • Validate parameters before executing destructive operations.
  • Name actions clearly for better discoverability in the UI.