> ## Documentation Index
> Fetch the complete documentation index at: https://docs.envzero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Your First Template

> Create your first env zero template by linking a VCS from GitHub, GitLab, Bitbucket, or Azure DevOps, specifying an IaC folder, and assigning it to a project.

<Info>
  This step assumes you have already [connected your cloud account](/guides/getting-started/connect-your-cloud-account).
</Info>

[Templates](/guides/getting-started/glossary#template) are how you add your infrastructure code to env zero. You need to tell env zero how to connect to your VCS and where to find your IaC code.

<Tip>
  If you don't have a repository yet, fork [env0/templates](https://github.com/env0/templates). For a simple starting point, try the `aws/simple-ec2` example (AWS) or another example that matches your cloud provider. Each folder has a README that lists what it deploys and which variables it requires.
</Tip>

## Create your template

1. Open the **Organization Templates** page.

<Frame caption="Link to Organization Templates">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/organization_templates_page_link.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=60efb3f69f3657c6bd8030c019c724a3" alt="Organization templates page link" width="406" height="736" data-path="images/guides/getting-started/organization_templates_page_link.png" />
</Frame>

2. Click **Create New Template**.

<Frame caption="Create New Template">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/create_new_template_button.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=f5a3d218178d6fe4aa4740dd1f024fb9" alt="Create new template button" width="2240" height="436" data-path="images/guides/getting-started/create_new_template_button.png" />
</Frame>

3. Choose your desired template type. Select **Terraform** for Terraform code or **OpenTofu** for OpenTofu code. For other frameworks, select the matching tile.
4. Enter a name for your template in `Template Name`. If the form shows a version selector, choose the IaC version your code requires. If you're unsure, select the latest stable version. Click **Next**.

<img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/c023fedf434d3406af005fa4412c9ffb691f5cf9e6342b86d9ecbcc56ec80f14-image.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=66805c75360183c737fe1ded21d16cff" alt="Template creation form showing Template Name field and IaC type selection" width="1404" height="679" data-path="images/guides/getting-started/c023fedf434d3406af005fa4412c9ffb691f5cf9e6342b86d9ecbcc56ec80f14-image.png" />

5. Select your VCS provider. Follow the section below for your provider.

<Tip>
  **IaC folder path:** Each VCS section below asks for a folder (`Terraform Folder`, `Pulumi Root`, etc.). This must be the exact path to your IaC files relative to the repository root, such as `terraform/` or `infra/prod`. Leave it empty only if your IaC files are at the repository root. An incorrect path causes a "no configuration files" error during the first deployment.
</Tip>

<Frame caption="VCS provider selection">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/vcs-provider-selection.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=ef90a208ba25d10ed836acf08bc1a43b" alt="VCS provider selection showing Github.com, Gitlab.com, Bitbucket.org, Azure DevOps, and Other VCS options" width="1332" height="429" data-path="images/guides/getting-started/vcs-provider-selection.png" />
</Frame>

* [GitHub](/guides/getting-started/create-your-first-template/#github)
* [GitLab](/guides/getting-started/create-your-first-template/#gitlab)
* [Bitbucket](/guides/getting-started/create-your-first-template/#bitbucket)
* [Azure DevOps](/guides/getting-started/create-your-first-template/#azure-devops)
* [Other VCS](/guides/getting-started/create-your-first-template/#other-vcs)

## GitHub

<Warning>
  Installing the env zero GitHub App requires **admin access** to your GitHub organization. If you don't have admin rights, ask your GitHub org admin to install it before continuing.
</Warning>

1. After clicking the **GitHub.com** button for the first time, a GitHub popup asks you to install the `env zero` GitHub App on a GitHub organization. Pick the GitHub organization containing your repository.

<Frame caption="Pick GitHub Organization">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/github_organization_selection_popup.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=3f70973f893052628776a0983e5b80cd" alt="GitHub organization selection popup" width="690" height="624" data-path="images/guides/getting-started/github_organization_selection_popup.png" />
</Frame>

2. Pick the repositories you want env zero to have access to and install the GitHub App.

<Frame caption="Pick GitHub Repositories">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/github_repository_selection_interface.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=701054d6040fbb6279ef5296e977e33e" alt="GitHub repository selection interface" width="675" height="811" data-path="images/guides/getting-started/github_repository_selection_interface.png" />
</Frame>

3. The GitHub popup closes.
4. Pick the GitHub repository that contains the code for this template.

<Tip>
  If your repository doesn't appear in the picker, it wasn't included when you installed the GitHub App. Go to your GitHub organization settings, find the env zero App, and click **Configure** to add the repository.
</Tip>

5. Enter a branch or tag in the `Branch` field. Leaving this empty uses your default branch (usually `main` or `master`).
6. Enter the folder your IaC files are in. The field name varies by template type (`Terraform Folder`, `Pulumi Root`, etc.) but works the same way. Leave empty if the files are at the repository root.
7. Click **Next** to continue to [Variables](/guides/getting-started/create-your-first-template/#variables).

<img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/c7586a80eee514f4856d5b8478e5121275dae466a2ae77daef3c1c89d5742a26-image.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=90b3cc82ab0a8cf11070db832b3f30ed" alt="GitHub VCS configuration showing repository picker, Branch field, and Terraform Folder input" width="1403" height="646" data-path="images/guides/getting-started/c7586a80eee514f4856d5b8478e5121275dae466a2ae77daef3c1c89d5742a26-image.png" />

## GitLab

### OAuth

1. After clicking the **GitLab.com** button for the first time, a GitLab popup asks you to authorize the `env zero` application to access your repositories.

<img src="https://mintcdn.com/envzero-b61043c8/L-kR31aFpopGDmR0/images/guides/getting-started/54471f0-screen_shot_2021-01-21_at_18.png?fit=max&auto=format&n=L-kR31aFpopGDmR0&q=85&s=3d96331a895b90dae0c3cf1a531e65f7" alt="GitLab OAuth authorization popup asking to grant the env zero application access to repositories" width="518" height="432" data-path="images/guides/getting-started/54471f0-screen_shot_2021-01-21_at_18.png" />

2. The GitLab popup closes.
3. Pick the GitLab repository that contains the code for this template.
4. Enter a branch or tag in the `Branch` field. Leaving this empty uses your default branch (usually `main` or `master`).
5. Enter the folder your IaC files are in. The field name varies by template type (`Terraform Folder`, `Pulumi Root`, etc.) but works the same way. Leave empty if the files are at the repository root.
6. Click **Next** to continue to [Variables](/guides/getting-started/create-your-first-template/#variables).

### GitLab Access Token

1. After selecting **GitLab.com**, a radio button appears with two options.
2. Click `Access Token` and either select an existing token or create a new one.
   1. Creating a token:
      1. The token can be either a [Personal Access Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) or a [Group Access Token](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html).
      2. The token must have access to each repository you want to use with env zero. Each project's user must have at least Maintainer or Owner permissions.
      3. The token must have the `read_repository` and `api` scopes.
3. Follow the same steps from step 3 in the OAuth section above.

<img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/b8353adf44b95bee031d103cb63f9f7f1562ca2bc3a897a5a816150103e00cba-image.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=7b561c95fe6b4042606a5a9b65e0a16c" alt="GitLab Access Token configuration showing token input and repository selection" width="1402" height="826" data-path="images/guides/getting-started/b8353adf44b95bee031d103cb63f9f7f1562ca2bc3a897a5a816150103e00cba-image.png" />

## Bitbucket

1. After clicking the **Bitbucket.org** button for the first time, a Bitbucket popup asks you to authorize the `env zero` application to access your workspace.

<img src="https://mintcdn.com/envzero-b61043c8/L-kR31aFpopGDmR0/images/guides/getting-started/47a575d-screen_shot_2021-04-08_at_14.png?fit=max&auto=format&n=L-kR31aFpopGDmR0&q=85&s=724ca0cff52e242354114ccb22b20e1c" alt="Bitbucket OAuth authorization popup asking to grant the env zero application access to workspace" width="976" height="1260" data-path="images/guides/getting-started/47a575d-screen_shot_2021-04-08_at_14.png" />

2. The Bitbucket popup closes.
3. Pick the Bitbucket repository that contains the code for this template.
4. Enter a branch or tag in the `Branch` field. Leaving this empty uses your default branch (usually `main` or `master`).
5. Enter the folder your IaC files are in. The field name varies by template type (`Terraform Folder`, `Pulumi Root`, etc.) but works the same way. Leave empty if the files are at the repository root.
6. Click **Next** to continue to [Variables](/guides/getting-started/create-your-first-template/#variables).

## Azure DevOps

1. After clicking the **Azure DevOps** button for the first time, an Azure DevOps popup asks you to authorize the `env zero` application to access your repositories. Grant access for the app.

<img src="https://mintcdn.com/envzero-b61043c8/NFoAIaj_CGEzw-yg/images/guides/admin-guide/templates/be8b39b-ado_access_request.png?fit=max&auto=format&n=NFoAIaj_CGEzw-yg&q=85&s=86b900d735fde22d7a3a0a9d8a4309c7" alt="Azure DevOps OAuth authorization popup asking to grant the env zero application access to repositories" width="966" height="669" data-path="images/guides/admin-guide/templates/be8b39b-ado_access_request.png" />

2. The Azure DevOps popup closes.
3. Pick the Azure DevOps repository that contains the code for this template.
4. Enter a branch in the `Branch` field. Leaving this empty uses your default branch (usually `main` or `master`).
5. Enter the folder your IaC files are in under `<IaC> Folder` (where IaC is the template type you selected). Leave empty if the files are at the repository root.
6. Click **Next** to continue to [Variables](/guides/getting-started/create-your-first-template/#variables).

<Warning>
  **Enable third-party app access in Azure DevOps**

  You must enable `Third-party application access via OAuth` under `Organization Settings > Security > Policies` for any organization you want to manage repositories for.
</Warning>

## Other VCS

1. Enter the URL to your IaC repository under **Repository URL**. The URL can be HTTP/S or SSH.
2. Enter a branch or tag in the `Branch` field. Leaving this empty uses your default branch.
3. Enter the folder your IaC files are in under `Terraform Folder`. Leave empty if the files are at the repository root.
4. If your repository is private, use the `SSH Keys` or `Git Token` dropdown to select the credentials you created in the [Connect Your Git Repository](/guides/getting-started/connect-your-vcs) step.
5. Click **Next** to continue to [Variables](/guides/getting-started/create-your-first-template/#variables).

<img src="https://mintcdn.com/envzero-b61043c8/L-kR31aFpopGDmR0/images/guides/getting-started/4534c4fb57676f845816c6ac4731a8bbbc4de3a0da9223b5a92758135173d427-image.png?fit=max&auto=format&n=L-kR31aFpopGDmR0&q=85&s=29a084572c1a82814c4dd8a5465eefe4" alt="Other VCS configuration showing Repository URL field, Branch field, and SSH Keys dropdown" width="1403" height="736" data-path="images/guides/getting-started/4534c4fb57676f845816c6ac4731a8bbbc4de3a0da9223b5a92758135173d427-image.png" />

## Variables

<Frame caption="Variables step">
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/vcs-environment-variables.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=819fe36f11e2fa459b1aebb4f1a5b656" alt="Variables step showing Terraform Variables table, Environment Variables table, and Variable Set Assignments section, each with an Add Variable button" width="1285" height="1256" data-path="images/guides/getting-started/vcs-environment-variables.png" />
</Frame>

1. Add the [variables](/guides/getting-started/glossary#variable) your template needs at deploy time.

   * **Terraform Variables** are passed to the IaC tool as `-var` flags. Use these for values your code declares as `variable` blocks, such as `region`, `instance_type`, or `environment_name`.
   * **Environment Variables** are set in the shell before the IaC tool runs. Use these for provider authentication, such as `AWS_ACCESS_KEY_ID`, `GOOGLE_CREDENTIALS`, or tool configuration flags.

   See [Variables](/guides/admin-guide/variables) for full scoping rules and inheritance. If your template doesn't require any variables yet, skip this step.

<Warning>
  Mark any variable containing a secret (passwords, API keys, tokens) as **Sensitive** using the lock icon. Sensitive variables are encrypted at rest and redacted from deployment logs. Non-sensitive values appear in plain text in logs and are visible to anyone with access to the environment.
</Warning>

2. Click **Next** to continue to [Projects](/guides/getting-started/create-your-first-template/#projects).

## Projects

1. Pick the projects that you'd like to allow to deploy this template.
2. Click **Done** to create the template.

<img src="https://mintcdn.com/envzero-b61043c8/L-kR31aFpopGDmR0/images/guides/getting-started/732ee4f-screen_shot_2021-01-21_at_18.png?fit=max&auto=format&n=L-kR31aFpopGDmR0&q=85&s=07dbaf2ef38ae29d977edaa131696ba3" alt="Template Projects step showing project checkboxes for associating the template" width="1423" height="405" data-path="images/guides/getting-started/732ee4f-screen_shot_2021-01-21_at_18.png" />

## Add your template to a project

To run the template, add it to one of the organization's projects. Your new organization already has a Default Project.

1. Go to the **Default Organization Project**.

2. Click **Project Templates** in the left menu.

<Frame>
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/project_templates_page_navigation.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=ed5837fbfcc47fd048e56d3f74c3215f" alt="Project templates page navigation" width="2240" height="1184" data-path="images/guides/getting-started/project_templates_page_navigation.png" />
</Frame>

3. Click **Manage Templates** and check the checkbox next to the template you created.

<Frame>
  <img src="https://mintcdn.com/envzero-b61043c8/lGlzrnZWRsIiLt0l/images/guides/getting-started/ff2459c-project_template_2_fix.png?fit=max&auto=format&n=lGlzrnZWRsIiLt0l&q=85&s=b3004445d3fbccbcfc22a3693d491199" alt="Project template management interface showing template checkbox selection" width="470" height="572" data-path="images/guides/getting-started/ff2459c-project_template_2_fix.png" />
</Frame>

4. Click **Save**.

## Next steps

* [Deploy Your First Environment](/guides/getting-started/running-your-first-environment) - Deploy your first environment from the template you created.
* [Using env zero Templates](/guides/admin-guide/env-zero-templates) - Learn advanced template settings, versioning, and variable control.
* [Approval Policies](/guides/policies-governance/approval-policies) - Require a plan review before any apply runs on this template.
* [Custom Flows](/guides/admin-guide/custom-flows) - Add pre- and post-deploy scripts to your template.
