Skip to content

Commit

Permalink
resource/aws_dynamodb_table: Skip ResourceNotFoundException during de…
Browse files Browse the repository at this point in the history
…letion (#11692)

Previously in the acceptance testing:

```
--- FAIL: TestAccAWSDynamoDbGlobalTable_multipleRegions (67.39s)
    testing.go:701: Error destroying resource! WARNING: Dangling resources
        may exist. The full state and error is shown below.

        Error: errors during apply: error deleting DynamoDB Table (tf-acc-test-tyuvv): Error deleting DynamoDB table: ResourceNotFoundException: Requested resource not found: Table: tf-acc-test-tyuvv not found
```

The prior code would wrap the `awserr.Error` in a `fmt.Errorf()` which meant the error was returned by value. The calling code already handles the error message context, so we remove the error wrapping so consumers can work with the AWS error type correctly. Another solution here would be instead using the Go 1.13 `%w` format verb, which will be part of a future linting check.

Output from acceptance testing:

```
--- PASS: TestAccAWSDynamoDbGlobalTable_basic (86.21s)
--- PASS: TestAccAWSDynamoDbGlobalTable_multipleRegions (106.17s)

--- PASS: TestAccAWSDynamoDbTable_attributeUpdate (463.78s)
--- PASS: TestAccAWSDynamoDbTable_attributeUpdateValidation (6.14s)
--- PASS: TestAccAWSDynamoDbTable_basic (27.57s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_PayPerRequestToProvisioned (57.72s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_GSI_ProvisionedToPayPerRequest (1149.43s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_PayPerRequestToProvisioned (45.62s)
--- PASS: TestAccAWSDynamoDbTable_BillingMode_ProvisionedToPayPerRequest (1325.53s)
--- PASS: TestAccAWSDynamoDbTable_disappears (19.40s)
--- PASS: TestAccAWSDynamoDbTable_disappears_PayPerRequestWithGSI (100.90s)
--- PASS: TestAccAWSDynamoDbTable_enablePitr (133.02s)
--- PASS: TestAccAWSDynamoDbTable_encryption (62.77s)
--- PASS: TestAccAWSDynamoDbTable_extended (195.41s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateCapacity (56.73s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateNonKeyAttributes (157.72s)
--- PASS: TestAccAWSDynamoDbTable_gsiUpdateOtherAttributes (465.18s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecification (67.08s)
--- PASS: TestAccAWSDynamoDbTable_streamSpecificationValidation (4.85s)
--- PASS: TestAccAWSDynamoDbTable_tags (36.51s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Disabled (41.27s)
--- PASS: TestAccAWSDynamoDbTable_Ttl_Enabled (29.97s)
```
  • Loading branch information
bflad authored Feb 3, 2020
1 parent 1c86619 commit 2b27d03
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions aws/resource_aws_dynamodb_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,13 +694,12 @@ func deleteAwsDynamoDbTable(tableName string, conn *dynamodb.DynamoDB) error {
}
return nil
})

if isResourceTimeoutError(err) {
_, err = conn.DeleteTable(input)
}
if err != nil {
return fmt.Errorf("Error deleting DynamoDB table: %s", err)
}
return nil

return err
}

func waitForDynamodbTableDeletion(conn *dynamodb.DynamoDB, tableName string, timeout time.Duration) error {
Expand Down

0 comments on commit 2b27d03

Please sign in to comment.