Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=securing-safe-food
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=PLACEHOLDER_PASSWORD
DATABASE_PASSWORD=PLACEHOLDER_PASSWORD

AWS_ACCESS_KEY_ID = PLACEHOLDER_AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY = PLACEHOLDER_AWS_SECRET_KEY
AWS_REGION = PLACEHOLDER_AWS_REGION
COGNITO_CLIENT_SECRET = PLACEHOLDER_COGNITO_CLIENT_SECRET

AWS_BUCKET_NAME = 'confirm-delivery-photos'
35 changes: 34 additions & 1 deletion apps/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,37 @@ You can check that your database connection details are correct by running `nx s
"LOG 🚀 Application is running on: http://localhost:3000/api"
```

Finally, run `yarn run typeorm:migrate` to load all the tables into your database. If everything is set up correctly, you should see "Migration ... has been executed successfully." in the terminal.
Finally, run `yarn run typeorm:migrate` to load all the tables into your database. If everything is set up correctly, you should see "Migration ... has been executed successfully." in the terminal.

# AWS Setup

We have a few environment variables that we utilize to access several AWS services throughout the application. Below is a list of each of them and how to access each after logging in to AWS

1. `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`:
- Click on your username in the top right corner, and navigate to Security Credentials
- Scroll down to access keys, and create a new key
- Select CLI as the purpose for the key, and add an optional description
- Replace both the public and secret keys in the .env file to those values. Note that the secret key will not be accessible after you leave this page
- Click done

2. `AWS_REGION`:
This can be found next to your profile name when you login to the main page. Some accounts may be different, but we generally use us-east-1 or us-east-2

3. `AWS_BUCKET_NAME`:
This one is already given to you. As of right now, we only use one bucket, confirm-delivery-photos to store photos in a public S3 Bucket. This may be subject to change as we use S3 more in the project.

4. `COGNITO_CLIENT_SECRET`:
This is used to help authenticate you with AWS Cognito and allow you to properly sign in using proper credential. To find this:
- Navigate to AWS Cognito
- Go to App Clients, and click on 'ssf client w secret'
- There, you can validate the information in `aws_exports.ts`, as well copy the client secret into your env file

5. Creating a new user within AWS Cognito
There are 2 ways you can create a new user in AWS Cognito. The simplest, is through loading the up, going to the landing page, and creating a new account there. If you choose to do it alternatively through the console, follow these steps:
- Navigate to AWS Cognito
- Go to Users
- If you do not already see your email there, create a new User, setting an email in password (this will be what you login with on the frontend)
- Click 'Create User'
- Load up the app, and go to the landing page
- Verify you are able to login with these new credentials you created

4 changes: 2 additions & 2 deletions apps/backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class AuthService {
this.providerClient = new CognitoIdentityProviderClient({
region: CognitoAuthConfig.region,
credentials: {
accessKeyId: process.env.NX_AWS_ACCESS_KEY,
secretAccessKey: process.env.NX_AWS_SECRET_ACCESS_KEY,
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
});

Expand Down