Configure Amplify categories

This guide is for those using the previous version of the Amplify libraries. You can also review the updated guide for configuring Amplify categories for the most recent version.

When using the Amplify CLI, the aws-exports.js file gets created and updated automatically for you based upon the resources you have added and configured.

If you are not using the Amplify CLI or need to override these settings, this documentation shows the available configuration properties for each category.

General configuration

The Amplify.configure() configuration can generally be included in your project entrypoint file (i.e. /src/main.js).

1Amplify.configure({
2 aws_project_region: 'us-east-1' // (optional) Default region for project
3});

Authentication (Amazon Cognito)

Top level configuration

1Amplify.configure({
2 aws_cognito_region: 'us-east-1', // (required) - Region where Amazon Cognito project was created
3 aws_user_pools_id: 'us-east-1_6AfQ6', // (optional) - Amazon Cognito User Pool ID
4 aws_user_pools_web_client_id: '5t3le8878kgc72', // (optional) - Amazon Cognito App Client ID (App client secret needs to be disabled)
5 aws_cognito_identity_pool_id:
6 'us-east-1:f602c14b-0fde-409c-9a7e-0baccbfd87d0', // (optional) - Amazon Cognito Identity Pool ID
7 aws_mandatory_sign_in: 'enable' // (optional) - Users are not allowed to get the aws credentials unless they are signed in
8});

Scoped configuration

1Amplify.configure({
2 Auth: {
3 // (required) only for Federated Authentication - Amazon Cognito Identity Pool ID
4 identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',
5
6 // (required)- Amazon Cognito Region
7 region: 'XX-XXXX-X',
8
9 // (optional) - Amazon Cognito Federated Identity Pool Region
10 // Required only if it's different from Amazon Cognito Region
11 identityPoolRegion: 'XX-XXXX-X',
12
13 // (optional) - Amazon Cognito User Pool ID
14 userPoolId: 'XX-XXXX-X_abcd1234',
15
16 // (optional) - Amazon Cognito Web Client ID (26-char alphanumeric string, App client secret needs to be disabled)
17 userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3',
18
19 // (optional) - Enforce user authentication prior to accessing AWS resources or not
20 mandatorySignIn: false,
21
22 // (optional) - Configuration for cookie storage
23 // Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol
24 cookieStorage: {
25 // - Cookie domain (only required if cookieStorage is provided)
26 domain: '.yourdomain.com',
27 // (optional) - Cookie path
28 path: '/',
29 // (optional) - Cookie expiration in days
30 expires: 365,
31 // (optional) - See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
32 sameSite: 'strict' | 'lax',
33 // (optional) - Cookie secure flag
34 // Either true or false, indicating if the cookie transmission requires a secure protocol (https).
35 secure: true
36 },
37
38 // (optional) - customized storage object
39 storage: MyStorage,
40
41 // (optional) - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'
42 authenticationFlowType: 'USER_PASSWORD_AUTH',
43
44 // (optional) - Manually set key value pairs that can be passed to Cognito Lambda Triggers
45 clientMetadata: { myCustomKey: 'myCustomValue' },
46
47 // (optional) - Hosted UI configuration
48 oauth: {
49 domain: 'your_cognito_domain',
50 scope: [
51 'phone',
52 'email',
53 'profile',
54 'openid',
55 'aws.cognito.signin.user.admin'
56 ],
57 redirectSignIn: 'http://localhost:3000/',
58 redirectSignOut: 'http://localhost:3000/',
59 clientId: '1g0nnr4h99a3sd0vfs9',
60 responseType: 'code' // or 'token', note that REFRESH token will only be generated when the responseType is code
61 }
62 }
63});

Storage (Amazon S3)

Top level configuration

1Amplify.configure({
2 aws_user_files_s3_bucket_region: 'us-east-1', // (required) - Amazon S3 bucket region
3 aws_user_files_s3_bucket: 'testappa321fb103f1f2ae6a4d25d8cd2161728123152-dev' // (required) - Amazon S3 bucket URI
4});

Scoped configuration - Storage

1Amplify.configure({
2 Auth: {
3 identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', // (required) - Amazon Cognito Identity Pool ID
4 region: 'XX-XXXX-X', // (required) - Amazon Cognito Region
5 userPoolId: 'XX-XXXX-X_abcd1234', // (optional) - Amazon Cognito User Pool ID
6 userPoolWebClientId: 'XX-XXXX-X_abcd1234' // (optional) - Amazon Cognito Web Client ID (App client secret needs to be disabled)
7 },
8 Storage: {
9 AWSS3: {
10 bucket: 'testappa321fb906f7f4ae6a4d25d8cd2134338123152-dev', // (required) - Amazon S3 bucket name
11 region: 'us-east-1' // (optional) - Amazon service region
12 }
13 }
14});

