diff --git a/builtin/providers/aws/resource_aws_api_gateway_integration.go b/builtin/providers/aws/resource_aws_api_gateway_integration.go index 2cb0c9818..c745ef3b6 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_integration.go +++ b/builtin/providers/aws/resource_aws_api_gateway_integration.go @@ -75,9 +75,18 @@ func resourceAwsApiGatewayIntegration() *schema.Resource { Elem: schema.TypeString, }, + "request_parameters": &schema.Schema{ + Type: schema.TypeMap, + Elem: schema.TypeString, + Optional: true, + ConflictsWith: []string{"request_parameters_in_json"}, + }, + "request_parameters_in_json": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"request_parameters"}, + Deprecated: "Use field request_parameters instead", }, "passthrough_behavior": &schema.Schema{ @@ -107,6 +116,12 @@ func resourceAwsApiGatewayIntegrationCreate(d *schema.ResourceData, meta interfa } parameters := make(map[string]string) + if kv, ok := d.GetOk("request_parameters"); ok { + for k, v := range kv.(map[string]interface{}) { + parameters[k] = v.(string) + } + } + if v, ok := d.GetOk("request_parameters_in_json"); ok { if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil { return fmt.Errorf("Error unmarshaling request_parameters_in_json: %s", err) @@ -129,8 +144,7 @@ func resourceAwsApiGatewayIntegrationCreate(d *schema.ResourceData, meta interfa RestApiId: aws.String(d.Get("rest_api_id").(string)), Type: aws.String(d.Get("type").(string)), IntegrationHttpMethod: integrationHttpMethod, - Uri: uri, - // TODO reimplement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented + Uri: uri, RequestParameters: aws.StringMap(parameters), RequestTemplates: aws.StringMap(templates), Credentials: credentials, @@ -175,6 +189,7 @@ func resourceAwsApiGatewayIntegrationRead(d *schema.ResourceData, meta interface d.Set("credentials", integration.Credentials) d.Set("type", integration.Type) d.Set("uri", integration.Uri) + d.Set("request_parameters", aws.StringValueMap(integration.RequestParameters)) d.Set("request_parameters_in_json", aws.StringValueMap(integration.RequestParameters)) d.Set("passthrough_behavior", integration.PassthroughBehavior) diff --git a/builtin/providers/aws/resource_aws_api_gateway_integration_response.go b/builtin/providers/aws/resource_aws_api_gateway_integration_response.go index e5f17abd7..c507b3473 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_integration_response.go +++ b/builtin/providers/aws/resource_aws_api_gateway_integration_response.go @@ -56,9 +56,18 @@ func resourceAwsApiGatewayIntegrationResponse() *schema.Resource { Elem: schema.TypeString, }, + "response_parameters": &schema.Schema{ + Type: schema.TypeMap, + Elem: schema.TypeString, + Optional: true, + ConflictsWith: []string{"response_parameters_in_json"}, + }, + "response_parameters_in_json": &schema.Schema{ - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"response_parameters"}, + Deprecated: "Use field response_parameters instead", }, }, } @@ -73,6 +82,11 @@ func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta } parameters := make(map[string]string) + if kv, ok := d.GetOk("response_parameters"); ok { + for k, v := range kv.(map[string]interface{}) { + parameters[k] = v.(string) + } + } if v, ok := d.GetOk("response_parameters_in_json"); ok { if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil { return fmt.Errorf("Error unmarshaling response_parameters_in_json: %s", err) @@ -80,12 +94,11 @@ func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta } input := apigateway.PutIntegrationResponseInput{ - 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)), - StatusCode: aws.String(d.Get("status_code").(string)), - ResponseTemplates: aws.StringMap(templates), - // TODO reimplement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented + 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)), + StatusCode: aws.String(d.Get("status_code").(string)), + ResponseTemplates: aws.StringMap(templates), ResponseParameters: aws.StringMap(parameters), } if v, ok := d.GetOk("selection_pattern"); ok { @@ -125,6 +138,7 @@ func resourceAwsApiGatewayIntegrationResponseRead(d *schema.ResourceData, meta i d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string))) d.Set("response_templates", integrationResponse.ResponseTemplates) d.Set("selection_pattern", integrationResponse.SelectionPattern) + d.Set("response_parameters", aws.StringValueMap(integrationResponse.ResponseParameters)) d.Set("response_parameters_in_json", aws.StringValueMap(integrationResponse.ResponseParameters)) return nil } diff --git a/builtin/providers/aws/resource_aws_api_gateway_integration_response_test.go b/builtin/providers/aws/resource_aws_api_gateway_integration_response_test.go index 7220bef17..aba246730 100644 --- a/builtin/providers/aws/resource_aws_api_gateway_integration_response_test.go +++ b/builtin/providers/aws/resource_aws_api_gateway_integration_response_test.go @@ -185,11 +185,9 @@ resource "aws_api_gateway_method_response" "error" { "application/json" = "Error" } - response_parameters_in_json = <