# Configure AWS Amplify

**URL:** <https://discourse.sst.dev/t/configure-aws-amplify/151>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151 "2018-05-09T20:16:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/1 "2018-05-09T20:16:16Z")

</div>

_From @jayair on Thu Mar 15 2018 19:38:04 GMT+0000 (UTC)_  
  
Link to chapter - [https://serverless-stack.com/chapters/configure-aws-amplify.html](https://serverless-stack.com/chapters/configure-aws-amplify.html)  
  
_Copied from original issue: [https://github.com/AnomalyInnovations/serverless-stack-com/issues/208](https://github.com/AnomalyInnovations/serverless-stack-com/issues/208)_

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/2 "2018-05-09T20:16:17Z")

</div>

_From @davidmsvetlecic on Tue Mar 20 2018 23:01:47 GMT+0000 (UTC)_  
  
fyi (in case anyone else had this problem): I was not able to upload a file to S3 due to permission error. Even though there was no difference in the policy, creating a new Cognito Identity Pool and it worked for me.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/3 "2018-05-09T20:16:18Z")

</div>

_From @viccooper142 on Thu Apr 05 2018 23:10:15 GMT+0000 (UTC)_  
  
Small typo: “The name: “notes” is basically telling Amplify that we want to name our API. Amplify allows you to add multiple APIs that **you** your app is going to work with. In our case our entire backend is just one single API.”

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/4 "2018-05-09T20:16:18Z")

</div>

_From @jayair on Fri Apr 06 2018 18:49:23 GMT+0000 (UTC)_  
  
@viccooper142 Thanks. Fixed.

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/5 "2018-05-09T20:16:18Z")

</div>

_From @ramnavan on Wed Apr 11 2018 15:45:21 GMT+0000 (UTC)_  
  
My question is behind the relationship between user pool and identity pool when performing signup and signin. Since signup and signin are primarily handled only my the Cognito User Pool, it confuses me why IdentityPoolId needs to be specified when configuring AWS Amplify? SignUp operation especially just creates user in the User Pool. What’s identity pool’s involvement here?

---

<div class="post-metadata">

