Remote Apply

Remote Backend allows applying your Terraform locally by triggering a remote apply in env0.
The remote apply uses your local Terraform files but actually runs it remotely in env0 while using the shared state and variables set for the env0 environment. Each remote apply creates a deployment in env0 so you will have an audit for each deployment.
By running a remote apply you can build your IaC faster, and test your changes locally before committing them.

Additional benefits are the rest of the env0 features that are automatically integrated into your plan logs. It includes:

🚧

Warning

Remote apply is not recommended for production environments as it lets you apply local code that is not VCS controlled, which can cause a drift in your infrastructure. Use this feature with caution.

Before You Start

There are some prerequisites you need to be aware of before starting to use remote apply.

Permissions

To enable Remote Apply within an environment, you must have the "Allow Edit Remote Apply" permission. As an admin, you can create a custom role with this permission, or use the Admin role, which have it enabled by default.

Opting In for Remote Apply

Within your environment's settings, navigate to General Settings > Remote State to find the Allow Remote Apply option.

To activate this feature, your environment must meet certain prerequisites:

  1. The Remote Backend must be enabled.
  2. Approve plan automatically must be enabled.
  3. There are no approval policies configured on this project.

Usage

  1. First, you have to have your Terraform configuration defined with the cloud block.
terraform {
  cloud {
    hostname     = "backend.api.env0.com"
    organization = "<org-id>.<project-id>"
    workspaces {
      name = "my-first-remote-apply"
    }
  }
}

πŸ“˜

Cloud Configuration Support

Terraform's cloud block is only available from version 1.1.0. To use remote apply, you have to use the cloud block configuration, and not the old remote "backend" configuration.

  1. To login, follow this guide
  2. Next, run
terraform init
terraform apply -auto-approve

🚧

-auto-approve flag

the -auto-approve flag is mandatory to execute remote apply on env0.

A remote apply will start an logs will start appearing on the terminal.

πŸ‘

Tip

You can see the deployment in env0 by clicking the yellow link.