Skip to content

Commit

Permalink
CR updates; set tags on create input and add CHANGELOG entry
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Apr 14, 2021
1 parent 2ea574c commit f3e53a1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/15615.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_organizations_organizational_unit: Add `tags` argument
```
7 changes: 1 addition & 6 deletions aws/resource_aws_organizations_organizational_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func resourceAwsOrganizationsOrganizationalUnitCreate(d *schema.ResourceData, me
createOpts := &organizations.CreateOrganizationalUnitInput{
Name: aws.String(d.Get("name").(string)),
ParentId: aws.String(d.Get("parent_id").(string)),
Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().OrganizationsTags(),
}

log.Printf("[DEBUG] Organizational Unit create config: %#v", createOpts)
Expand Down Expand Up @@ -110,12 +111,6 @@ func resourceAwsOrganizationsOrganizationalUnitCreate(d *schema.ResourceData, me
ouId := resp.OrganizationalUnit.Id
d.SetId(aws.StringValue(ouId))

if v := d.Get("tags").(map[string]interface{}); len(v) > 0 {
if err := keyvaluetags.OrganizationsUpdateTags(conn, d.Id(), nil, v); err != nil {
return fmt.Errorf("Error adding Organizational Unit (%s) tags: %s", d.Id(), err)
}
}

return resourceAwsOrganizationsOrganizationalUnitRead(d, meta)
}

Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_organizations_organizational_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func testAccAwsOrganizationsOrganizationalUnit_Tags(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOrganizationsAccountPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, organizations.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsOrganizationsOrganizationalUnitDestroy,
Steps: []resource.TestStep{
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_organizations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccAWSOrganizations_serial(t *testing.T) {
"basic": testAccAwsOrganizationsOrganizationalUnit_basic,
"disappears": testAccAwsOrganizationsOrganizationalUnit_disappears,
"Name": testAccAwsOrganizationsOrganizationalUnit_Name,
"Tags": testAccAwsOrganizationsOrganizationalUnit_Tags,
"Tags": testAccAwsOrganizationsOrganizationalUnit_Tags,
},
"OrganizationalUnits": {
"DataSource": testAccDataSourceAwsOrganizationsOrganizationalUnits_basic,
Expand Down

0 comments on commit f3e53a1

Please sign in to comment.