Skip to content

Resource Template

Resource templates are the building blocks of Environment templates and include Terraform Infrastructure as Code (IaC) that defines a resource, including variables, lifecycle hooks (pre/post actions upon completion, deployment, etc.), Terraform hooks, policies, whether the resource will be dedicated per workload or shared, and more.

Create a Resource Template

  1. In a project, select Environments > Resource Templates.
  2. Select New Resource Template.
  3. Type a name for the resource template. Optionally, type a description.
  4. Select a Git Repository. The repository resource must be created before creating the resource template. See [Repositories] for more information.
  5. Select Create. The resource template is created and the configuration page displays.
  6. See below for information about each configuration category. Use the table of contents links (right-side navigation) to view a section.
  7. Select Save to save the resource template. Click Cancel to close the configuration and go back to the resource template list.

General

Setting Description
Version Name Enter the version for the resource. Examples: v1, 0.1, 3.
Name Enter a name for the resource.
Description Enter a description for the resource. This is optional.
Provider Select the provider for the resource. Supported value is Terraform.
Provider Version Enter the provider version for the resource.
Labels Add a label to the resource. Use labels to specify identifying attributes of objects that are meaningful and relevant to users, but do not directly imply semantics to the core system. This is a key-value pair. For example, the key is environment and the value is dev.
Annotations Add an annotation to the resource. Use annotations to attach arbitrary non-identifying metadata to the resource. This is a key-value pair. For example, the key is imageregistry and the value is https://hub.docker.com/.

Repository

Setting Description
Repository Name Select the name for the repository.
Branch Enter the branch to use for the repository. Example: master.
Directory Path Enter the directory path for the configuration file in the repository.

Configuration

Setting Description
Refresh Read the current settings from the resource and update if necessary.
Use system state store Select to use the Rafay system state store. You can alternatively configure the Backend Config to store the state data files
Lock Lock a resource to prevent accidental modifications or deletion.
Var Files Add var files to the resource.
Backend Config Enter the backend config for the resource. A backend defines where Terraform stores its state data files. See Backend Config - Terraform for more details.
Plugin Dirs Enter the plugin directory for the resource. This is optional. See Managing Plugins for more details.

Hooks

A hook runs during a specified point when creating a resource from a template. Hooks can extend the functionality of creating a resource, like sending an HTTP request to a system.

Resource Hooks

Create a resource hook. See Hook Type for parameter details about each hook type.

Setting Description
On Completion Set a hook that is triggered when resource creation or updating is complete.
On Failure Set a hook that is triggered when resource creation or updating fails to complete.
On Init Set a hook that is triggered when resource creation or updating is initialized.
On Success Set a hook that is triggered when resource creation or updating is successful.

Terraform Hooks

Create a Terraform hook. See Hook Type for parameter details about each hook type.

Deploy

Create a Terraform hook that is triggered when the resource is deployed.

Setting Description
Init Deploy the resource when terraform init is used.
Plan Deploy the resource when terraform plan is used.
Apply Deploy the resource when terraform apply is used.
Output Deploy the resource when an output is used.

Destroy

Create a Terraform hook that is triggered when the resource is destroyed.

Setting Description
Init Destroy the resource when terraform init is used.
Plan Destroy the resource when terraform plan is used.
Destroy Destroy the resource when terraform destroy is used.

Hook Type

When adding a Resource or Terraform hook, select a hook type and set the appropriate parameters.

Approval

Setting Description
Name Enter a name for the hook.
Approval Type Select the approval type. Supported values are: Internal and Email.
-- Internal
Agent Name Select the agent to associate with this hook.
Continue on Failure Set the hook to run even if the resource creating or updating process fails.
Timeout Enter a value to set the timeout duration. If the timeout duration is exceeded, the resource creation or updating is terminated.

Container

Setting Description
Name
Container Configuration
-- cpuLimitMilli
-- Image
-- Memory Limit in MB
-- Working Directory Path
-- Success Condition
Arguments
Commands
Environment Variables
Agent Name
Continue on Failure
Timeout

HTTP

Setting Description
Name
HTTP Configuration
-- Body
-- Endpoint
-- Method
-- Success Condition
Headers
Agent Name
Continue on Failure
Timeout

Agents

Parameter Description
Name Select an agent to associate with this resource.

Input Variables

Setting Description
Name The name of the variable.
Description A brief description of the variable.
Value The variable value.
Value Type The type of value.
-- HCL Hashicorp configuration language.
-- JSON JavaScript Object Notation (JSON) is a lightweight data-interchange format.
-- Expressions Expressions are valid units of code that resolve to a value.
-- Text Text value.
Override Type Controls if a user can change a variable or not.
-- Allowed Allows the user to override the value.
-- Not Allowed Does not allow the user to override the value.
-- Restricted Allows the user to override the value by selecting a different, pre-defined value.
Restricted Values If Restricted is selected for the Override Type, enter the values that are allowed.
Sensitive Does not display the value in the UI.
Required The variable is required when using this Context.

Contexts

Setting Description
Context Select a Context to associate with this resource.