John Jerald De Chavez

AWS Cheatsheet

My personal cheatsheet on AWS or common I used on cli

CLI

Getting tired opening new tab for commands. So, I decided to collect the common commands on AWS CLI.

List Users

aws cognito-idp list-users --profile your-aws-profile --region us-east-1 --user-pool-id us-east-1_your-pool-id

List Users with Filters

aws cognito-idp list-users --profile your-aws-profile --region us-east-1 --user-pool-id us-east-1_your-pool-id --filter 'cognito:user_status = "FORCE_CHANGE_PASSWORD"

Get User

aws cognito-idp admin-get-user --profile your-aws-profile --region us-east-1 --user-pool-id us-east-1_your-pool-id --username johndoe@mail.com

Resend temporary Password

aws cognito-idp admin-create-user --profile your-aws-profile --region us-east-1 --user-pool-id us-east-1_your-pool-id --username johndoe@mail.com --message-action RESEND

Signup User with email and password

aws cognito-idp sign-up --profile your-aws-profile --region us-east-1 --client-id us-east-1_your-pool-id --username admin@example.com --password Passw0rd!

Verify Email

aws cognito-idp admin-confirm-sign-up --profile your-aws-profile --region us-east-1 --user-pool-id your-user-pool-id --username admin@example.com

Definitions

Refresher for definations of AWS services.

Cognito User Pool

To manage sign up and login functionality for our users, we’ll be using an AWS service called, Amazon Cognito User Pool. It’ll store our user’s login info. It’ll also be managing user sessions in our React app.

Cognito Indentity Pool

To manage access control to our AWS infrastructure we use another service called Amazon Cognito Identity Pools. This service decides if our previously authenticated user has access to the resources he/she is trying to connect to. Identity Pools can have different authentication providers (like Cognito User Pools, Facebook, Google etc.). In our case, our Identity Pool will be connected to our User Pool.

Understanding CORS

There are two things we need to do to support CORS in our serverless API.

Preflight OPTIONS requests: For certain types of cross-domain requests (PUT, DELETE, ones with Authentication headers, etc.), your browser will first make a preflight request using the request method OPTIONS. These need to respond with the domains that are allowed to access this API and the HTTP methods that are allowed.

Respond with CORS headers: For all the other types of requests we need to make sure to include the appropriate CORS headers. These headers, just like the one above, need to include the domains that are allowed.

There’s a bit more to CORS than what we have covered here. So make sure to check out the Wikipedia article for further details.

If we don’t set the above up, then we’ll see something like this in our HTTP responses.

No 'Access-Control-Allow-Origin' header is present on the requested resource

And our browser won’t show us the HTTP response. This can make debugging our API extremely hard.

AWS Amplify

AWS Amplify provides a few simple modules (Auth, API, and Storage) to help us easily connect to our backend.

SST

If you are planning to work with sqlite on your sst project. I have some solution:

References