GraphQL API (AWS AppSync)

Top level configuration

1Amplify.configure({
2 aws_appsync_region: 'us-east-1', // (optional) - AWS AppSync region
3 aws_appsync_graphqlEndpoint:
4 'https://<app-id>.appsync-api.<region>.amazonaws.com/graphql', // (optional) - AWS AppSync endpoint
5 aws_appsync_authenticationType: 'AMAZON_COGNITO_USER_POOLS', // (optional) - Primary AWS AppSync authentication type
6 graphql_endpoint: 'https://www.yourdomain.com/graphql', // (optional) - Custom GraphQL endpoint
7 aws_appsync_apiKey: 'da2-xxxxxxxxxxxxxxxxxxxxxxxxxx', // (optional) - AWS AppSync API Key
8 graphql_endpoint_iam_region: 'us-east-1' // (optional) - Custom IAM region
9});
10
11// Authentication type options are API_KEY, AWS_IAM, AMAZON_COGNITO_USER_POOLS and OPENID_CONNECT

Scoped configuration - GraphQL API

1Amplify.configure({
2 API: {
3 graphql_endpoint: 'https:/www.example.com/my-graphql-endpoint',
4 graphql_headers: async () => ({
5 'My-Custom-Header': 'my value' // Set Custom Request Headers for non-AppSync GraphQL APIs
6 })
7 }
8});

REST API (Amazon API Gateway)

1Amplify.configure({
2 aws_cloud_logic_custom: [
3 {
4 name: 'your-api-name', // (required) - API Name (This name is used used in the client app to identify the API - API.get('your-api-name', '/path'))
5 endpoint: 'https://gfz59k9rlj.execute-api.us-east-1.amazonaws.com/dev', // (required) -API Gateway URL + environment
6 region: 'us-east-1' // (required) - API Gateway region
7 }
8 ]
9});

Predictions

Top level configuration

1Amplify.configure({
2 Auth: {
3 identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx', // (required) - Amazon Cognito Identity Pool ID
4 region: 'us-east-1' // (required)- Amazon Cognito Region
5 },
6 predictions: {
7 convert: {
8 translateText: {
9 region: 'us-east-1',
10 proxy: false,
11 defaults: {
12 sourceLanguage: 'en',
13 targetLanguage: 'zh'
14 }
15 },
16 speechGenerator: {
17 region: 'us-east-1',
18 proxy: false,
19 defaults: {
20 VoiceId: 'Ivy',
21 LanguageCode: 'en-US'
22 }
23 },
24 transcription: {
25 region: 'us-east-1',
26 proxy: false,
27 defaults: {
28 language: 'en-US'
29 }
30 }
31 },
32 identify: {
33 identifyText: {
34 proxy: false,
35 region: 'us-east-1',
36 defaults: {
37 format: 'PLAIN'
38 }
39 },
40 identifyEntities: {
41 proxy: false,
42 region: 'us-east-1',
43 celebrityDetectionEnabled: true,
44 defaults: {
45 collectionId: 'identifyEntities8b89c648-test',
46 maxEntities: 50
47 }
48 },
49 identifyLabels: {
50 proxy: false,
51 region: 'us-east-1',
52 defaults: {
53 type: 'LABELS'
54 }
55 }
56 },
57 interpret: {
58 interpretText: {
59 region: 'us-east-1',
60 proxy: false,
61 defaults: {
62 type: 'ALL'
63 }
64 }
65 }
66 }
67});

Analytics (Amazon Pinpoint)

Top level configuration

1Amplify.configure({
2 aws_mobile_analytics_app_region: 'us-east-1', // (required) Amazon Pinpoint Project region
3 aws_mobile_analytics_app_id: '34876218b9df404a847857a94a0e7e9f' // (required) Amazon Pinpoint Project ID
4});

Scoped configuration Analytics

