Environment Manager Developer Guide - Resource Template - Rafay Product Documentation

Resource Template

Resource templates are fundamental components of environment templates, containing Infrastructure as Code (IaC), such as HCL, to define resources. They encompass variables, lifecycle hooks (e.g., pre/post actions on completion or deployment), policies, and configurations that determine whether the resource is dedicated to a specific workload or shared across multiple workloads.

Key features of resource templates include:

A resource template cannot be published independently; it must be associated with an environment template to be published. Additionally, resource templates can be shared across projects, allowing users with access to those projects to leverage them for building environment templates.


Setting Description
apiVersion Rafay’s API version eaas.envmgmt.io/v1.
Kind ResourceTemplate.
Metadata

Sample Resource Template spec

apiVersion: eaas.envmgmt.io/v1
kind: ResourceTemplate
metadata:
  name: rauto-workload-resource-template-65837
  project: defaultproject
spec:
  contexts:
  - name: rauto-rafay-creds-config-context-65837
  - name: rauto-workload-config-config-context-65837
  hooks: {}
  provider: terraform
  providerOptions:
    driver:
      name: madhucustom
    terraform:
      backendConfigs:
      - tmp/inputs/workload.tfvars
      backendType: custom
      lock: true
      refresh: true
  repositoryOptions:
    branch: resourcetemplate-testing
    directoryPath: workloads/eaas/terraform/rafay-workload
    name: rauto-repo-65837
  secret:
    name: file://artifacts/rauto-workload-resource-template-65837/sealed-secret.yaml
  variables:
  - name: cluster_name
    value: $(resource."rauto-eks-resource-template-65837".output.eks_cluster_name.value)$
    valueType: expression
  - name: postgres_host
    value: $(resource."rauto-rds-resource-template-65837".output.rds_hostname.value)$
    valueType: expression
  - name: postgres_username
    value: $(resource."rauto-rds-resource-template-65837".output.rds_username.value)$
    valueType: expression
  - name: postgres_password
    options:
      sensitive: true
    value: sealed://variables.3
    valueType: expression
  - name: redis_config_endpoint
    value: $(resource."rauto-ec-resource-template-65837".output.configuration_endpoint_address.value)$
    valueType: expression
  version: custom-noagent