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

Adds support for PRIVATE endpoint type for aws_api_gateway_rest_api #4888

Merged
merged 2 commits into from
Jun 20, 2018
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
1 change: 1 addition & 0 deletions aws/resource_aws_api_gateway_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func resourceAwsApiGatewayRestApi() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
apigateway.EndpointTypeEdge,
apigateway.EndpointTypeRegional,
apigateway.EndpointTypePrivate,
}, false),
},
},
Expand Down
18 changes: 18 additions & 0 deletions aws/resource_aws_api_gateway_rest_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,24 @@ func TestAccAWSAPIGatewayRestApi_EndpointConfiguration(t *testing.T) {
},
},
})

resource.Test(t, resource.TestCase{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally prefer to create whole new top level acceptance test functions instead of adding multiple resource.Test() within the same function -- this allows us to parallelize our testing better. 😄

Another complicated piece to our API Gateway testing here is that we run the service testing across multiple AWS partitions (Commercial and GovCloud (US)), which the latter may or may not support the new PRIVATE REST API endpoint type. If you look at the TestStep above your addition here, we have a PreConfig function that ensures the AWS API Gateway service its calling supports the EDGE endpoint type or skips the rest of the test. We'll want to add something similar for PRIVATE as well.

Do not be discouraged here though! There just happens to be more advanced testing handling with this resource testing than other parts of our resource testing. You actually were on the right track except the tweaks mentioned above, which I can handle in a commit after yours to expedite releasing this enhancement for everyone. 👍

Copy link
Author

@edsonmarquezani edsonmarquezani Jun 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I get it. I just didn't know private type might not be supported in some regions.

As for the remaing, I understand you're going to make the adjustments yourself, right? Anyway, feel free to ask for it, if you want to. I think I could handle it. ;)

PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAPIGatewayRestAPIDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAPIGatewayRestAPIConfig_EndpointConfiguration(rName, "PRIVATE"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAPIGatewayRestAPIExists("aws_api_gateway_rest_api.test", &restApi),
resource.TestCheckResourceAttr("aws_api_gateway_rest_api.test", "endpoint_configuration.#", "1"),
resource.TestCheckResourceAttr("aws_api_gateway_rest_api.test", "endpoint_configuration.0.types.#", "1"),
resource.TestCheckResourceAttr("aws_api_gateway_rest_api.test", "endpoint_configuration.0.types.0", "PRIVATE"),
),
},
},
})

}

func TestAccAWSAPIGatewayRestApi_api_key_source(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/api_gateway_rest_api.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ __Note__: If the `body` argument is provided, the OpenAPI specification will be

### endpoint_configuration

* `types` - (Required) A list of endpoint types. This resource currently only supports managing a single value. Valid values: `EDGE` or `REGIONAL`. If unspecified, defaults to `EDGE`. Must be declared as `REGIONAL` in non-Commercial partitions. Refer to the [documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/create-regional-api.html) for more information on the difference between edge-optimized and regional APIs.
* `types` - (Required) A list of endpoint types. This resource currently only supports managing a single value. Valid values: `EDGE`, `REGIONAL` or `PRIVATE`. If unspecified, defaults to `EDGE`. Must be declared as `REGIONAL` in non-Commercial partitions. Refer to the [documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/create-regional-api.html) for more information on the difference between edge-optimized and regional APIs.

## Attributes Reference

Expand Down