Amplify-cli: Connect React Native App to Existing Amplify Back-end Infrastructure

Created on 7 Feb 2020  路  5Comments  路  Source: aws-amplify/amplify-cli

Amplify CLI Version
4.13.1

What AWS Services are you utilizing?
Auth, API, Lambda, DynamoDB, and S3

Details:
I've build a React web application, using Amplify CLI to provision Authentication (via a Cognito user pool), REST API, Lambda functions, DynamoDB, and S3 storage.

This all works nicely. Thanks for making Amplify! 馃尞 <= here's a taco

Now I'm starting on a React Native (Expo) version of the app, and I'd like to access the existing back-end infrastructure (see above services) that has been created for the web-app.

Note that the dev-environment infrastructure has been provisioned using Amplify CLI, and the prod-environment infrastructure gets provisioned by Amplify Console via a connected repo.

I guess that I could start fiddling with using IAM roles, but I'm hoping there's a better way.

Question
What's the easiest/most-straight-forward way to configure and initialize the new React Native project so that I can access both the dev and prod back-end?

multienv platform question

Most helpful comment

All 5 comments

For the record, I have read this, but it's not really documentation on how to do the voodoo that I want to do.

@andrestone thanks for the links.

Unfortunately, I've done something stupid here, as running amplify pull in the new React Native directory results in the error:

Cannot find any backend environment in the Amplify Console App mycoolapp
Failed to pull the backend

I think this has to do with the way I've created/deployed things (summarized here in bottom picture).

In brief:

  • the app was initialized (with Amplify CLI), and all the backend-infrastructure has been provisioned in an env called "dev"
  • the production app gets built and deployed when things are pushed to a repo. This env is called prod.

I'm thinking that I might need import a backend env as shown here from Amplify Console, but I'm uncertain.

And that uncertainty is really the reason for my initial question.

@kimfucious Did you try the amplify env import command?

Hi @kaustavghosh06

I did, but I wound up doing something dumb. See here #3381.

However, it was kind of a good thing, because now I have my back-end up in AWS Console (which I didn't before), so I could use amplify pull to pull the back-end created for my React app to the directory where I'm developing the React Native App, allowing me to use a single back-end for both, which is pretty awesome! 馃尞 !

Was this page helpful?
0 / 5 - 0 ratings