Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bare error returns from CRUD functions #28894

Merged
merged 106 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
08e4431
Documentation update
gdavison Jan 9, 2023
71649e8
Fixes bare errors in `route53`
gdavison Jan 9, 2023
a2fac30
Fixes bare errors in `redshift`
gdavison Jan 9, 2023
46f9a44
Fixes bare errors in `opsworks`
gdavison Jan 9, 2023
f2325a5
Fixes bare errors in `kms`
gdavison Jan 9, 2023
3a3a07f
Fixes bare errors in `workspaces`
gdavison Jan 10, 2023
a168c55
Fixes bare errors in `worklink`
gdavison Jan 10, 2023
43c4fe3
Fixes bare errors in `wafregional`
gdavison Jan 10, 2023
c676bb6
Fixes bare errors in `waf`
gdavison Jan 10, 2023
a8cc16e
Fixes bare errors in `transfer`
gdavison Jan 10, 2023
deef1c0
Fixes bare errors in `synthetics`
gdavison Jan 10, 2023
8bac032
Fixes bare errors in `storagegateway`
gdavison Jan 10, 2023
111a821
Fixes bare errors in `ssoadmin`
gdavison Jan 10, 2023
1ad4efa
Fixes bare errors in `ssm`
gdavison Jan 10, 2023
4c1797b
Fixes bare errors in `signer`
gdavison Jan 10, 2023
9d4c5de
Fixes bare errors in `ses`
gdavison Jan 10, 2023
24f8be1
Fixes bare errors in `servicequotas`
gdavison Jan 10, 2023
0f163db
Fixes bare errors in `serverlessrepo`
gdavison Jan 10, 2023
4873e02
Fixes bare errors in `securityhub`
gdavison Jan 10, 2023
f00e926
Fixes bare errors in `secretsmanager`
gdavison Jan 10, 2023
a2743ba
Fixes bare errors in `sagemaker`
gdavison Jan 10, 2023
592d3f7
Fixes bare errors in `s3`
gdavison Jan 10, 2023
58ea7ca
Fixes bare errors in `route53`
gdavison Jan 10, 2023
4bf93e0
Fixes bare errors in `redshiftserverless`
gdavison Jan 10, 2023
6ff207a
Fixes bare errors in `redshift`
gdavison Jan 10, 2023
afe3427
Fixes bare errors in `rds`
gdavison Jan 10, 2023
c1bed80
Fixes bare errors in `ram`
gdavison Jan 10, 2023
c9d0b50
Fixes bare errors in `quicksight`
gdavison Jan 10, 2023
b49e333
Fixes bare errors in `pinpoint`
gdavison Jan 10, 2023
fe30bd6
Fixes bare errors in `organizations`
gdavison Jan 10, 2023
ad7930b
Fixes bare errors in `opsworks`
gdavison Jan 10, 2023
a846857
Fixes bare errors in `opensearch`
gdavison Jan 10, 2023
567164c
Fixes bare errors in `networkmanager`
gdavison Jan 11, 2023
76fc089
Fixes bare errors in `neptune`
gdavison Jan 11, 2023
0cdb271
Fixes bare errors in `mediastore`
gdavison Jan 11, 2023
7d2d5b0
Fixes bare errors in `lightsail`
gdavison Jan 11, 2023
01d8a16
Fixes bare errors in `lexmodels`
gdavison Jan 11, 2023
2d9758b
Fixes bare errors in `lambda`
gdavison Jan 11, 2023
2ae8d9a
Fixes bare errors in `lakeformation`
gdavison Jan 11, 2023
f3b3dfa
Fixes bare errors in `kinesisanalyticsv2`
gdavison Jan 11, 2023
5a75123
Fixes bare errors in `kinesisanalytics`
gdavison Jan 11, 2023
4e1647a
Fixes bare errors in `iot`
gdavison Jan 11, 2023
1271cd2
Fixes bare errors in `iam`
gdavison Jan 11, 2023
fa5f09d
Fixes bare errors in `guardduty`
gdavison Jan 11, 2023
d922c86
Fixes bare errors in `grafana`
gdavison Jan 11, 2023
5a07c16
Fixes bare errors in `glue`
gdavison Jan 11, 2023
0f4a5ac
Fixes bare errors in `glacier`
gdavison Jan 11, 2023
e01d2db
Fixes bare errors in `gamelift`
gdavison Jan 11, 2023
db9809a
Fixes bare errors in `fms`
gdavison Jan 11, 2023
ddf1e1e
Fixes bare errors in `firehose`
gdavison Jan 11, 2023
fb3a12e
Fixes bare errors in `events`
gdavison Jan 11, 2023
b0b8d81
Removes unnecessary `[ERROR]` in error messages
gdavison Jan 12, 2023
56821d6
Fixes bare errors in `emr`
gdavison Jan 12, 2023
dfad739
Fixes bare errors in `elbv2`
gdavison Jan 12, 2023
bc29e4c
Fixes bare errors in `elb`
gdavison Jan 12, 2023
8198117
Fixes bare errors in `elastictranscoder`
gdavison Jan 12, 2023
c8daebe
Fixes bare errors in `elasticsearch`
gdavison Jan 12, 2023
f5ebd6b
Fixes bare errors in `elasticbeanstalk`
gdavison Jan 12, 2023
1e3dce5
Fixes bare errors in `elasticache`
gdavison Jan 12, 2023
1f9897f
Fixes bare errors in `eks`
gdavison Jan 12, 2023
b60b1b8
Fixes bare errors in `efs`
gdavison Jan 12, 2023
b524557
Fixes bare errors in `ecs`
gdavison Jan 12, 2023
d6ea3d4
Fixes bare errors in `ecrpublic`
gdavison Jan 12, 2023
0fe4aae
Fixes bare errors in `ecr`
gdavison Jan 12, 2023
844452f
Fixes bare errors in `ec2`
gdavison Jan 12, 2023
d5faebc
Fixes bare errors in `dynamodb`
gdavison Jan 12, 2023
2889494
Fixes bare errors in `ds`
gdavison Jan 12, 2023
1eecb3a
Fixes bare errors in `docdb`
gdavison Jan 12, 2023
0e73f6c
Fixes bare errors in `dms`
gdavison Jan 12, 2023
985a44c
Fixes bare errors in `directconnect`
gdavison Jan 12, 2023
2b19b4a
Fixes bare errors in `deploy`
gdavison Jan 12, 2023
ec0296c
Fixes bare errors in `dax`
gdavison Jan 12, 2023
4d9340e
Fixes bare errors in `datasync`
gdavison Jan 12, 2023
3d98158
Fixes bare errors in `dataexchange`
gdavison Jan 12, 2023
8990c49
Fixes bare errors in `cur`
gdavison Jan 12, 2023
7fcf298
Fixes bare errors in `connect`
gdavison Jan 12, 2023
c1ab280
Fixes bare errors in `configservice`
gdavison Jan 12, 2023
ef2610c
Fixes bare errors in `cognitoidp`
gdavison Jan 12, 2023
107f231
Fixes bare errors in `cognitoidentity`
gdavison Jan 12, 2023
2a07591
Fixes bare errors in `codestarnotifications`
gdavison Jan 12, 2023
53a425d
Fixes bare errors in `codecommit`
gdavison Jan 12, 2023
29dfadb
Fixes bare errors in `codebuild`
gdavison Jan 12, 2023
8a7d372
Fixes bare errors in `codeartifact`
gdavison Jan 12, 2023
3757dd0
Fixes bare errors in `cloudwatch`
gdavison Jan 12, 2023
6790f9a
Fixes bare errors in `cloudtrail`
gdavison Jan 12, 2023
8eab28c
Fixes bare errors in `cloudsearch`
gdavison Jan 12, 2023
85555e5
Fixes bare errors in `cloudfront`
gdavison Jan 12, 2023
909319c
Fixes bare errors in `cloudformation`
gdavison Jan 12, 2023
05fab27
Fixes bare errors in `cloud9`
gdavison Jan 12, 2023
3daf308
Fixes bare errors in `batch`
gdavison Jan 12, 2023
636208a
Fixes bare errors in `backup`
gdavison Jan 12, 2023
b103da0
Fixes bare errors in `autoscalingplans`
gdavison Jan 12, 2023
cfa23e5
Fixes bare errors in `autoscaling`
gdavison Jan 12, 2023
0c176c3
Fixes bare errors in `athena`
gdavison Jan 12, 2023
b7f88ff
Fixes bare errors in `appsync`
gdavison Jan 12, 2023
7514e74
Fixes bare errors in `appintegrations`
gdavison Jan 12, 2023
42e2812
Fixes bare errors in `appconfig`
gdavison Jan 12, 2023
ae435bd
Fixes bare errors in `appautoscaling`
gdavison Jan 12, 2023
674817b
Fixes bare errors in `apigatewayv2`
gdavison Jan 12, 2023
362c59d
Fixes bare errors in `apigateway`
gdavison Jan 12, 2023
2efba6a
Fixes bare errors in `acmpca`
gdavison Jan 12, 2023
a192514
Adds semgrep rule to default file
gdavison Jan 13, 2023
7a10b57
Removes extra leading `error ` from error messages in documentation
gdavison Jan 13, 2023
3c6272c
Missing documentation
gdavison Jan 13, 2023
a614ace
`yamllint`
gdavison Jan 13, 2023
cd01122
Test fixes
gdavison Jan 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
17 changes: 17 additions & 0 deletions .ci/.semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -854,3 +854,20 @@ rules:
patterns:
- pattern-regex: '(Create|Read|Update|Delete)Context:'
severity: ERROR

