Page updated Jan 16, 2024

Use existing AWS resources

Existing Amazon API Gateway resources can be used with the Amplify Libraries by calling Amplify.configure() with the API Gateway API name and options. Note, you will need to supply the full resource configuration and library options objects when calling Amplify.configure(). The following example shows how to configure additional API Gateway resources to an existing Amplify application:

1import { Amplify } from 'aws-amplify';
2import amplifyconfig from './src/amplifyconfiguration.json';
3Amplify.configure(amplifyconfig):
4
5const existingConfig = Amplify.getConfig();
6
7// Add existing resource to the existing configuration.
8Amplify.configure({
9 ...existingConfig,
10 API: {
11 ...existingConfig.API,
12 REST: {
13 ...existingConfig.API?.REST,
14 YourAPIName: {
15 endpoint:
16 'https://abcdefghij1234567890.execute-api.us-east-1.amazonaws.com/stageName',
17 region: 'us-east-1' // Optional
18 }
19 }
20 }
21});
  • YourAPIName: Friendly name for the API
    • endpoint: The HTTPS endpoint of the API
    • region: AWS Region where the resources are provisioned. If not specified, the region will be inferred from the endpoint.

Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see Install Amplify Libraries.