Basic Template
What Will You Do¶
In this section, you will create a config context, resource template and an environment template using Git to System synchronization. The environment will execute a simple Infrastructure as Code file to print the values of preset environment variables.
Step 1: Create IaC¶
In this step, we will create IaC files within our Git repository. These files will be used by the resource template we will create in a subsequent step.
- In your Git Repository, create a file named main.tf in the following path < RepoName >/terraform/main.tf
- Populate the file with the following code
provider "local" {}
# Resource to print the variables
resource "null_resource" "access_key" {
provisioner "local-exec" {
command = <<EOF
#######################################
# Access Key: ${var.access_key} #
#######################################
EOF
}
}
resource "null_resource" "secret" {
provisioner "local-exec" {
command = <<EOF
###############################
# Secret: ${var.secret} #
###############################
EOF
}
}
- Commit the changes to the repository
You will now create a second file to store the variable configuration.
- Create a second file named variables.tf in the following path < RepoName >/terraform/variables.tf
- Populate the file with the following code
# Define variables
variable "access_key" {
description = "The access key for the environment"
type = string
}
variable "secret" {
description = "The secret for the environment"
type = string
sensitive = true
}
- Commit the changes to the repository
Step 2: Create Config Context¶
In this step, we will create a config context which stores two environment variables. One variable will be configured to contain sensitive data.
- In your Git repository, navigate to < Repo Name >/projects/< Project Name >/configcontexts
- Create a new file named em-cc.yaml in this directory
- Copy the below code into the file
- Update the following fields to match your environment
- Project
- Commit the file to the repository
apiVersion: eaas.envmgmt.io/v1
kind: ConfigContext
metadata:
name: em-gs
project: em-gs
spec:
envs:
- key: TF_VAR_access_key
options:
override:
type: notallowed
value: accesskey123
- key: TF_VAR_secret
options:
mask: true
override:
type: notallowed
sensitive: true
value: tempvalue

Now, you will go back into the console and see that the Config Context resource has been created. You will then update the sensitive variable value from the console. This will then encrypt the sensitive value and store it in Git.
- In your project, navigate to Environments -> Config Contexts
- Edit the newly created config context
- Navigate to Environment Variables
- Edit the variable named TF_VAR_secret
- Populate the Value field with any value
- Click Save
- Click Save again
Step 3: Create Resource Template¶
In this step, we will create a resource template which will execute the previously created IaC files.
- In your Git repository, navigate to < Repo Name >/projects/< Project Name >/resourcetemplates
- Create a new file named em-rt.yaml in this directory
- Copy the below code into the file
- Update the following fields to match your environment
- Project
- Agent Name
- Repository Name
- Commit the file to the repository
apiVersion: eaas.envmgmt.io/v1
kind: ResourceTemplate
metadata:
name: em-rt
project: em-gs
spec:
agents:
- name: em-gs
contexts:
- name: em-cc
provider: opentofu
providerOptions:
openTofu:
backendType: system
repositoryOptions:
branch: main
directoryPath: /terraform/
name: gitops
version: v1
versionState: draft

- In your project, navigate to Environments -> Resource Templates
You will see the newly created resource template.
Step 4: Create Environment Template¶
In this step, we will create a environment template which will execute the previously created resource template.
- In your Git repository, navigate to < Repo Name >/projects/< Project Name >/environmenttemplates
- Create a new file named em-et.yaml in this directory
- Copy the below code into the file
- Update the following fields to match your environment
- Project
- Agent Name
- Commit the file to the repository
apiVersion: eaas.envmgmt.io/v1
kind: EnvironmentTemplate
metadata:
name: em-et
project: em-gs
spec:
agents:
- name: em-gs
resources:
- kind: resourcetemplate
name: em-rt
resourceOptions:
version: v1
type: dynamic
version: v1
versionState: draft

- In your project, navigate to Environments -> Environment Templates
You will see the newly created environment template.
Step 5: Create Environment¶
In this step, we will create a environment using the environment template. The environment will run the IaC. You will be able to see the logs of the environment run to see the variables set in the config context.
- In your project, navigate to Environments -> Environments
- Click Launch on the environment template card
- Enter a name for the environment
- Click Save & Deploy
After a minute, the environment run will have completed.
- Click Show near Activities (Recent Runs)
- Expand group.em-rt.output
You will see the output of the access_key variable as well as the suppressed output of the secret variable value.
Recap¶
In this part, you used Git to System sync to create resources in Environment manager and deploy a simple IaC environment.