Skip to content

Commit

Permalink
resource/aws_ssm_document: Fixes for tfproviderlint R006
Browse files Browse the repository at this point in the history
Reference: #11864

`RetryFunc` should only be used when logic has a retryable condition. In the case of working with the AWS Go SDK, it also arbitrarily restricts the automatic retrying logic of API calls to the timeout, which is generally undesired.

Previously:

```
aws/resource_aws_ssm_document.go:213:39: R006: RetryFunc should include RetryableError() handling or be removed
```

Output from acceptance testing:

```
--- PASS: TestAccAWSSSMDocument_basic (26.29s)
--- PASS: TestAccAWSSSMDocument_session (37.24s)
--- PASS: TestAccAWSSSMDocument_automation (41.32s)
--- PASS: TestAccAWSSSMDocument_permission_batching (44.07s)
--- PASS: TestAccAWSSSMDocument_params (46.96s)
--- PASS: TestAccAWSSSMDocument_SchemaVersion_1 (48.76s)
--- PASS: TestAccAWSSSMDocument_DocumentFormat_YAML (51.32s)
--- PASS: TestAccAWSSSMDocument_target_type (51.87s)
--- PASS: TestAccAWSSSMDocument_Tags (58.75s)
--- PASS: TestAccAWSSSMDocument_permission_private (66.11s)
--- PASS: TestAccAWSSSMDocument_permission_public (67.63s)
--- PASS: TestAccAWSSSMDocument_update (76.88s)
--- PASS: TestAccAWSSSMDocument_permission_change (77.82s)
--- PASS: TestAccAWSSSMDocument_package (83.33s)
```
  • Loading branch information
bflad committed Feb 13, 2020
1 parent 0efdad0 commit df6a553
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions aws/resource_aws_ssm_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,8 @@ func resourceAwsSsmDocumentCreate(d *schema.ResourceData, meta interface{}) erro
docInput.TargetType = aws.String(v.(string))
}

log.Printf("[DEBUG] Waiting for SSM Document %q to be created", d.Get("name").(string))
var resp *ssm.CreateDocumentOutput
err := resource.Retry(5*time.Minute, func() *resource.RetryError {
var err error
resp, err = ssmconn.CreateDocument(docInput)
resp, err := ssmconn.CreateDocument(docInput)

if err != nil {
return resource.NonRetryableError(err)
}
return nil
})

if isResourceTimeoutError(err) {
resp, err = ssmconn.CreateDocument(docInput)
}
if err != nil {
return fmt.Errorf("Error creating SSM document: %s", err)
}
Expand Down

0 comments on commit df6a553

Please sign in to comment.