Skip to content

Commit

Permalink
fix(newrelic_api_access_key): Fix missing resource newrelic_api_acces…
Browse files Browse the repository at this point in the history
…s_key error (#2520)
  • Loading branch information
gramsa49 authored and sanderblue committed Dec 13, 2023
1 parent 9fd644d commit 6981577
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions newrelic/resource_newrelic_api_access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package newrelic

import (
"context"
"errors"
"fmt"
"log"
"strings"
Expand Down Expand Up @@ -98,7 +97,7 @@ func resourceNewrelicAPIAccessKeyImport(ctx context.Context, d *schema.ResourceD

diag := resourceNewRelicAPIAccessKeyRead(ctx, d, meta)
if diag.HasError() {
return nil, errors.New("error reading after import")
return nil, fmt.Errorf("error reading after import")
}

return []*schema.ResourceData{d}, nil
Expand Down Expand Up @@ -179,6 +178,10 @@ func resourceNewRelicAPIAccessKeyRead(ctx context.Context, d *schema.ResourceDat

key, readErr := client.APIAccess.GetAPIAccessKeyWithContext(ctx, d.Id(), apiaccess.APIAccessKeyType(getAPIAccessKeyType(d)))
if readErr != nil {
if strings.Contains(readErr.Error(), "Key not found") {
d.SetId("")
return nil
}
return diag.FromErr(readErr)
}

Expand Down

0 comments on commit 6981577

Please sign in to comment.