Pre-requisites:
Install with npm i @aws-amplify/cli -g
We’re using amplify to deploy our Cognito user pool automatically, also, the frontend (client) is working through the Cognito Authentications using Cognito API and package.
cd client/ && amplify init
cd client/ && amplify add auth
, and continue the wizard according to these settings. ./src/aws-exports.json
is located on the root of /client
amplify push
and confirm when the CLI asks for confirmationI recommend you go to AWS Console (web dashboard) and check the new Cognito User Pull is successfully deployed as this:
npm install
,then npm run start
you must see no error in the React Client To create an account, for the first time, we need to continue deploying and configuring the API to save the users created by Cognito, so, let’s deploy the API.
aws configure
and set your credentials.* thanks Oswaldo to deploy everything in the Business account and realized this. config/{environment}.json
with the following fields: -- ./config/test.json
{
"MONGO_HOST": "YourMongoDB_Host",
"MONGO_PORT": 27017,
"MONGO_SECRET": "MongoPass",
"MONGO_SET": "replica-set-Cluster0-shard-0",
"MONGO_USER": "MongoUSER",
"MONGO_DATABASE":"DatabaseName",
"SRV_CONFIG": false,
"USER_POOL_ARN": "arn:aws:cognito-idp:us-east-1:9999999999:userpool/us-west-1_632zAiS9C"
}
The fields above show all the environment vars needed by the API, basically the MONGO and COGNITO credentials.
cd ../
npm install
serverless deploy --stage {environment} --region={same_as_cognito_region}
If everything is successfully deployed, you must see something similar to the logs above.
./client/package.json
and update the following scripts to point to your S3 bucket name instead of flavioaandres.com 🙂
"npm run build:test && aws s3 sync build/ s3:**//my-finances-bucket-flavio** --acl public-read",
.env.{environment}
is created, if you’re going to deploy test stage, check .env.test
is set up with the right .env vars: REACT_APP_FINANCES_API_URL="https://api.env.flavioaandres.com"
cd client/ && npm run deploy:test
{
"_id" : ObjectId("5fd625d50e1f299d3a6c9521"),
"filters" : [
{
"phrase" : "Bancolombia te informa recepción transferencia",
"type" : "INCOME",
"parser" : "transferReception"
},
{
"phrase" : "Bancolombia le informa Compra",
"type" : "EXPENSE",
"parser" : "shopping"
},
{
"phrase" : "Bancolombia le informa Retiro",
"type" : "EXPENSE",
"parser" : "debitWithdrawal"
},
{
"phrase" : "Bancolombia le informa Transferencia",
"type" : "EXPENSE",
"parser" : "transfer"
},
{
"phrase" : "Bancolombia le informa Pago",
"type" : "EXPENSE",
"parser" : "payments"
}
],
"name" : "BANCOLOMBIA",
"subjects" : [
"Servicio de Alertas y Notificaciones Bancolombia",
"Servicio de Alertas.",
"Servicio de Alertas y Notificaciones",
"Alertas y Notificaciones"
],
"folder" : "INBOX",
"createdAt" : ISODate("2020-11-26T19:32:15.925Z"),
"updatedAt" : ISODate("2020-11-26T19:32:15.925Z"),
"__v" : 0.0,
"ignore_phrase" : "Bancolombia le informa que su factura inscrita",
"index_value" : NumberLong(0)
}