- id: bare-error-returns
languages: [go]
message: API errors should be wrapped with the CRUD info
paths:
include:
- internal/service
patterns:
- pattern: return $ERR
- pattern-inside: |
func $FUNC($D *schema.ResourceData, ...) error {
...
}
- metavariable-regex:
metavariable: $ERR
regex: "[Ee]rr(?!ors\\.)"
severity: ERROR
8 changes: 4 additions & 4 deletions docs/data-handling-and-conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ To further understand the necessary data conversions used throughout the Terrafo
| `list` | `[]*T` | `TypeList` (`[]interface{}` of `T`)<br/>`TypeSet` (`*schema.Set` of `T`) | `list(any)`<br/>`set(any)` |
| `map` | `map[T1]*T2` | `TypeMap` (`map[string]interface{}`) | `map(any)` |
| `string` | `*string` | `TypeString` (`string`) | `string` |
| `structure` | `struct` | `TypeList` (`[]interface{}` of `map[string]interface{}`) | `list(object(any))` |
| `structure` | `struct` | `TypeList` (`[]interface{}` of `map[string]interface{}`) with `MaxItems: 1` | `list(object(any))` |
| `timestamp` | `*time.Time` | `TypeString` (typically RFC3339 formatted) | `string` |

<!-- markdownlint-enable no-inline-html --->
Expand Down Expand Up @@ -282,7 +282,7 @@ To write:

