Overview

Expressions enable users to dynamically configure input variables by utilizing the output of other resources or configurations. This capability allows platform teams to create programmable templates for provisioning infrastructure and applications. Using resource output as input to another via expressions refers to taking the output of one resource, such as a Terraform resource template, and using it as input for another resource. In Terraform, outputs are defined in the configuration, as shown below:

output "vpc_id" {
  value = module.vpc.vpc_id
}

Currently, only Terraform is supported for outputs, but different types of expressions such as CUE, Starlark, and JSONPath can be used to enhance flexibility, validation, and data extraction across workflows.

Recommendation: It is recommended to use Starlark expressions as they provide a powerful and flexible way to handle complex logic within the Rafay environment. Utilizing a subset of Python, Starlark enables programmability and computations. This language offers the advantage of interacting directly with Rafay APIs through expressions, facilitating the creation of dynamic and adaptable workflows.

  • CUE is a declarative language designed to validate and unify configurations by enforcing constraints and defining rules. It helps ensure that resource outputs meet specific requirements, making it ideal for maintaining consistency across configurations. CUE’s structured approach simplifies the management of configurations and relationships between resources, ensuring reliable and repeatable workflows. CUE expressions are specifically designed for accessing environment-related data.

  • Starlark is a Python-like scripting language that provides flexibility for complex computations, dynamic workflows, and direct interaction with APIs, such as retrieving kubeconfig files. Its hermetic execution ensures secure, sandboxed operations, while its simple and familiar syntax makes it accessible for users who need programmability and logic-driven expressions. Starlark is well-suited for tasks that involve advanced processing and safe execution in dynamic environments. These expressions provide the capability to interact with any first-class objects in Rafay, such as workloads, namespaces, clusters, and more.

  • JSONPath is a query language used to efficiently extract and filter specific data from complex JSON structures. Its clear and readable expressions simplify navigation through JSON outputs, making it effective for handling dynamic or varying data formats. JSONPath’s interoperability with various tools and programming languages ensures seamless integration, enabling structured and precise data extraction for a wide range of use cases.