Skip to content

Commit

Permalink
SCALRCORE-28030 merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanMytsko committed Oct 5, 2023
2 parents 5c58c33 + e3797d4 commit 45d67b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `scalr_provider_configuration`: Fixed error message if aws credentials type is wrong. ([#275](https://github.com/Scalr/terraform-provider-scalr/pull/275))
- `data.scalr_provider_configuration`: Added new attribute `environments` ([#285](https://github.com/Scalr/terraform-provider-scalr/pull/280/files))
- `data.scalr_provider_configuration`: Fixed `provider-name` attribute ([#285](https://github.com/Scalr/terraform-provider-scalr/pull/280/files))
- `data.scalr_enviroment`: Added new attribute `default_provider_configurations` ([#279](https://github.com/Scalr/terraform-provider-scalr/pull/279))

### Added

Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ data "scalr_environment" "example2" {

- `cost_estimation_enabled` (Boolean) Boolean indicates if cost estimation is enabled for the environment.
- `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-<RANDOM STRING>`.
- `status` (String) The status of an environment.
- `tag_ids` (List of String) List of tag IDs associated with the environment.
Expand Down
15 changes: 15 additions & 0 deletions scalr/data_source_scalr_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func dataSourceScalrEnvironment() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"default_provider_configurations": {
Description: "List of IDs of provider configurations, used in the environment workspaces by default.",
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
}}
}

Expand Down Expand Up @@ -142,6 +148,15 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta
}
_ = d.Set("policy_groups", policyGroups)

defaultProviderConfigurations := make([]string, 0)
if environment.DefaultProviderConfigurations != nil {
for _, provider := range environment.DefaultProviderConfigurations {
defaultProviderConfigurations = append(defaultProviderConfigurations, provider.ID)
}
}

_ = d.Set("default_provider_configurations", defaultProviderConfigurations)

var tags []string
if len(environment.Tags) != 0 {
for _, tag := range environment.Tags {
Expand Down
1 change: 1 addition & 0 deletions scalr/data_source_scalr_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func TestAccEnvironmentDataSource_basic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.full_name"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.email"),
resource.TestCheckResourceAttrSet("data.scalr_environment.test", "created_by.0.username"),
resource.TestCheckResourceAttr("data.scalr_environment.test", "default_provider_configurations.#", "0"),
),
},
{
Expand Down

0 comments on commit 45d67b5

Please sign in to comment.