Change a public or private API endpoint type in API Gateway - Amazon API Gateway

Change a public or private API endpoint type in API Gateway

Changing an API endpoint type requires you to update the API's configuration. You can change an existing API type using the API Gateway console, the AWS CLI, or an AWS SDK for API Gateway. The endpoint type cannot be changed again until the current change is completed, but your API will be available.

The following endpoint type changes are supported:

  • From edge-optimized to Regional or private

  • From Regional to edge-optimized or private

  • From private to Regional

You cannot change a private API into an edge-optimized API.

If you are changing a public API from edge-optimized to Regional or vice versa, note that an edge-optimized API may have different behaviors than a Regional API. For example, an edge-optimized API removes the Content-MD5 header. Any MD5 hash value passed to the backend can be expressed in a request string parameter or a body property. However, the Regional API passes this header through, although it may remap the header name to some other name. Understanding the differences helps you decide how to update an edge-optimized API to a Regional one or from a Regional API to an edge-optimized one.

Use the API Gateway console to change an API endpoint type

To change the API endpoint type of your API, perform one of the following sets of steps:

To convert a public endpoint from Regional or edge-optimized and vice versa
  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

  2. Choose a REST API.

  3. Choose API settings.

  4. In the API details section, choose Edit.

  5. For API endpoint type, select either Edge-optimized or Regional.

  6. Choose Save changes.

  7. Redeploy your API so that the changes will take effect.

To convert a private endpoint to a Regional endpoint
  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

  2. Choose a REST API.

  3. Edit the resource policy for your API to remove any mention of VPCs or VPC endpoints so that API calls from outside your VPC as well as inside your VPC will succeed.

  4. Choose API settings.

  5. In the API details section, choose Edit.

  6. For API endpoint type, select Regional.

  7. Choose Save changes.

  8. Remove the resource policy from your API.

  9. Redeploy your API so that the changes will take effect.

To convert a Regional endpoint to a private endpoint
  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

  2. Choose a REST API.

  3. Create a resource policy that grants access to your VPC or VPC endpoint. For more information, see Set up a resource policy for a private API.

  4. Choose API settings.

  5. In the API details section, choose Edit.

  6. For API endpoint type, select Private.

  7. (Optional) For VPC endpoint IDs, select the VPC endpoint IDs that you want to associate with your private API.

  8. Choose Save changes.

  9. Redeploy your API so that the changes will take effect.

Use the AWS CLI to change an API endpoint type

To use the AWS CLI to update an edge-optimized API whose API ID is {api-id}, call update-rest-api as follows:

aws apigateway update-rest-api \ --rest-api-id {api-id} \ --patch-operations op=replace,path=/endpointConfiguration/types/EDGE,value=REGIONAL

The successful response has a status code of 200 OK and a payload similar to the following:

{ "createdDate": "2017-10-16T04:09:31Z", "description": "Your first API with Amazon API Gateway. This is a sample API that integrates via HTTP with our demo Pet Store endpoints", "endpointConfiguration": { "types": "REGIONAL" }, "id": "0gsnjtjck8", "name": "PetStore imported as edge-optimized" }

Conversely, update a regional API to an edge-optimized API as follows:

aws apigateway update-rest-api \ --rest-api-id {api-id} \ --patch-operations op=replace,path=/endpointConfiguration/types/REGIONAL,value=EDGE

Because put-rest-api is for updating API definitions, it is not applicable to updating an API endpoint type.