diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ef90900..99f74dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `data.scalr_environments`: changed type of `ids` attribute from TypeList to TypeSet ([373](https://github.com/Scalr/terraform-provider-scalr/pull/373)) +- `scalr_workspace` and `data.scalr_workspace`: new attributes `terragrunt_version` and `terragrunt_use_run_all` ([#378](https://github.com/Scalr/terraform-provider-scalr/pull/378)) +- `scalr_environment` and `data.scalr_environment`: new attribute `remote_backend` ([#378](https://github.com/Scalr/terraform-provider-scalr/pull/378)) + ## [2.2.0] - 2024-11-22 ### Added diff --git a/docs/data-sources/environment.md b/docs/data-sources/environment.md index cac0664a..bee3a877 100644 --- a/docs/data-sources/environment.md +++ b/docs/data-sources/environment.md @@ -39,6 +39,7 @@ data "scalr_environment" "example2" { - `created_by` (List of Object) Details of the user that created the environment. (see [below for nested schema](#nestedatt--created_by)) - `default_provider_configurations` (List of String) List of IDs of provider configurations, used in the environment workspaces by default. - `policy_groups` (List of String) List of the environment policy-groups IDs, in the format `pgrp-`. +- `remote_backend` (Boolean) If Scalr exports the remote backend configuration and state storage for your infrastructure management. Disabling this feature will also prevent the ability to perform state locking, which ensures that concurrent operations do not conflict. Additionally, it will disable the capability to initiate CLI-driven runs through Scalr. - `status` (String) The status of an environment. - `tag_ids` (List of String) List of tag IDs associated with the environment. diff --git a/docs/data-sources/workspace.md b/docs/data-sources/workspace.md index c3aafc57..2d88202f 100644 --- a/docs/data-sources/workspace.md +++ b/docs/data-sources/workspace.md @@ -61,6 +61,8 @@ data "scalr_workspace" "example2" { - `vcs_provider_id` (String) The identifier of a VCS provider in the format `vcs-`. - `vcs_repo` (List of Object) If a workspace is linked to a VCS repository this block shows the details, otherwise `{}` (see [below for nested schema](#nestedatt--vcs_repo)) - `working_directory` (String) A relative path that Terraform will execute within. +- `terragrunt_version` (String) The version of Terragrunt the workspace performs runs on. +- `terragrunt_use_run_all` (Boolean) Indicates whether the workspace uses `terragrunt run-all`. ### Nested Schema for `created_by` diff --git a/docs/resources/environment.md b/docs/resources/environment.md index d70b1c07..5235ed1b 100644 --- a/docs/resources/environment.md +++ b/docs/resources/environment.md @@ -35,6 +35,7 @@ resource "scalr_environment" "test" { - `cost_estimation_enabled` (Boolean, Deprecated) Set (true/false) to enable/disable cost estimation for the environment. - `default_provider_configurations` (Set of String) List of IDs of provider configurations, used in the environment workspaces by default. - `policy_groups` (List of String, Deprecated) List of the environment policy-groups IDs, in the format `pgrp-`. +- `remote_backend` (Boolean) If Scalr exports the remote backend configuration and state storage for your infrastructure management. Disabling this feature will also prevent the ability to perform state locking, which ensures that concurrent operations do not conflict. Additionally, it will disable the capability to initiate CLI-driven runs through Scalr. - `tag_ids` (Set of String) List of tag IDs associated with the environment. ### Read-Only diff --git a/docs/resources/workspace.md b/docs/resources/workspace.md index a8d7af6a..2f77a9ed 100644 --- a/docs/resources/workspace.md +++ b/docs/resources/workspace.md @@ -167,6 +167,8 @@ resource "scalr_workspace" "example-b" { - `ssh_key_id` (String) The identifier of the SSH key to use for the workspace. - `tag_ids` (Set of String) List of tag IDs associated with the workspace. - `terraform_version` (String) The version of Terraform to use for this workspace. Defaults to the latest available version. +- `terragrunt_use_run_all` (Boolean) Indicates whether the workspace uses `terragrunt run-all`. +- `terragrunt_version` (String) The version of Terragrunt the workspace performs runs on. - `type` (String) The type of the Scalr Workspace environment, available options: `production`, `staging`, `testing`, `development`, `unmapped`. - `var_files` (List of String) A list of paths to the `.tfvars` file(s) to be used as part of the workspace configuration. - `vcs_provider_id` (String) ID of VCS provider - required if vcs-repo present and vice versa, in the format `vcs-`. diff --git a/go.mod b/go.mod index 70eb3bfe..988242e3 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0 github.com/hashicorp/terraform-plugin-testing v1.11.0 github.com/hashicorp/terraform-svchost v0.1.1 - github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e + github.com/scalr/go-scalr v0.0.0-20241217115214-520118b5f6e3 ) require ( diff --git a/go.sum b/go.sum index a222cf50..c33808d3 100644 --- a/go.sum +++ b/go.sum @@ -201,8 +201,8 @@ github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBO github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e h1:dRpwrWotOKjMEmUJQEavyoM/20QTXshBeY7bAmg+84s= -github.com/scalr/go-scalr v0.0.0-20241111151759-2c33e05ca45e/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE= +github.com/scalr/go-scalr v0.0.0-20241217115214-520118b5f6e3 h1:S1NUPU0JSImn29HJfPRaRxQLPSR4G8HwWi6tl99bgbo= +github.com/scalr/go-scalr v0.0.0-20241217115214-520118b5f6e3/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= diff --git a/internal/provider/data_source_scalr_environment.go b/internal/provider/data_source_scalr_environment.go index c69719be..35e27846 100644 --- a/internal/provider/data_source_scalr_environment.go +++ b/internal/provider/data_source_scalr_environment.go @@ -90,6 +90,11 @@ func dataSourceScalrEnvironment() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + "remote_backend": { + Description: "If Scalr exports the remote backend configuration and state storage for your infrastructure management. Disabling this feature will also prevent the ability to perform state locking, which ensures that concurrent operations do not conflict. Additionally, it will disable the capability to initiate CLI-driven runs through Scalr.", + Type: schema.TypeBool, + Computed: true, + }, }} } @@ -131,6 +136,7 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta _ = d.Set("name", environment.Name) _ = d.Set("cost_estimation_enabled", environment.CostEstimationEnabled) _ = d.Set("status", environment.Status) + _ = d.Set("remote_backend", environment.RemoteBackend) var createdBy []interface{} if environment.CreatedBy != nil { diff --git a/internal/provider/data_source_scalr_workspace.go b/internal/provider/data_source_scalr_workspace.go index 3866ca0d..6018b6c2 100644 --- a/internal/provider/data_source_scalr_workspace.go +++ b/internal/provider/data_source_scalr_workspace.go @@ -94,7 +94,16 @@ func dataSourceScalrWorkspace() *schema.Resource { Type: schema.TypeString, Computed: true, }, - + "terragrunt_version": { + Description: "The version of Terragrunt the workspace performs runs on.", + Type: schema.TypeString, + Computed: true, + }, + "terragrunt_use_run_all": { + Description: "Indicates whether the workspace uses `terragrunt run-all`.", + Type: schema.TypeBool, + Computed: true, + }, "iac_platform": { Description: "The IaC platform used for this workspace.", Type: schema.TypeString, @@ -275,6 +284,8 @@ func dataSourceScalrWorkspaceRead(ctx context.Context, d *schema.ResourceData, m _ = d.Set("operations", workspace.Operations) _ = d.Set("execution_mode", workspace.ExecutionMode) _ = d.Set("terraform_version", workspace.TerraformVersion) + _ = d.Set("terragrunt_version", workspace.TerragruntVersion) + _ = d.Set("terragrunt_use_run_all", workspace.TerragruntUseRunAll) _ = d.Set("iac_platform", workspace.IaCPlatform) _ = d.Set("type", workspace.EnvironmentType) _ = d.Set("working_directory", workspace.WorkingDirectory) diff --git a/internal/provider/resource_scalr_environment.go b/internal/provider/resource_scalr_environment.go index cb1350c4..fb7751fe 100644 --- a/internal/provider/resource_scalr_environment.go +++ b/internal/provider/resource_scalr_environment.go @@ -96,6 +96,13 @@ func resourceScalrEnvironment() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, + "remote_backend": { + Description: "If Scalr exports the remote backend configuration and state storage for your infrastructure management. Disabling this feature will also prevent the ability to perform state locking, which ensures that concurrent operations do not conflict. Additionally, it will disable the capability to initiate CLI-driven runs through Scalr.", + Type: schema.TypeBool, + Optional: true, + Computed: true, + ForceNew: true, + }, }, } } @@ -134,6 +141,10 @@ func resourceScalrEnvironmentCreate(ctx context.Context, d *schema.ResourceData, if costEstimationEnabled, ok := d.GetOkExists("cost_estimation_enabled"); ok { //nolint:staticcheck options.CostEstimationEnabled = ptr(costEstimationEnabled.(bool)) } + if remoteBackend, ok := d.GetOkExists("remote_backend"); ok { //nolint:staticcheck + options.RemoteBackend = ptr(remoteBackend.(bool)) + } + if defaultProviderConfigurationsI, ok := d.GetOk("default_provider_configurations"); ok { defaultProviderConfigurations := defaultProviderConfigurationsI.(*schema.Set).List() pcfgValues := make([]*scalr.ProviderConfiguration, 0) @@ -183,6 +194,7 @@ func resourceScalrEnvironmentRead(ctx context.Context, d *schema.ResourceData, m _ = d.Set("name", environment.Name) _ = d.Set("account_id", environment.Account.ID) _ = d.Set("cost_estimation_enabled", environment.CostEstimationEnabled) + _ = d.Set("remote_backend", environment.RemoteBackend) _ = d.Set("status", environment.Status) defaultProviderConfigurations := make([]string, 0) diff --git a/internal/provider/resource_scalr_environment_test.go b/internal/provider/resource_scalr_environment_test.go index 962db8bf..452863ac 100644 --- a/internal/provider/resource_scalr_environment_test.go +++ b/internal/provider/resource_scalr_environment_test.go @@ -25,6 +25,7 @@ func TestAccEnvironment_basic(t *testing.T) { testAccCheckScalrEnvironmentAttributes(environment, rInt), resource.TestCheckResourceAttr("scalr_environment.test", "name", fmt.Sprintf("test-env-%d", rInt)), resource.TestCheckResourceAttr("scalr_environment.test", "cost_estimation_enabled", "true"), + resource.TestCheckResourceAttr("scalr_environment.test", "remote_backend", "false"), resource.TestCheckResourceAttr("scalr_environment.test", "status", "Active"), resource.TestCheckResourceAttr("scalr_environment.test", "account_id", defaultAccount), resource.TestCheckResourceAttr("scalr_environment.test", "policy_groups.%", "0"), @@ -233,6 +234,7 @@ resource "scalr_environment" "test" { name = "test-env-%d" account_id = "%s" cost_estimation_enabled = true + remote_backend = false }`, rInt, defaultAccount) } diff --git a/internal/provider/resource_scalr_workspace.go b/internal/provider/resource_scalr_workspace.go index 3e5cf486..546ebf0e 100644 --- a/internal/provider/resource_scalr_workspace.go +++ b/internal/provider/resource_scalr_workspace.go @@ -142,6 +142,18 @@ func resourceScalrWorkspace() *schema.Resource { Optional: true, Computed: true, }, + "terragrunt_version": { + Description: "The version of Terragrunt the workspace performs runs on.", + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "terragrunt_use_run_all": { + Description: "Indicates whether the workspace uses `terragrunt run-all`.", + Type: schema.TypeBool, + Optional: true, + Computed: true, + }, "iac_platform": { Description: "The IaC platform to use for this workspace. Valid values are `terraform` and `opentofu`. Defaults to `terraform`.", @@ -412,6 +424,12 @@ func resourceScalrWorkspaceCreate(ctx context.Context, d *schema.ResourceData, m if operations, ok := d.GetOk("operations"); ok { options.Operations = ptr(operations.(bool)) } + if terragruntVersion, ok := d.GetOk("terragrunt_version"); ok { + options.TerragruntVersion = ptr(terragruntVersion.(string)) + } + if terragruntUseRunAll, ok := d.GetOk("terragrunt_use_run_all"); ok { + options.TerragruntUseRunAll = ptr(terragruntUseRunAll.(bool)) + } if executionMode, ok := d.GetOk("execution_mode"); ok { options.ExecutionMode = ptr( @@ -585,6 +603,8 @@ func resourceScalrWorkspaceRead(ctx context.Context, d *schema.ResourceData, met _ = d.Set("auto_queue_runs", workspace.AutoQueueRuns) _ = d.Set("type", workspace.EnvironmentType) _ = d.Set("var_files", workspace.VarFiles) + _ = d.Set("terragrunt_version", workspace.TerragruntVersion) + _ = d.Set("terragrunt_use_run_all", workspace.TerragruntUseRunAll) if workspace.RunOperationTimeout != nil { _ = d.Set("run_operation_timeout", &workspace.RunOperationTimeout) @@ -689,7 +709,7 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m d.HasChange("vcs_provider_id") || d.HasChange("agent_pool_id") || d.HasChange("deletion_protection_enabled") || d.HasChange("hooks") || d.HasChange("module_version_id") || d.HasChange("var_files") || d.HasChange("run_operation_timeout") || d.HasChange("iac_platform") || - d.HasChange("type") { + d.HasChange("type") || d.HasChange("terragrunt_version") || d.HasChange("terragrunt_use_run_all") { // Create a new options struct. options := scalr.WorkspaceUpdateOptions{ Name: ptr(d.Get("name").(string)), @@ -715,6 +735,12 @@ func resourceScalrWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, m scalr.WorkspaceExecutionMode(executionMode.(string)), ) } + if terragruntVersion, ok := d.GetOk("terragrunt_version"); ok { + options.TerragruntVersion = ptr(terragruntVersion.(string)) + } + if terragruntUseRunAll, ok := d.GetOkExists("terragrunt_use_run_all"); ok { //nolint:staticcheck + options.TerragruntUseRunAll = ptr(terragruntUseRunAll.(bool)) + } if autoQueueRunsI, ok := d.GetOk("auto_queue_runs"); ok { options.AutoQueueRuns = ptr( diff --git a/templates/data-sources/workspace.md.tmpl b/templates/data-sources/workspace.md.tmpl index 91860237..7f24dd17 100644 --- a/templates/data-sources/workspace.md.tmpl +++ b/templates/data-sources/workspace.md.tmpl @@ -52,6 +52,8 @@ hidden: false - `vcs_provider_id` (String) The identifier of a VCS provider in the format `vcs-`. - `vcs_repo` (List of Object) If a workspace is linked to a VCS repository this block shows the details, otherwise `{}` (see [below for nested schema](#nestedatt--vcs_repo)) - `working_directory` (String) A relative path that Terraform will execute within. +- `terragrunt_version` (String) The version of Terragrunt the workspace performs runs on. +- `terragrunt_use_run_all` (Boolean) Indicates whether the workspace uses `terragrunt run-all`. ### Nested Schema for `created_by`