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

resource/aws_api_gateway_method: Remove deprecated request_parameters_in_json argument #7701

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 19 additions & 44 deletions aws/resource_aws_api_gateway_method.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package aws

import (
"encoding/json"
"fmt"
"log"
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)

Expand Down Expand Up @@ -88,17 +85,15 @@ func resourceAwsApiGatewayMethod() *schema.Resource {
},

"request_parameters": {
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeBool},
Optional: true,
ConflictsWith: []string{"request_parameters_in_json"},
Type: schema.TypeMap,
Elem: &schema.Schema{Type: schema.TypeBool},
Optional: true,
},

"request_parameters_in_json": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"request_parameters"},
Deprecated: "Use field request_parameters instead",
Type: schema.TypeString,
Optional: true,
Removed: "Use `request_parameters` argument instead",
},

"request_validator_id": {
Expand Down Expand Up @@ -139,12 +134,6 @@ func resourceAwsApiGatewayMethodCreate(d *schema.ResourceData, meta interface{})
}
input.RequestParameters = aws.BoolMap(parameters)
}
if v, ok := d.GetOk("request_parameters_in_json"); ok {
if err := json.Unmarshal([]byte(v.(string)), &parameters); err != nil {
return fmt.Errorf("Error unmarshaling request_parameters_in_json: %s", err)
}
input.RequestParameters = aws.BoolMap(parameters)
}

if v, ok := d.GetOk("authorizer_id"); ok {
input.AuthorizerId = aws.String(v.(string))
Expand Down Expand Up @@ -201,16 +190,8 @@ func resourceAwsApiGatewayMethodRead(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("error setting request_models: %s", err)
}

// KNOWN ISSUE: This next d.Set() is broken as it should be a JSON string of the map,
// however leaving as-is since this attribute has been deprecated
// for a very long time and will be removed soon in the next major release.
// Not worth the effort of fixing, acceptance testing, and potential JSON equivalence bugs.
if _, ok := d.GetOk("request_parameters_in_json"); ok {
d.Set("request_parameters_in_json", aws.BoolValueMap(out.RequestParameters))
}

if err := d.Set("request_parameters", aws.BoolValueMap(out.RequestParameters)); err != nil {
return fmt.Errorf("error setting request_models: %s", err)
return fmt.Errorf("error setting request_parameters: %s", err)
}

d.Set("request_validator_id", out.RequestValidatorId)
Expand Down Expand Up @@ -346,25 +327,19 @@ func resourceAwsApiGatewayMethodDelete(d *schema.ResourceData, meta interface{})
conn := meta.(*AWSClient).apigateway
log.Printf("[DEBUG] Deleting API Gateway Method: %s", d.Id())

return resource.Retry(5*time.Minute, func() *resource.RetryError {
_, err := conn.DeleteMethod(&apigateway.DeleteMethodInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
})
if err == nil {
return nil
}
_, err := conn.DeleteMethod(&apigateway.DeleteMethodInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
})

apigatewayErr, ok := err.(awserr.Error)
if apigatewayErr.Code() == "NotFoundException" {
return nil
}
if isAWSErr(err, apigateway.ErrCodeNotFoundException, "") {
return nil
}

if !ok {
return resource.NonRetryableError(err)
}
if err != nil {
return fmt.Errorf("error deleting API Gateway Method (%s): %s", d.Id(), err)
}

return resource.NonRetryableError(err)
})
return nil
}
1 change: 0 additions & 1 deletion website/docs/r/api_gateway_method.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ The following arguments are supported:
* `request_validator_id` - (Optional) The ID of a `aws_api_gateway_request_validator`
* `request_parameters` - (Optional) A map of request query string parameters and headers that should be passed to the integration.
For example: `request_parameters = {"method.request.header.X-Some-Header" = true "method.request.querystring.some-query-param" = true}` would define that the header `X-Some-Header` and the query string `some-query-param` must be provided in the request
* `request_parameters_in_json` - **Deprecated**, use `request_parameters` instead.

## Import

Expand Down