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
| Field | Description | Required |
|---|---|---|
name | Display name of the action (shown in UI) | ✅ |
description | Short description shown in the Actions tab | |
facets_resource_name | Blueprint resource name (var.instance_name) | ✅ |
facets_environment | Environment reference (var.environment) | ✅ |
facets_resource | Resource instance (var.instance) | ✅ |
steps[] | List of workflow steps to execute | ✅ |
steps[].image | Container image for the step | ✅ |
steps[].script | Shell 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 actionKUBECONFIG– 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:
| Label | Description |
|---|---|
display_name | Human-readable name of the Action |
resource_name | Facets blueprint resource name |
resource_kind | Resource kind (e.g., application, service) |
environment_unique_name | Environment identifier |
cluster_id | Internal 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.
Updated 2 days ago