Skip to content

Commit d686a5c

Browse files
committed
Merge branch 'issue-7004.aws_api_gateway_v2_integration' into issue-7004.aws_api_gateway_v2_stage
2 parents c95361e + 1dac073 commit d686a5c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

aws/resource_aws_api_gateway2_integration.go

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func resourceAwsApiGateway2Integration() *schema.Resource {
2020
Importer: &schema.ResourceImporter{
2121
State: resourceAwsApiGateway2IntegrationImport,
2222
},
23+
CustomizeDiff: resourceAwsApiGateway2IntegrationCustomizeDiff,
2324

2425
Schema: map[string]*schema.Schema{
2526
"api_id": {
@@ -279,3 +280,20 @@ func resourceAwsApiGateway2IntegrationImport(d *schema.ResourceData, meta interf
279280

280281
return []*schema.ResourceData{d}, nil
281282
}
283+
284+
func resourceAwsApiGateway2IntegrationCustomizeDiff(diff *schema.ResourceDiff, meta interface{}) error {
285+
if diff.Id() == "" {
286+
// New resource.
287+
integrationMethod := diff.Get("integration_method").(string)
288+
integrationType := diff.Get("integration_type").(string)
289+
if integrationType == apigatewayv2.IntegrationTypeMock {
290+
if integrationMethod != "" {
291+
return fmt.Errorf("'integration_method' must not be set when 'integration_type' is '%s'", integrationType)
292+
}
293+
} else if integrationMethod == "" {
294+
return fmt.Errorf("'integration_method' must be set when 'integration_type' is '%s'", integrationType)
295+
}
296+
}
297+
298+
return nil
299+
}

website/docs/r/api_gateway_v2_integration.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Valid values: `AWS`, `AWS_PROXY`, `HTTP`, `HTTP_PROXY`, `MOCK`.
5858
* `content_handling_strategy` - (Optional) How to handle response payload content type conversions. Valid values: `CONVERT_TO_BINARY`, `CONVERT_TO_TEXT`.
5959
* `credentials_arn` - (Optional) The credentials required for the integration, if any.
6060
* `description` - (Optional) The description of the integration.
61-
* `integration_method` - (Optional) The integration's HTTP method.
61+
* `integration_method` - (Optional) The integration's HTTP method. Must be specified if `integration_type` is not `MOCK`.
6262
* `integration_uri` - (Optional) The URI of the Lambda function for a Lambda proxy integration, where `integration_type` is `AWS_PROXY`.
6363
* `passthrough_behavior` - (Optional) The pass-through behavior for incoming requests based on the Content-Type header in the request, and the available mapping templates specified as the `request_templates` attribute. Valid values: `WHEN_NO_MATCH`, `WHEN_NO_TEMPLATES`, `NEVER`. Default is `WHEN_NO_MATCH`.
6464
* `request_templates` - (Optional) A map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client.

0 commit comments

Comments
 (0)