1

We have an existing AWS Amplify project with auth, api, storage, hosting etc. Works well. We now need to create a separate publicly accessible site using the same DynamoDB tables, GraphQL schema etc. without auth and with different hosting and storage resources. We have viewed a couple of similar questions on StackOverflow without any answers. Our best guess would be to copy over the Amplify config files and remove the non-api related config files and sections - but that seems like a hack if it works.

Is there any official way to attempt this?

GregHouse
  • 295
  • 1
  • 2
  • 15

1 Answers1

1

No, you are on the right track.

Manually pass in the resources that you want to overwrite, and generate new for everything else.

import { mergeDeepLeft } from 'ramda';
import Amplify from '@aws-amplify/core';
import config from './aws-exports';

const myAppConfig = {
    // ...
    'aws_appsync_graphqlEndpoint': 'https://xxxxxx.appsync-api.us-east-1.amazonaws.com/graphql',
    'aws_appsync_region': 'us-east-1',
    'aws_appsync_authenticationType': 'API_KEY',
    'aws_appsync_apiKey': 'da2-xxxxxxxxxxxxxxxxxxxxxxxxxx',
    // ...
}

Amplify.configure(mergeDeepLeft(myAppConfig, config));
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
  • Thank you. For the private site we are securing our API via Cognito User Pools so you must be authenticated to access the API. We've also added API key access as an alternative authentication mechanism on AppSync. Can we then access via the API key using the manual configuration in the public app? Second question - in May 2019 AppSync added support for multiple authentication mechanisms enforced via the schema via a directive like "@aws_api_key". Will Amplify be supporting this soon? – GregHouse Aug 02 '19 at 03:01