# Secure Our Serverless APIs

**URL:** <https://discourse.sst.dev/t/secure-our-serverless-apis/2467>\
**Category:** Chapter Comments\
**Created:** [August 26, 2021, 1:18am UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467 "2021-08-26T01:18:56Z")\
**Posts on this page:** 13\
**Page:** 1

<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 26, 2021, 1:18am UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/1 "2021-08-26T01:18:56Z")

</div>

Link to chapter — [https://serverless-stack.com/chapters/secure-our-serverless-apis.html](https://serverless-stack.com/chapters/secure-our-serverless-apis.html)

---

<div class="post-metadata">

**Author:** ![jeff-talley](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jeff-talley/32/1229_2.png) [@jeff-talley](https://discourse.sst.dev/u/jeff-talley)\
**Post date:** [October 3, 2021, 4:52pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/2 "2021-10-03T16:52:19Z")

</div>

How can I see a list of users that I have created in my Cognito User Pool?

I am following along with this guide and everything is working beautifully. I am about to start working on the React front end, but I wanted to see a list of users that I created based on this chapter and I cannot figure out how to do it.

I created the user shown in the guide for “[admin@example.com](mailto:admin@example.com)” and it worked fine. I then created another one for “[admin2@example.com](mailto:admin2@example.com)” and it worked as well. Now, I want to see a list of users that I have created, which should show these two.

However, everything I try just shows me my IAM user in Cognito (CLISST). I cannot find any command to run at the command line that would list these users, and when I login to my AWS account in a browser, I cannot find them there either. Strangely, my AWS account even says that I do not have any Cognito User Pools or Cognito Identity Pools, even though I successfully created both per this guide.

Now … I am totally confused by Discourse and have no idea if I am posting this question correctly or in the right place. Please tell me if I am doing any of this incorrectly.

Thanks in advance …

---

<div class="post-metadata">

**Author:** ![jeff-talley](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jeff-talley/32/1229_2.png) [@jeff-talley](https://discourse.sst.dev/u/jeff-talley)\
**Post date:** [October 3, 2021, 5:08pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/3 "2021-10-03T17:08:09Z")

</div>

Ok I figured out a command line that I can run to give me this list, but I still cannot figure out how to see all of this by logging into my AWS console for some reason.

Here is the command:

aws cognito-idp list-users --region [enter region here] --user-pool-id [enter user pool id here] --limit 20

---

<div class="post-metadata">

**Author:** ![VeryBaddude](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/verybaddude/32/1266_2.png) [@VeryBaddude](https://discourse.sst.dev/u/VeryBaddude)\
**Post date:** [January 9, 2022, 11:47pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/4 "2022-01-09T23:47:25Z")

</div>

When testing the code, I get the following back:

```auto
Authenticating with User Pool
Getting temporary credentials
Making API request
{
  status: 404,
  statusText: 'Not Found',
  data: { message: 'Not Found' }
}

```

I have finished each lesson up to that point with all tests working so I am at a loss as to why I get this result.

Thanks!

---

<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:** [January 10, 2022, 10:27pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/5 "2022-01-10T22:27:36Z")

</div>

Hmm this sounds like the API path is incorrect? Can you double check that?

---

<div class="post-metadata">

**Author:** ![johnrizzo4](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/johnrizzo4/32/1267_2.png) [@johnrizzo4](https://discourse.sst.dev/u/johnrizzo4)\
**Post date:** [January 10, 2022, 10:34pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/6 "2022-01-10T22:34:18Z")

</div>

Using the aws-api-gateway-cli-test with Windows (within Powershell, within VSCode), I’ve an exception.

From the book:

```auto
npx aws-api-gateway-cli-test --username admin@example.com --password Passw0rd! --user-pool-id USER_POOL_ID --app-client-id USER_POOL_CLIENT_ID --cognito-region COGNITO_REGION --identity-pool-id IDENTITY_POOL_ID --invoke-url API_ENDPOINT --api-gateway-region API_REGION --path-template /notes --method POST --body "{\"content\":\"hello world\",\"attachment\":\"hello.jpg\"}"

```

(with the correct values of my server, of course)

Error:

```auto
npx : 113 installé(s) en 22.981s
Authenticating with User Pool
Getting temporary credentials
Making API request
undefined:1
{\
 ^

SyntaxError: Unexpected token \ in JSON at position 1
    at JSON.parse (<anonymous>)
    at makeRequest (C:\Users\john\AppData\Roaming\npm-cache\_npx\17040\node_modules\aws-api-gateway-cli-test\index.js:179:17)
    at C:\Users\john\AppData\Roaming\npm-cache\_npx\17040\node_modules\aws-api-gateway-cli-test\index.js:152:5
    at C:\Users\john\AppData\Roaming\npm-cache\_npx\17040\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials.js:124:23
    at C:\Users\john\AppData\Roaming\npm-cache\_npx\17040\node_modules\aws-api-gateway-cli-test\node_modules\aws-sdk\lib\credentials.js:212:15
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

```

Or more concisely:

> SyntaxError: Unexpected token \ in JSON at position 1

It comes from the body string:

```auto
--body "{\"content\":\"hello world3\",\"attachment\":\"hello3.jpg\"}"

```

I’ve tried different versions such as:

```auto
--body "{'content':'hello world3','attachment':'hello3.jpg'}"

```

which triggers another error.

Any idea of a correct string?  
Many thanks.

---

<div class="post-metadata">

**Author:** ![VeryBaddude](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/verybaddude/32/1266_2.png) [@VeryBaddude](https://discourse.sst.dev/u/VeryBaddude)\
**Post date:** [January 10, 2022, 11:00pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/7 "2022-01-10T23:00:34Z")

</div>

Looks like I figured it out through trial and error - not sure why exactly, but it works if I use these two parameters like this:

```auto
--invoke-url='https://random.execute-api.us-east-1.amazonaws.com/' \
--path-template='notes' \

```

The --path-template that is in your instructions had a slash in front of the word “notes”. Moving that slash at the end of the --invoke-url made it work.

Hopefully this helps someone else.

Thanks!

---

<div class="post-metadata">

**Author:** ![wmbond](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/wmbond/32/1224_2.png) [@wmbond](https://discourse.sst.dev/u/wmbond)\
**Post date:** [February 25, 2022, 5:28am UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/8 "2022-02-25T05:28:05Z")

</div>

Going through the SST tutorial and successfully ran the **cognito-idp sign-up** and it created the user.

Ran **cognito-idp admin-confirm-sign-up** and it returned the error _An error occurred (UserNotFoundException) when calling the AdminConfirmSignUp operation: User does not exist._

Checked the account in AWS and the email has a comma appended to it. Edited the email in AWS and **cognito-idp admin-confirm-sign-up** correctly changed the state to Confirmed.

I cannot account for why the trailing comma is added to the account email when running **cognito-idp sign-up**

---

<div class="post-metadata">

**Author:** ![ceej](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@ceej](https://discourse.sst.dev/u/ceej)\
**Post date:** [May 3, 2022, 7:35pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/9 "2022-05-03T19:35:28Z")

</div>

I also had this issue on Windows, and I don’t have a real fix but I found a workaround.

I’m using VSCode and using their integrated terminal to run all of my command line stuff. In Windows, this terminal appears to default to PowerShell.

I switched the terminal to cmd and it worked.

---

<div class="post-metadata">

**Author:** ![Brandoxcode](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/brandoxcode/32/1444_2.png) [@Brandoxcode](https://discourse.sst.dev/u/Brandoxcode)\
**Post date:** [May 16, 2023, 2:22pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/10 "2023-05-16T14:22:30Z")

</div>

Hi guys Im having this error

NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).

I tried to upgraded all my @aws-sdk packages to the 3x version and it didnt work

---

<div class="post-metadata">

**Author:** ![LambdaBender](https://avatars.discourse-cdn.com/v4/letter/l/a183cd/32.png) [@LambdaBender](https://discourse.sst.dev/u/LambdaBender)\
**Post date:** [August 6, 2024, 10:50am UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/11 "2024-08-06T10:50:10Z")

</div>

Hi @jayair,

I am currently working through the SST intro notes tutorial.  
Thanks, for the nice introduction!

There are just two things, I struggled a bit so far:

- get all the command line stuff working.
- creating the AWS accounts could have been much easier

1. AWS Accounts  
It would have been great to see [Adam’s video about AWS federated accounts](https://www.proaws.dev/tips/the-best-way-to-access-your-aws-accounts-g7692) before starting. Spent a lot of time to set up Accounts and IAM users the wrong way before starting. Maybe link it in the first chapter, before it’s going into the weeds?

2. CLI Tools  
For the cli calls, it would be nice to have a .env file with all the necessary variables to be filled out during the tutorial.

.env:

```auto
API_ENDPOINT=https://YOUR-STACK-ID.execute-api.us-east-1.amazonaws.com
USER_POOL_CLIENT_ID=
IDENTITY_POOL_ID=
API_REGION=us-east-1
COGNITO_REGION=us-east-1
USER_POOL_ID=

STRIPE_SECRET_TEST_KEY=fill out
STRIPE_PUBLISHABLE_KEY=fill out

```

And then the CLI calls in little shell scripts, loading the .env file. E.g. 01\_test\_user\_signup.sh:

```bash
source .env

AWS_PROFILE=plain-dev-sst aws cognito-idp sign-up \
  --region ${COGNITO_REGION} \
  --client-id ${USER_POOL_CLIENT_ID} \
  --username admin@example.com \
  --password Passw0rd!

```

02\_test\_user\_admin\_confirm\_signup.sh:

```auto
source .env

AWS_PROFILE=plain-dev-sst aws cognito-idp admin-confirm-sign-up \
  --region ${COGNITO_REGION} \
  --user-pool-id ${USER_POOL_ID} \
  --username admin@example.com

```

This would reduce room for error.

I hope this thread isn’t some kind of /dev/null btw.

Thanks for considering, and thanks for the great framework so far!

Greets,  
Andreas

---

<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 8, 2024, 5:09pm UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/12 "2024-08-08T17:09:32Z")

</div>

Appreciate the feedback!

---

<div class="post-metadata">

**Author:** ![ericmasiello](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/ericmasiello/32/1439_2.png) [@ericmasiello](https://discourse.sst.dev/u/ericmasiello)\
**Post date:** [August 26, 2025, 11:26am UTC](https://discourse.sst.dev/t/secure-our-serverless-apis/2467/13 "2025-08-26T11:26:59Z")

</div>

I”m getting the same result.
