Skip to content

Commit

Permalink
Merge pull request #34424 from hashicorp/b-inspector2-crashes
Browse files Browse the repository at this point in the history
inspector2: Fix a couple of crashes
  • Loading branch information
ewbankkit authored Nov 15, 2023
2 parents 8ffa80e + a3a22ac commit 1287ab9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changelog/34424.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_inspector2_delegated_admin_account: Fix `errors: *target must be interface or implement error` panic
```

```release-note:bug
resource/aws_inspector2_enabler: Fix `interface conversion: interface {} is nil, not map[string]inspector2.AccountResourceStatus` panic
```
9 changes: 4 additions & 5 deletions internal/service/inspector2/delegated_admin_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,11 @@ func FindDelegatedAdminAccountStatusID(ctx context.Context, conn *inspector2.Cli
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if err != nil {
var ve types.ValidationException
if errs.AsContains(err, &ve, "is the delegated admin") {
return string(types.RelationshipStatusEnabled), accountID, nil
}
if errs.IsAErrorMessageContains[*types.ValidationException](err, "is the delegated admin") {
return string(types.RelationshipStatusEnabled), accountID, nil
}

if err != nil {
return "", "", err
}

Expand Down
10 changes: 7 additions & 3 deletions internal/service/inspector2/enabler.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,13 @@ func waitEnabled(ctx context.Context, conn *inspector2.Client, accountIDs []stri
Delay: 10 * time.Second,
}

raw, err := stateConf.WaitForStateContext(ctx)
result := raw.(map[string]AccountResourceStatus)
return result, err
outputRaw, err := stateConf.WaitForStateContext(ctx)

if output, ok := outputRaw.(map[string]AccountResourceStatus); ok {
return output, err
}

return nil, err
}

func waitDisabled(ctx context.Context, conn *inspector2.Client, accountIDs []string, timeout time.Duration) error {
Expand Down

0 comments on commit 1287ab9

Please sign in to comment.