Skip to content

Commit

Permalink
fix: check !d.IsNewResource() before d.SetId("")
Browse files Browse the repository at this point in the history
#16796
https://github.com/hashicorp/terraform-provider-aws/pull/19307/checks?check_run_id=2554016542

```
Calling `d.SetId("")` should ensure `!d.IsNewResource()` is checked first
```
  • Loading branch information
suzuki-shunsuke committed May 11, 2021
1 parent fd94cb2 commit b47ccb6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aws/resource_aws_appconfig_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func resourceAwsAppconfigApplicationRead(d *schema.ResourceData, meta interface{

output, err := conn.GetApplication(input)

if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") {
if !d.IsNewResource() && isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") {
log.Printf("[WARN] Appconfig Application (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_appconfig_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func resourceAwsAppconfigEnvironmentRead(d *schema.ResourceData, meta interface{

output, err := conn.GetEnvironment(input)

if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") {
if !d.IsNewResource() && isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") {
log.Printf("[WARN] Appconfig Environment (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
Expand Down

0 comments on commit b47ccb6

Please sign in to comment.