```go
if err := d.Set("attribute_name", flattenStructures(output.Thing.AttributeName)); err != nil {
return fmt.Errorf("error setting attribute_name: %w", err)
return fmt.Errorf("setting attribute_name: %w", err)
}
```

Expand All @@ -303,7 +303,7 @@ To write (_likely to have helper function introduced soon_):
```go
if output.Thing.AttributeName != nil {
if err := d.Set("attribute_name", []interface{}{flattenStructure(output.Thing.AttributeName)}); err != nil {
return fmt.Errorf("error setting attribute_name: %w", err)
return fmt.Errorf("setting attribute_name: %w", err)
}
} else {
d.Set("attribute_name", nil)
Expand Down Expand Up @@ -362,7 +362,7 @@ To write:

```go
if err := d.Set("attribute_name", flattenStructures(output.Thing.AttributeNames)); err != nil {
return fmt.Errorf("error setting attribute_name: %w", err)
return fmt.Errorf("setting attribute_name: %w", err)
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/raising-a-pull-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ This Contribution Guide also includes separate sections on topics such as [Error
}

if err != nil {
return fmt.Errorf("error creating KMS External Key: %s", err)
return fmt.Errorf("creating KMS External Key: %s", err)
}
```

Expand Down
4 changes: 2 additions & 2 deletions internal/generate/tags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interfa
_, err := conn.UntagResource(input)

if err != nil {
return fmt.Errorf("error untagging resource (%s): %s", identifier, err)
return fmt.Errorf("untagging resource (%s): %s", identifier, err)
}
}

Expand All @@ -363,7 +363,7 @@ func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interfa
_, err := conn.TagResource(input)

if err != nil {
return fmt.Errorf("error tagging resource (%s): %s", identifier, err)
return fmt.Errorf("tagging resource (%s): %s", identifier, err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/generate/tags/README_updatetags.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interfa
_, err := conn.UntagResource(input)

if err != nil {
return fmt.Errorf("error untagging resource (%s): %s", identifier, err)
return fmt.Errorf("untagging resource (%s): %s", identifier, err)
}
}

Expand All @@ -40,7 +40,7 @@ func AthenaUpdateTags(conn *athena.Athena, identifier string, oldTagsMap interfa
_, err := conn.TagResource(input)

if err != nil {
return fmt.Errorf("error tagging resource (%s): %s", identifier, err)
return fmt.Errorf("tagging resource (%s): %s", identifier, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ func New(ctx context.Context) (*schema.Provider, error) {
"aws_guardduty_organization_admin_account": guardduty.ResourceOrganizationAdminAccount(),
"aws_guardduty_organization_configuration": guardduty.ResourceOrganizationConfiguration(),
"aws_guardduty_publishing_destination": guardduty.ResourcePublishingDestination(),
"aws_guardduty_threatintelset": guardduty.ResourceThreatintelset(),
"aws_guardduty_threatintelset": guardduty.ResourceThreatIntelSet(),

"aws_iam_access_key": iam.ResourceAccessKey(),
"aws_iam_account_alias": iam.ResourceAccountAlias(),
Expand Down
4 changes: 2 additions & 2 deletions internal/service/acmpca/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func resourcePermissionRead(d *schema.ResourceData, meta interface{}) error {
caARN, principal, sourceAccount, err := PermissionParseResourceID(d.Id())

if err != nil {
return err
return fmt.Errorf("reading ACM PCA Permission (%s): %w", d.Id(), err)
}

permission, err := FindPermission(conn, caARN, principal, sourceAccount)
Expand Down Expand Up @@ -125,7 +125,7 @@ func resourcePermissionDelete(d *schema.ResourceData, meta interface{}) error {
caARN, principal, sourceAccount, err := PermissionParseResourceID(d.Id())

if err != nil {
return err
return fmt.Errorf("deleting ACM PCA Permission: %s", err)
}

input := &acmpca.DeletePermissionInput{
Expand Down
7 changes: 4 additions & 3 deletions internal/service/apigateway/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ func ResourceAccount() *schema.Resource {
func resourceAccountRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).APIGatewayConn()

log.Printf("[INFO] Reading API Gateway Account %s", d.Id())
account, err := conn.GetAccount(&apigateway.GetAccountInput{})
if err != nil {
return err
return fmt.Errorf("reading API Gateway Account: %w", err)
}

log.Printf("[DEBUG] Received API Gateway Account: %s", account)
Expand All @@ -65,7 +64,9 @@ func resourceAccountRead(d *schema.ResourceData, meta interface{}) error {
// (e.g. for referencing throttle_settings)
d.Set("cloudwatch_role_arn", account.CloudwatchRoleArn)
}
d.Set("throttle_settings", FlattenThrottleSettings(account.ThrottleSettings))
if err := d.Set("throttle_settings", FlattenThrottleSettings(account.ThrottleSettings)); err != nil {
return fmt.Errorf("reading API Gateway Account: %w", err)
}

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apigateway/api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func resourceAPIKeyUpdate(d *schema.ResourceData, meta interface{}) error {
PatchOperations: resourceAPIKeyUpdateOperations(d),
})
if err != nil {
return err
return fmt.Errorf("updating API Gateway API Key (%s): %w", d.Id(), err)
}

return resourceAPIKeyRead(d, meta)
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apigateway/api_key_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func dataSourceAPIKeyRead(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return err
return fmt.Errorf("reading API Gateway API Key (%s): %w", d.Get("id").(string), err)
}

d.SetId(aws.StringValue(apiKey.Id))
Expand Down
4 changes: 2 additions & 2 deletions internal/service/apigateway/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func resourceAuthorizerCreate(d *schema.ResourceData, meta interface{}) error {
}

if err := validateAuthorizerType(d); err != nil {
return err
return fmt.Errorf("creating API Gateway Authorizer: %w", err)
}
if v, ok := d.GetOk("authorizer_uri"); ok {
input.AuthorizerUri = aws.String(v.(string))
Expand Down Expand Up @@ -141,7 +141,7 @@ func resourceAuthorizerCreate(d *schema.ResourceData, meta interface{}) error {
log.Printf("[INFO] Creating API Gateway Authorizer: %s", input)
out, err := conn.CreateAuthorizer(&input)
if err != nil {
return fmt.Errorf("error creating API Gateway Authorizer: %w", err)
return fmt.Errorf("creating API Gateway Authorizer: %w", err)
}

d.SetId(aws.StringValue(out.Id))
Expand Down
8 changes: 4 additions & 4 deletions internal/service/apigateway/base_path_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func resourceBasePathMappingRead(d *schema.ResourceData, meta interface{}) error

domainName, basePath, err := DecodeBasePathMappingID(d.Id())
if err != nil {
return err
return fmt.Errorf("reading API Gateway Base Path Mapping (%s): %w", d.Id(), err)
}

mapping, err := conn.GetBasePathMapping(&apigateway.GetBasePathMappingInput{
Expand All @@ -165,7 +165,7 @@ func resourceBasePathMappingRead(d *schema.ResourceData, meta interface{}) error
return nil
}

return fmt.Errorf("error reading API Gateway Base Path Mapping (%s): %w", d.Id(), err)
return fmt.Errorf("reading API Gateway Base Path Mapping (%s): %w", d.Id(), err)
}

mappingBasePath := aws.StringValue(mapping.BasePath)
Expand All @@ -187,7 +187,7 @@ func resourceBasePathMappingDelete(d *schema.ResourceData, meta interface{}) err

domainName, basePath, err := DecodeBasePathMappingID(d.Id())
if err != nil {
return err
return fmt.Errorf("deleting API Gateway Base Path Mapping (%s): %w", d.Id(), err)
}

_, err = conn.DeleteBasePathMapping(&apigateway.DeleteBasePathMappingInput{
Expand All @@ -200,7 +200,7 @@ func resourceBasePathMappingDelete(d *schema.ResourceData, meta interface{}) err
return nil
}

return err
return fmt.Errorf("deleting API Gateway Base Path Mapping (%s): %w", d.Id(), err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apigateway/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func resourceDeploymentUpdate(d *schema.ResourceData, meta interface{}) error {
PatchOperations: resourceDeploymentUpdateOperations(d),
})
if err != nil {
return err
return fmt.Errorf("updating API Gateway Deployment (%s): %w", d.Id(), err)
}

return resourceDeploymentRead(d, meta)
Expand Down
23 changes: 9 additions & 14 deletions internal/service/apigateway/documentation_part.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func resourceDocumentationPartCreate(d *schema.ResourceData, meta interface{}) e
RestApiId: aws.String(apiId),
})
if err != nil {
return err
return fmt.Errorf("reading API Gateway Documentation Part: %w", err)
}
d.SetId(apiId + "/" + *out.Id)
d.SetId(apiId + "/" + aws.StringValue(out.Id))

return nil
}
Expand All @@ -96,7 +96,7 @@ func resourceDocumentationPartRead(d *schema.ResourceData, meta interface{}) err

apiId, id, err := DecodeDocumentationPartID(d.Id())
if err != nil {
return err
return fmt.Errorf("reading API Gateway Documentation Part (%s): %w", d.Id(), err)
}

docPart, err := conn.GetDocumentationPart(&apigateway.GetDocumentationPartInput{
Expand All @@ -109,7 +109,7 @@ func resourceDocumentationPartRead(d *schema.ResourceData, meta interface{}) err
d.SetId("")
return nil
}
return fmt.Errorf("error reading API Gateway Documentation Part (%s): %w", d.Id(), err)
return fmt.Errorf("reading API Gateway Documentation Part (%s): %w", d.Id(), err)
}

d.Set("rest_api_id", apiId)
Expand All @@ -124,7 +124,7 @@ func resourceDocumentationPartUpdate(d *schema.ResourceData, meta interface{}) e

apiId, id, err := DecodeDocumentationPartID(d.Id())
if err != nil {
return err
return fmt.Errorf("updating API Gateway Documentation Part (%s): %w", d.Id(), err)
}

input := apigateway.UpdateDocumentationPartInput{
Expand All @@ -144,15 +144,10 @@ func resourceDocumentationPartUpdate(d *schema.ResourceData, meta interface{}) e

input.PatchOperations = operations

log.Printf("[INFO] Updating API Gateway Documentation Part: %s", input)

out, err := conn.UpdateDocumentationPart(&input)
if err != nil {
return err
if _, err := conn.UpdateDocumentationPart(&input); err != nil {
return fmt.Errorf("updating API Gateway Documentation Part (%s): %w", d.Id(), err)
}

log.Printf("[DEBUG] API Gateway Documentation Part updated: %s", out)

return resourceDocumentationPartRead(d, meta)
}

Expand All @@ -161,14 +156,14 @@ func resourceDocumentationPartDelete(d *schema.ResourceData, meta interface{}) e

apiId, id, err := DecodeDocumentationPartID(d.Id())
if err != nil {
return err
return fmt.Errorf("deleting API Gateway Documentation Part (%s): %w", d.Id(), err)
}

_, err = conn.DeleteDocumentationPart(&apigateway.DeleteDocumentationPartInput{
DocumentationPartId: aws.String(id),
RestApiId: aws.String(apiId),
})
return err
return fmt.Errorf("deleting API Gateway Documentation Part (%s): %w", d.Id(), err)
}

func expandDocumentationPartLocation(l []interface{}) *apigateway.DocumentationPartLocation {
Expand Down
11 changes: 7 additions & 4 deletions internal/service/apigateway/documentation_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func resourceDocumentationVersionRead(d *schema.ResourceData, meta interface{})

apiId, docVersion, err := DecodeDocumentationVersionID(d.Id())
if err != nil {
return err
return fmt.Errorf("reading API Gateway Documentation Version (%s): %w", d.Id(), err)
}

version, err := conn.GetDocumentationVersion(&apigateway.GetDocumentationVersionInput{
Expand All @@ -86,7 +86,7 @@ func resourceDocumentationVersionRead(d *schema.ResourceData, meta interface{})
d.SetId("")
return nil
}
return fmt.Errorf("error reading API Gateway Documentation Version (%s): %w", d.Id(), err)
return fmt.Errorf("reading API Gateway Documentation Version (%s): %w", d.Id(), err)
}

d.Set("rest_api_id", apiId)
Expand All @@ -112,7 +112,7 @@ func resourceDocumentationVersionUpdate(d *schema.ResourceData, meta interface{}
},
})
if err != nil {
return err
return fmt.Errorf("updating API Gateway Documentation Version (%s): %w", d.Id(), err)
}
log.Printf("[DEBUG] Updated API Gateway Documentation Version %s", d.Id())

Expand All @@ -127,7 +127,10 @@ func resourceDocumentationVersionDelete(d *schema.ResourceData, meta interface{}
DocumentationVersion: aws.String(d.Get("version").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
})
return err
if err != nil {
return fmt.Errorf("deleting API Gateway Documentation Version (%s): %w", d.Id(), err)
}
return nil
}

func DecodeDocumentationVersionID(id string) (string, string, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/apigateway/domain_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func resourceDomainNameUpdate(d *schema.ResourceData, meta interface{}) error {
})

if err != nil {
return err
return fmt.Errorf("updating API Gateway Domain Name (%s): %s", d.Id(), err)
}

return resourceDomainNameRead(d, meta)
Expand All @@ -425,7 +425,7 @@ func resourceDomainNameDelete(d *schema.ResourceData, meta interface{}) error {
}

if err != nil {
return fmt.Errorf("Error deleting API Gateway domain name: %s", err)
return fmt.Errorf("deleting API Gateway Domain Name (%s): %s", d.Id(), err)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion internal/service/apigateway/export_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func dataSourceExportRead(d *schema.ResourceData, meta interface{}) error {

export, err := conn.GetExport(input)
if err != nil {
return err
return fmt.Errorf("reading API Gateway Export: %w", err)
}

d.SetId(fmt.Sprintf("%s:%s", restApiId, stageName))
Expand Down
Loading