From d178e565f306ba3f9637342b453a80e1178b1164 Mon Sep 17 00:00:00 2001 From: Tomer Heber Date: Fri, 20 May 2022 05:51:30 -0500 Subject: [PATCH] Feat: support resolving terraform version from code for template resource (#388) --- env0/resource_template.go | 4 ++-- tests/integration/004_template/main.tf | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/env0/resource_template.go b/env0/resource_template.go index b6ecae87..d145fb7a 100644 --- a/env0/resource_template.go +++ b/env0/resource_template.go @@ -151,9 +151,9 @@ func resourceTemplate() *schema.Resource { }, "terraform_version": { Type: schema.TypeString, - Description: "the Terraform version to use (example: 0.15.1)", + Description: "the Terraform version to use (example: 0.15.1). Setting to `RESOLVE_FROM_TERRAFORM_CODE` defaults to the version of `terraform.required_version` during run-time (resolve from terraform code).", Optional: true, - ValidateDiagFunc: NewRegexValidator(`^[0-9]\.[0-9]{1,2}\.[0-9]{1,2}$`), + ValidateDiagFunc: NewRegexValidator(`^(?:[0-9]\.[0-9]{1,2}\.[0-9]{1,2})|RESOLVE_FROM_TERRAFORM_CODE$`), Default: "0.15.1", }, "terragrunt_version": { diff --git a/tests/integration/004_template/main.tf b/tests/integration/004_template/main.tf index 6fec1de9..0f084c3e 100644 --- a/tests/integration/004_template/main.tf +++ b/tests/integration/004_template/main.tf @@ -31,6 +31,19 @@ resource "env0_template" "github_template" { terraform_version = "0.15.1" } +resource "env0_template" "github_template_resolve" { + name = "Github Test Resolve-${random_string.random.result}" + description = "Template description - GitHub" + type = "terraform" + repository = data.env0_template.github_template.repository + github_installation_id = data.env0_template.github_template.github_installation_id + path = "misc/null-resource" + retries_on_deploy = 3 + retry_on_deploy_only_when_matches_regex = "abc" + retries_on_destroy = 1 + terraform_version = "RESOLVE_FROM_TERRAFORM_CODE" +} + #resource "env0_template" "gitlab_template" { # name = "gitlab test-${random_string.random.result}" # description = "template description - gitlab"