Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading existing organizations accounts #24899

Merged
merged 6 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/24899.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_organizations_account: Fix reading account state for existing accounts
```
10 changes: 1 addition & 9 deletions internal/service/organizations/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
"github.com/hashicorp/terraform-provider-aws/names"
)

func ResourceAccount() *schema.Resource {
Expand Down Expand Up @@ -140,6 +139,7 @@ func resourceAccountCreate(d *schema.ResourceData, meta interface{}) error {
}

d.SetId(aws.StringValue(output.AccountId))
d.Set("govcloud_id", output.GovCloudAccountId)
ewbankkit marked this conversation as resolved.
Show resolved Hide resolved

if v, ok := d.GetOk("parent_id"); ok {
oldParentAccountID, err := findParentAccountID(conn, d.Id())
Expand Down Expand Up @@ -196,14 +196,6 @@ func resourceAccountRead(d *schema.ResourceData, meta interface{}) error {
d.Set("parent_id", parentAccountID)
d.Set("status", account.Status)

s, err := findCreateAccountStatusByID(conn, d.Id())

if err != nil {
return names.Error(names.Organizations, "finding", "Create Account Status", d.Id(), err)
}

d.Set("govcloud_id", s.GovCloudAccountId)

tags, err := ListTags(conn, d.Id())

if err != nil {
Expand Down