1Amplify.configure({
2 Analytics: {
3 // - disable Analytics if true
4 disabled: false,
5 // (optional) - Allow recording session events. Default is true.
6 autoSessionRecord: true,
7
8 AWSPinpoint: {
9 // (optional) - Amazon Pinpoint App Client ID
10 appId: 'XXXXXXXXXXabcdefghij1234567890ab',
11 // (optional) - Amazon service region
12 region: 'XX-XXXX-X',
13 // (optional) - Customized endpoint
14 endpointId: 'XXXXXXXXXXXX',
15 // (optional) - Default Endpoint Information
16 endpoint: {
17 address: 'xxxxxxx', // The unique identifier for the recipient. For example, an address could be a device token, email address, or mobile phone number.
18 attributes: {
19 // Custom attributes that your app reports to Amazon Pinpoint. You can use these attributes as selection criteria when you create a segment.
20 hobbies: ['piano', 'hiking']
21 },
22 channelType: 'APNS', // The channel type. Valid values: APNS, GCM
23 demographic: {
24 appVersion: 'xxxxxxx', // The version of the application associated with the endpoint.
25 locale: 'xxxxxx', // The endpoint locale in the following format: The ISO 639-1 alpha-2 code, followed by an underscore, followed by an ISO 3166-1 alpha-2 value
26 make: 'xxxxxx', // The manufacturer of the endpoint device, such as Apple or Samsung.
27 model: 'xxxxxx', // The model name or number of the endpoint device, such as iPhone.
28 modelVersion: 'xxxxxx', // The model version of the endpoint device.
29 platform: 'xxxxxx', // The platform of the endpoint device, such as iOS or Android.
30 platformVersion: 'xxxxxx', // The platform version of the endpoint device.
31 timezone: 'xxxxxx' // The timezone of the endpoint. Specified as a tz database value, such as Americas/Los_Angeles.
32 },
33 location: {
34 city: 'xxxxxx', // The city where the endpoint is located.
35 country: 'xxxxxx', // The two-letter code for the country or region of the endpoint. Specified as an ISO 3166-1 alpha-2 code, such as "US" for the United States.
36 latitude: 0, // The latitude of the endpoint location, rounded to one decimal place.
37 longitude: 0, // The longitude of the endpoint location, rounded to one decimal place.
38 postalCode: 'xxxxxx', // The postal code or zip code of the endpoint.
39 region: 'xxxxxx' // The region of the endpoint location. For example, in the United States, this corresponds to a state.
40 },
41 metrics: {
42 // Custom metrics that your app reports to Amazon Pinpoint.
43 },
44 /** Indicates whether a user has opted out of receiving messages with one of the following values:
45 * ALL - User has opted out of all messages.
46 * NONE - Users has not opted out and receives all messages.
47 */
48 optOut: 'ALL',
49 // Customized userId
50 userId: 'XXXXXXXXXXXX',
51 // User attributes
52 userAttributes: {
53 interests: ['football', 'basketball', 'AWS']
54 // ...
55 }
56 },
57
58 // Buffer settings used for reporting analytics events.
59 // (optional) - The buffer size for events in number of items.
60 bufferSize: 1000,
61
62 // (optional) - The interval in milliseconds to perform a buffer check and flush if necessary.
63 flushInterval: 5000, // 5s
64
65 // (optional) - The number of events to be deleted from the buffer when flushed.
66 flushSize: 100,
67
68 // (optional) - The limit for failed recording retries.
69 resendLimit: 5
70 }
71 }
72});

Geo

Top level configuration

1Amplify.configure({
2 Auth: {
3 identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab', // REQUIRED - Amazon Cognito Identity Pool ID
4 region: 'XX-XXXX-X', // REQUIRED - Amazon Cognito Region
5 userPoolId: 'XX-XXXX-X_abcd1234', // OPTIONAL - Amazon Cognito User Pool ID for authenticated user access
6 userPoolWebClientId: 'XX-XXXX-X_abcd1234' // OPTIONAL - Amazon Cognito Web Client ID for authenticated user access
7 },
8 geo: {
9 AmazonLocationService: {
10 maps: {
11 items: {
12 XXXXXXXXXXX: {
13 // REQUIRED - Amazon Location Service Map resource name
14 style: 'VectorEsriStreets' // REQUIRED - String representing the style of map resource
15 }
16 },
17 default: 'XXXXXXXXXXX' // REQUIRED - Amazon Location Service Map resource name to set as default
18 },
19 search_indices: {
20 items: ['XXXXXXXXX'], // REQUIRED - Amazon Location Service Place Index name
21 default: 'XXXXXXXXX' // REQUIRED - Amazon Location Service Place Index name to set as default
22 },
23 region: 'XX-XXXX-X' // REQUIRED - Amazon Location Service Region
24 }
25 }
26});

Interactions

Top level configuration

1Amplify.configure({
2 Auth: {
3 identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx', // (required) Identity Pool ID
4 region: 'us-east-1' // (required) Identity Pool region
5 },
6 Interactions: {
7 bots: {
8 BookTrip: {
9 name: 'BookTrip',
10 alias: '$LATEST',
11 region: 'us-east-1'
12 }
13 }
14 }
15});