From 76d1e3c8e43b4e5922d7b3879085727636c16815 Mon Sep 17 00:00:00 2001 From: jordanst3wart Date: Tue, 3 Sep 2024 23:22:35 +1000 Subject: [PATCH 1/6] feature: [New Data Source]: AWS Organizations descendant OUs (issue #30992) --- ...scendant_organization_units_data_source.go | 96 +++++++++++++++++++ ...ant_organization_units_data_source_test.go | 73 ++++++++++++++ .../organizations/organizations_test.go | 1 + .../organizations/service_package_gen.go | 5 + ...escendant_organization_units.html.markdown | 35 +++++++ 5 files changed, 210 insertions(+) create mode 100644 internal/service/organizations/organizational_units_descendant_organization_units_data_source.go create mode 100644 internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go create mode 100644 website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown diff --git a/internal/service/organizations/organizational_units_descendant_organization_units_data_source.go b/internal/service/organizations/organizational_units_descendant_organization_units_data_source.go new file mode 100644 index 00000000000..5d2b21dcd77 --- /dev/null +++ b/internal/service/organizations/organizational_units_descendant_organization_units_data_source.go @@ -0,0 +1,96 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package organizations + +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/organizations" + awstypes "github.com/aws/aws-sdk-go-v2/service/organizations/types" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" +) + +// @SDKDataSource("aws_organizations_organizational_unit_descendant_organization_units", name="Organizational Unit Descendant Organization Units") +func dataSourceOrganizationalUnitDescendantOrganizationUnits() *schema.Resource { + return &schema.Resource{ + ReadWithoutTimeout: dataSourceOrganizationalUnitDescendantOrganizationUnitsRead, + + Schema: map[string]*schema.Schema{ + "children": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, + "parent_id": { + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func dataSourceOrganizationalUnitDescendantOrganizationUnitsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + var diags diag.Diagnostics + conn := meta.(*conns.AWSClient).OrganizationsClient(ctx) + + parentID := d.Get("parent_id").(string) + organizationUnits, err := findAllOrganizationUnitsForParentAndBelow(ctx, conn, parentID) + + if err != nil { + return sdkdiag.AppendErrorf(diags, "listing Organizations Units for parent (%s) and descendants: %s", parentID, err) + } + + d.SetId(parentID) + + if err := d.Set("accounts", flattenOrganizationalUnits(organizationUnits)); err != nil { + return sdkdiag.AppendErrorf(diags, "setting organization units: %s", err) + } + + return diags +} + +// findAllOrganizationUnitsForParentAndBelow recurses down an OU tree, returning all organization units at the specified parent and below. +func findAllOrganizationUnitsForParentAndBelow(ctx context.Context, conn *organizations.Client, id string) ([]awstypes.OrganizationalUnit, error) { + var output []awstypes.OrganizationalUnit + + ous, err := findOrganizationalUnitsForParentByID(ctx, conn, id) + + if err != nil { + return nil, err + } + + output = append(output, ous...) + + for _, ou := range ous { + organizationUnits, err := findAllOrganizationUnitsForParentAndBelow(ctx, conn, aws.ToString(ou.Id)) + + if err != nil { + return nil, err + } + + output = append(output, organizationUnits...) + } + + return output, nil +} diff --git a/internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go b/internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go new file mode 100644 index 00000000000..e9459886989 --- /dev/null +++ b/internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go @@ -0,0 +1,73 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package organizations_test + +import ( + "fmt" + "testing" + + sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-provider-aws/internal/acctest" + "github.com/hashicorp/terraform-provider-aws/names" +) + +func testOrganizationalUnitDescendantOusDataSource_basic(t *testing.T) { + ctx := acctest.Context(t) + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + topOUDataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.current" + newOU1DataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.test0" + newOU2DataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.test1" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + acctest.PreCheck(ctx, t) + acctest.PreCheckOrganizationManagementAccount(ctx, t) + }, + ErrorCheck: acctest.ErrorCheck(t, names.OrganizationsServiceID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testOrganizationalUnitDescendantOusDataSourceConfig_basic(rName), + Check: resource.ComposeTestCheckFunc( + acctest.CheckResourceAttrGreaterThanValue(topOUDataSourceName, "children.#", 0), + resource.TestCheckResourceAttr(newOU1DataSourceName, "children.#", acctest.Ct0), + resource.TestCheckResourceAttr(newOU2DataSourceName, "children.#", acctest.Ct0), + ), + }, + }, + }) +} + +func testOrganizationalUnitDescendantOusDataSourceConfig_basic(rName string) string { + return fmt.Sprintf(` +data "aws_organizations_organization" "current" {} + +resource "aws_organizations_organizational_unit" "test0" { + name = "%[1]s-0" + parent_id = data.aws_organizations_organization.current.roots[0].id +} + +resource "aws_organizations_organizational_unit" "test1" { + name = "%[1]s-1" + parent_id = aws_organizations_organizational_unit.test0.id +} + +data "aws_organizations_organizational_unit_descendant_organization_units" "current" { + parent_id = data.aws_organizations_organization.current.roots[0].id + + depends_on = [aws_organizations_organizational_unit.test0, aws_organizations_organizational_unit.test1] +} + +data "aws_organizations_organizational_unit_descendant_organization_units" "test0" { + parent_id = aws_organizations_organizational_unit.test0.id + + depends_on = [aws_organizations_organizational_unit.test1] +} + +data "aws_organizations_organizational_unit_descendant_organization_units" "test1" { + parent_id = aws_organizations_organizational_unit.test1.id +} +`, rName) +} diff --git a/internal/service/organizations/organizations_test.go b/internal/service/organizations/organizations_test.go index 9f260ffdff7..56bc7e93c60 100644 --- a/internal/service/organizations/organizations_test.go +++ b/internal/service/organizations/organizations_test.go @@ -50,6 +50,7 @@ func TestAccOrganizations_serial(t *testing.T) { "update": testAccOrganizationalUnit_update, "tags": testAccOrganizationalUnit_tags, "DataSource_basic": testAccOrganizationalUnitDataSource_basic, + "DescendantOusDataSource_basic": testOrganizationalUnitDescendantOusDataSource_basic, "ChildAccountsDataSource_basic": testAccOrganizationalUnitChildAccountsDataSource_basic, "DescendantAccountsDataSource_basic": testAccOrganizationalUnitDescendantAccountsDataSource_basic, "PluralDataSource_basic": testAccOrganizationalUnitsDataSource_basic, diff --git a/internal/service/organizations/service_package_gen.go b/internal/service/organizations/service_package_gen.go index 5aba3d9eedf..90655350497 100644 --- a/internal/service/organizations/service_package_gen.go +++ b/internal/service/organizations/service_package_gen.go @@ -57,6 +57,11 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac TypeName: "aws_organizations_organizational_units", Name: "Organizational Unit", }, + { + Factory: dataSourceOrganizationalUnitDescendantOrganizationUnits, + TypeName: "aws_organizations_organizational_unit_descendant_organization_units", + Name: "Organizational Unit Descendant Organization Units", + }, { Factory: dataSourcePolicies, TypeName: "aws_organizations_policies", diff --git a/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown b/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown new file mode 100644 index 00000000000..8f7c9e4dc37 --- /dev/null +++ b/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown @@ -0,0 +1,35 @@ +--- +subcategory: "Organizations" +layout: "aws" +page_title: "AWS: aws_organizations_organizational_unit_descendant_accounts" +description: |- + Get all child accounts under a parent organizational unit. This provides all children. +--- + +# Data Source: aws_organizations_organizational_unit_descendant_organization_units + +Get all direct child organizational units under a parent organizational unit. This provides all children. + +## Example Usage + +```terraform +data "aws_organizations_organization" "org" {} + +data "aws_organizations_organizational_unit_descendant_organization_units" "ous" { + parent_id = data.aws_organizations_organization.org.roots[0].id +} +``` + +## Argument Reference + +* `parent_id` - (Required) Parent ID of the organizational unit. + +## Attribute Reference + +This data source exports the following attributes in addition to the arguments above: + +* `children` - List of child organizational units, which have the following attributes: + * `arn` - ARN of the organizational unit + * `name` - Name of the organizational unit + * `id` - ID of the organizational unit +* `id` - Parent identifier of the organizational units. From 1a3cde724abeb823f251f7deafc99de2398023be Mon Sep 17 00:00:00 2001 From: jordanst3wart Date: Tue, 3 Sep 2024 23:44:05 +1000 Subject: [PATCH 2/6] fix documentation for aws_organizations_organizational_unit_descendant_organization_units --- ...izational_unit_descendant_organization_units.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown b/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown index 8f7c9e4dc37..6d6fe9110d0 100644 --- a/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown +++ b/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown @@ -1,9 +1,9 @@ --- subcategory: "Organizations" layout: "aws" -page_title: "AWS: aws_organizations_organizational_unit_descendant_accounts" +page_title: "AWS: aws_organizations_organizational_unit_descendant_organization_units" description: |- - Get all child accounts under a parent organizational unit. This provides all children. + Get all direct child organizational units under a parent organizational unit. This provides all children. --- # Data Source: aws_organizations_organizational_unit_descendant_organization_units From 8939a217c21532f3ddcfa35b3d4268fd867a29b6 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 3 Sep 2024 11:13:02 -0400 Subject: [PATCH 3/6] Add CHANGELOG entry. --- .changelog/39120.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/39120.txt diff --git a/.changelog/39120.txt b/.changelog/39120.txt new file mode 100644 index 00000000000..66f7cb71706 --- /dev/null +++ b/.changelog/39120.txt @@ -0,0 +1,3 @@ +```release-note:new-data-source +aws_organizations_organizational_unit_descendant_organization_units +``` \ No newline at end of file From f46594cead917a79d9c5cb428b41c653c1df50cf Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 3 Sep 2024 11:19:32 -0400 Subject: [PATCH 4/6] 'aws_organizations_organizational_unit_descendant_organization_units' -> 'aws_organizations_organizational_unit_descendant_organizational_units'. --- .changelog/39120.txt | 2 +- .../organizational_units_data_source.go | 2 +- ...ndant_organizational_units_data_source.go} | 22 +++++++++---------- ..._organizational_units_data_source_test.go} | 12 +++++----- .../organizations/service_package_gen.go | 10 ++++----- ...endant_organizational_units.html.markdown} | 6 ++--- 6 files changed, 27 insertions(+), 27 deletions(-) rename internal/service/organizations/{organizational_units_descendant_organization_units_data_source.go => organizational_units_descendant_organizational_units_data_source.go} (62%) rename internal/service/organizations/{organizational_units_descendant_organization_units_data_source_test.go => organizational_units_descendant_organizational_units_data_source_test.go} (92%) rename website/docs/d/{organizations_organizational_unit_descendant_organization_units.html.markdown => organizations_organizational_unit_descendant_organizational_units.html.markdown} (94%) diff --git a/.changelog/39120.txt b/.changelog/39120.txt index 66f7cb71706..84271c54ed6 100644 --- a/.changelog/39120.txt +++ b/.changelog/39120.txt @@ -1,3 +1,3 @@ ```release-note:new-data-source -aws_organizations_organizational_unit_descendant_organization_units +aws_organizations_organizational_unit_descendant_organizational_units ``` \ No newline at end of file diff --git a/internal/service/organizations/organizational_units_data_source.go b/internal/service/organizations/organizational_units_data_source.go index 0ce4ca170b1..e922fa2720a 100644 --- a/internal/service/organizations/organizational_units_data_source.go +++ b/internal/service/organizations/organizational_units_data_source.go @@ -62,7 +62,7 @@ func dataSourceOrganizationalUnitsRead(ctx context.Context, d *schema.ResourceDa children, err := findOrganizationalUnitsForParentByID(ctx, conn, parentID) if err != nil { - return sdkdiag.AppendErrorf(diags, "listing Organizations Organization Units for parent (%s): %s", parentID, err) + return sdkdiag.AppendErrorf(diags, "listing Organizations Organizational Units for parent (%s): %s", parentID, err) } d.SetId(parentID) diff --git a/internal/service/organizations/organizational_units_descendant_organization_units_data_source.go b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source.go similarity index 62% rename from internal/service/organizations/organizational_units_descendant_organization_units_data_source.go rename to internal/service/organizations/organizational_units_descendant_organizational_units_data_source.go index 5d2b21dcd77..a9940f31655 100644 --- a/internal/service/organizations/organizational_units_descendant_organization_units_data_source.go +++ b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source.go @@ -16,10 +16,10 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKDataSource("aws_organizations_organizational_unit_descendant_organization_units", name="Organizational Unit Descendant Organization Units") -func dataSourceOrganizationalUnitDescendantOrganizationUnits() *schema.Resource { +// @SDKDataSource("aws_organizations_organizational_unit_descendant_organizational_units", name="Organizational Unit Descendant Organization Units") +func dataSourceOrganizationalUnitDescendantOrganizationalUnits() *schema.Resource { return &schema.Resource{ - ReadWithoutTimeout: dataSourceOrganizationalUnitDescendantOrganizationUnitsRead, + ReadWithoutTimeout: dataSourceOrganizationalUnitDescendantOrganizationalUnitsRead, Schema: map[string]*schema.Schema{ "children": { @@ -50,28 +50,28 @@ func dataSourceOrganizationalUnitDescendantOrganizationUnits() *schema.Resource } } -func dataSourceOrganizationalUnitDescendantOrganizationUnitsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func dataSourceOrganizationalUnitDescendantOrganizationalUnitsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).OrganizationsClient(ctx) parentID := d.Get("parent_id").(string) - organizationUnits, err := findAllOrganizationUnitsForParentAndBelow(ctx, conn, parentID) + organizationUnits, err := findAllOrganizationalUnitsForParentAndBelow(ctx, conn, parentID) if err != nil { - return sdkdiag.AppendErrorf(diags, "listing Organizations Units for parent (%s) and descendants: %s", parentID, err) + return sdkdiag.AppendErrorf(diags, "listing Organizations Organizational Units for parent (%s) and descendants: %s", parentID, err) } d.SetId(parentID) - if err := d.Set("accounts", flattenOrganizationalUnits(organizationUnits)); err != nil { - return sdkdiag.AppendErrorf(diags, "setting organization units: %s", err) + if err := d.Set("children", flattenOrganizationalUnits(organizationUnits)); err != nil { + return sdkdiag.AppendErrorf(diags, "setting children: %s", err) } return diags } -// findAllOrganizationUnitsForParentAndBelow recurses down an OU tree, returning all organization units at the specified parent and below. -func findAllOrganizationUnitsForParentAndBelow(ctx context.Context, conn *organizations.Client, id string) ([]awstypes.OrganizationalUnit, error) { +// findAllOrganizationalUnitsForParentAndBelow recurses down an OU tree, returning all organizational units at the specified parent and below. +func findAllOrganizationalUnitsForParentAndBelow(ctx context.Context, conn *organizations.Client, id string) ([]awstypes.OrganizationalUnit, error) { var output []awstypes.OrganizationalUnit ous, err := findOrganizationalUnitsForParentByID(ctx, conn, id) @@ -83,7 +83,7 @@ func findAllOrganizationUnitsForParentAndBelow(ctx context.Context, conn *organi output = append(output, ous...) for _, ou := range ous { - organizationUnits, err := findAllOrganizationUnitsForParentAndBelow(ctx, conn, aws.ToString(ou.Id)) + organizationUnits, err := findAllOrganizationalUnitsForParentAndBelow(ctx, conn, aws.ToString(ou.Id)) if err != nil { return nil, err diff --git a/internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go similarity index 92% rename from internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go rename to internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go index e9459886989..5a7cd133780 100644 --- a/internal/service/organizations/organizational_units_descendant_organization_units_data_source_test.go +++ b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go @@ -16,9 +16,9 @@ import ( func testOrganizationalUnitDescendantOusDataSource_basic(t *testing.T) { ctx := acctest.Context(t) rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) - topOUDataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.current" - newOU1DataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.test0" - newOU2DataSourceName := "data.aws_organizations_organizational_unit_descendant_organization_units.test1" + topOUDataSourceName := "data.aws_organizations_organizational_unit_descendant_organizational_units.current" + newOU1DataSourceName := "data.aws_organizations_organizational_unit_descendant_organizational_units.test0" + newOU2DataSourceName := "data.aws_organizations_organizational_unit_descendant_organizational_units.test1" resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -54,19 +54,19 @@ resource "aws_organizations_organizational_unit" "test1" { parent_id = aws_organizations_organizational_unit.test0.id } -data "aws_organizations_organizational_unit_descendant_organization_units" "current" { +data "aws_organizations_organizational_unit_descendant_organizational_units" "current" { parent_id = data.aws_organizations_organization.current.roots[0].id depends_on = [aws_organizations_organizational_unit.test0, aws_organizations_organizational_unit.test1] } -data "aws_organizations_organizational_unit_descendant_organization_units" "test0" { +data "aws_organizations_organizational_unit_descendant_organizational_units" "test0" { parent_id = aws_organizations_organizational_unit.test0.id depends_on = [aws_organizations_organizational_unit.test1] } -data "aws_organizations_organizational_unit_descendant_organization_units" "test1" { +data "aws_organizations_organizational_unit_descendant_organizational_units" "test1" { parent_id = aws_organizations_organizational_unit.test1.id } `, rName) diff --git a/internal/service/organizations/service_package_gen.go b/internal/service/organizations/service_package_gen.go index 90655350497..8348d7ad964 100644 --- a/internal/service/organizations/service_package_gen.go +++ b/internal/service/organizations/service_package_gen.go @@ -52,16 +52,16 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac TypeName: "aws_organizations_organizational_unit_descendant_accounts", Name: "Organizational Unit Descendant Accounts", }, + { + Factory: dataSourceOrganizationalUnitDescendantOrganizationalUnits, + TypeName: "aws_organizations_organizational_unit_descendant_organizational_units", + Name: "Organizational Unit Descendant Organization Units", + }, { Factory: dataSourceOrganizationalUnits, TypeName: "aws_organizations_organizational_units", Name: "Organizational Unit", }, - { - Factory: dataSourceOrganizationalUnitDescendantOrganizationUnits, - TypeName: "aws_organizations_organizational_unit_descendant_organization_units", - Name: "Organizational Unit Descendant Organization Units", - }, { Factory: dataSourcePolicies, TypeName: "aws_organizations_policies", diff --git a/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown b/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown similarity index 94% rename from website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown rename to website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown index 6d6fe9110d0..8d9cf61b1fe 100644 --- a/website/docs/d/organizations_organizational_unit_descendant_organization_units.html.markdown +++ b/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown @@ -1,12 +1,12 @@ --- subcategory: "Organizations" layout: "aws" -page_title: "AWS: aws_organizations_organizational_unit_descendant_organization_units" +page_title: "AWS: aws_organizations_organizational_unit_descendant_organizational_units" description: |- Get all direct child organizational units under a parent organizational unit. This provides all children. --- -# Data Source: aws_organizations_organizational_unit_descendant_organization_units +# Data Source: aws_organizations_organizational_unit_descendant_organizational_units Get all direct child organizational units under a parent organizational unit. This provides all children. @@ -15,7 +15,7 @@ Get all direct child organizational units under a parent organizational unit. Th ```terraform data "aws_organizations_organization" "org" {} -data "aws_organizations_organizational_unit_descendant_organization_units" "ous" { +data "aws_organizations_organizational_unit_descendant_organizational_units" "ous" { parent_id = data.aws_organizations_organization.org.roots[0].id } ``` From 76a4ec03f12104ada034d65046e93b64cab14e9e Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 3 Sep 2024 11:20:43 -0400 Subject: [PATCH 5/6] Fix markdownlint 'D007/ul-indent Unordered list indentation [Expected: 4; Actual: 2]'. --- ...ional_unit_descendant_organizational_units.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown b/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown index 8d9cf61b1fe..07c5a84789d 100644 --- a/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown +++ b/website/docs/d/organizations_organizational_unit_descendant_organizational_units.html.markdown @@ -29,7 +29,7 @@ data "aws_organizations_organizational_unit_descendant_organizational_units" "ou This data source exports the following attributes in addition to the arguments above: * `children` - List of child organizational units, which have the following attributes: - * `arn` - ARN of the organizational unit - * `name` - Name of the organizational unit - * `id` - ID of the organizational unit + * `arn` - ARN of the organizational unit + * `name` - Name of the organizational unit + * `id` - ID of the organizational unit * `id` - Parent identifier of the organizational units. From 18419fa9979fd435a208a72b80b2331057f57cf1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 3 Sep 2024 11:31:50 -0400 Subject: [PATCH 6/6] Fix 'testOrganizationalUnitDescendantOUsDataSource_basic'. --- ...ts_descendant_organizational_units_data_source_test.go | 8 ++++---- internal/service/organizations/organizations_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go index 5a7cd133780..5ff2a86693f 100644 --- a/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go +++ b/internal/service/organizations/organizational_units_descendant_organizational_units_data_source_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -func testOrganizationalUnitDescendantOusDataSource_basic(t *testing.T) { +func testOrganizationalUnitDescendantOUsDataSource_basic(t *testing.T) { ctx := acctest.Context(t) rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) topOUDataSourceName := "data.aws_organizations_organizational_unit_descendant_organizational_units.current" @@ -30,9 +30,9 @@ func testOrganizationalUnitDescendantOusDataSource_basic(t *testing.T) { Steps: []resource.TestStep{ { Config: testOrganizationalUnitDescendantOusDataSourceConfig_basic(rName), - Check: resource.ComposeTestCheckFunc( - acctest.CheckResourceAttrGreaterThanValue(topOUDataSourceName, "children.#", 0), - resource.TestCheckResourceAttr(newOU1DataSourceName, "children.#", acctest.Ct0), + Check: resource.ComposeAggregateTestCheckFunc( + acctest.CheckResourceAttrGreaterThanOrEqualValue(topOUDataSourceName, "children.#", 2), + resource.TestCheckResourceAttr(newOU1DataSourceName, "children.#", acctest.Ct1), resource.TestCheckResourceAttr(newOU2DataSourceName, "children.#", acctest.Ct0), ), }, diff --git a/internal/service/organizations/organizations_test.go b/internal/service/organizations/organizations_test.go index 56bc7e93c60..61df0c7091a 100644 --- a/internal/service/organizations/organizations_test.go +++ b/internal/service/organizations/organizations_test.go @@ -50,7 +50,7 @@ func TestAccOrganizations_serial(t *testing.T) { "update": testAccOrganizationalUnit_update, "tags": testAccOrganizationalUnit_tags, "DataSource_basic": testAccOrganizationalUnitDataSource_basic, - "DescendantOusDataSource_basic": testOrganizationalUnitDescendantOusDataSource_basic, + "DescendantOUsDataSource_basic": testOrganizationalUnitDescendantOUsDataSource_basic, "ChildAccountsDataSource_basic": testAccOrganizationalUnitChildAccountsDataSource_basic, "DescendantAccountsDataSource_basic": testAccOrganizationalUnitDescendantAccountsDataSource_basic, "PluralDataSource_basic": testAccOrganizationalUnitsDataSource_basic,