**Author:** ![anomalyinnovations](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/anomalyinnovations/32/10_2.png) [@anomalyinnovations](https://discourse.sst.dev/u/anomalyinnovations)\
**Post date:** [May 9, 2018, 8:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/6 "2018-05-09T20:16:19Z")

</div>

_From @jayair on Wed Apr 11 2018 23:23:22 GMT+0000 (UTC)_  
  
@ramnavan I’m not sure if you had a chance to look at this chapter - [https://serverless-stack.com/chapters/cognito-user-pool-vs-identity-pool.html](https://serverless-stack.com/chapters/cognito-user-pool-vs-identity-pool.html)

But the Identity Pool uses the User Pool as an authentication provider and then secures access to the other AWS resources.

---

<div class="post-metadata">

**Author:** ![wrbm](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wrbm](https://discourse.sst.dev/u/wrbm)\
**Post date:** [May 24, 2018, 3:54am UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/7 "2018-05-24T03:54:33Z")

</div>

Im getting this error **Uncaught TypeError: Cannot read property ‘crypto’ of undefined** when importing Amplify from “aws-amplify”;

Has anyone seen this ?

---

<div class="post-metadata">

**Author:** ![wrbm](https://avatars.discourse-cdn.com/v4/letter/w/e0b2c6/32.png) [@wrbm](https://discourse.sst.dev/u/wrbm)\
**Post date:** [May 24, 2018, 5:15am UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/8 "2018-05-24T05:15:21Z")

</div>

Was able to solve it. If anyone else is having the same issue and using webpack. Just exclude node\_modules where you use babel-loader in webpack config file like this:  
_{ test: /.(js)$/, use: ‘babel-loader’, **exclude: /node\_modules/** }_

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [May 24, 2018, 7:06pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/9 "2018-05-24T19:06:38Z")

</div>

Thanks for reporting back.

Were you using a Webpack config on top of Create React App?

---

<div class="post-metadata">

**Author:** ![crjacinro](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/crjacinro/32/206_2.png) [@crjacinro](https://discourse.sst.dev/u/crjacinro)\
**Post date:** [August 11, 2018, 6:18pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/10 "2018-08-11T18:18:57Z")

</div>

How to protect the configuration files? I don’t want to expose my keys in a js file, where everyone can see in the source code. I am using angular 6 though in my project.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [August 15, 2018, 3:36pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/11 "2018-08-15T15:36:23Z")

</div>

These ids can be publicly visible. We are securing them on the backend with Cognito and IAM. This ensures that you need to be logged in to to your app to access these resources.

---

<div class="post-metadata">

**Author:** ![rstar2](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/rstar2/32/301_2.png) [@rstar2](https://discourse.sst.dev/u/rstar2)\
**Post date:** [October 31, 2018, 3:46pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/12 "2018-10-31T15:46:43Z")

</div>

But what prevents me(or anyother else) to get these ids and use them in my application, wouldn’t I be able to login/register using your UserPool and etc. and thus poluting this pool with contacts from different app.

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [November 5, 2018, 10:14pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/13 "2018-11-05T22:14:24Z")

</div>

These Id’s are meant to be available on the client side. So in theory somebody would be able to use these to sign up for your app through a different client. Of course that is pretty similar to just signing up for your app directly. I’ll need to check if there is a way to filter based on the source domain.

---

<div class="post-metadata">

**Author:** ![colemars](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/colemars/32/523_2.png) [@colemars](https://discourse.sst.dev/u/colemars)\
**Post date:** [August 18, 2019, 10:52pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/15 "2019-08-18T22:52:27Z")

</div>

Are you still of the opinion these Id’s can be exposed in a repo?

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [September 2, 2019, 3:43pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/16 "2019-09-02T15:43:08Z")

</div>

Oh yeah totally. There would be not other way to do this. And the authentication is what allows users to access these resources. The id’s on their own aren’t useful.

---

<div class="post-metadata">

**Author:** ![kpose](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@kpose](https://discourse.sst.dev/u/kpose)\
**Post date:** [February 6, 2020, 5:26am UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/17 "2020-02-06T05:26:48Z")

</div>

Hello, great tutorial here. I have a little difficulty. I am trying to build something similar but in react native using expo.

MY QUESTION: Why did you have to initialize AWS amplify in src/index.js? is it a convention? can i initialize it in App.js?  
Forgive me if the question sounds vague, trying to get a grasp of this

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [February 10, 2020, 7:16pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/18 "2020-02-10T19:16:52Z")

</div>

Hmm I guess you could since we aren’t really using it in `index.js`. But it’s mostly by convention that we are defining it there.

---

<div class="post-metadata">

**Author:** ![tkim](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@tkim](https://discourse.sst.dev/u/tkim)\
**Post date:** [June 1, 2020, 2:34am UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/19 "2020-06-01T02:34:18Z")

</div>

Hello, thanks for creating this guide, it’s probably the best and most comprehensive one I’ve seen! I really appreciate your work.

I’m having issues building React as soon as I import Amplify from ‘aws-amplify’.

**src/index.js**  
`import { Amplify } from 'aws-amplify';`

**Build error after runing `yarn start`:**  
Error in ./~/idb/build/cjs/index.js  
Module parse failed: /Users/tk/Google Drive/projects/amplify-notes-app/frontend/node\_modules/idb/build/cjs/index.js Unexpected token (58:25)  
You may need an appropriate loader to handle this file type.  
SyntaxError: Unexpected token (58:25)  
@ ./~/@aws-amplify/datastore/lib/storage/adapter/indexeddb.js 54:10-24

```
/Users/tk/Google Drive/projects/amplify-notes-app/frontend/node_modules/chokidar/lib/fsevents-handler.js:26
  return (new fsevents(path)).on('fsevent', callback).start();
      ^
TypeError: fsevents is not a constructor
at createFSEventsInstance (/Users/tk/Google Drive/projects/amplify-notes-app/frontend/node_modules/chokidar/lib/fsevents-handler.js:26:11)
at setFSEventsListener (/Users/tk/Google Drive/projects/amplify-notes-app/frontend/node_modules/chokidar/lib/fsevents-handler.js:80:16)
at FSWatcher.FsEventsHandler._watchWithFsEvents (/Users/tk/Google Drive/projects/amplify-notes-app/frontend/node_modules/chokidar/lib/fsevents-handler.js:244:16)
at FSWatcher.<anonymous> (/Users/tk/Google Drive/projects/amplify-notes-app/frontend/node_modules/chokidar/lib/fsevents-handler.js:378:25)
at LOOP (fs.js:1757:14)
at processTicksAndRejections (internal/process/task_queues.js:79:11)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

```

Seems like an issue with the `fsevents` module. I tried reinstalling fs events with the latest version manually and resetting my node\_modules (removing node\_modules/yarn-lock + reinstalling).

I’m using CRA for this.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![tkim](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@tkim](https://discourse.sst.dev/u/tkim)\
**Post date:** [June 1, 2020, 2:47am UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/20 "2020-06-01T02:47:27Z")

</div>

I got it working! Here’s what I did:

1. Cleaned yarn and npm cache (`yarn cache clean` + `npm cache clean --force`)
2. Upgraded react-scripts to version 3 with `yarn add react-scripts@3`
3. Changed Amplify as a default export (rather than a named export as the tutorial said), because react was complaining about it  
_ **From** _  
`import { Amplify } from 'aws-amplify'`  
_ **to** _  
`import Amplify from 'aws-amplify`

When I ran `yarn start` again it prompted me to “target the browser”, which added the following to package.json and it worked.

```
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
```

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [June 13, 2020, 10:26pm UTC](https://discourse.sst.dev/t/configure-aws-amplify/151/21 "2020-06-13T22:26:52Z")

</div>

That’s really weird. Glad that you figured it out.

Which version of AWS Amplify do you have in your package.json?

This is what we are using:

> <https://github.com/AnomalyInnovations/serverless-stack-demo-client/blob/master/package.json#L7>

And we import it using:

> <https://github.com/AnomalyInnovations/serverless-stack-demo-client/blob/master/src/index.js#L3>

[Next page](https://discourse.sst.dev/t/configure-aws-amplify/151.md?page=2)
