- [First time setup] Set up your AWS config file (
~/.aws/config) to work with the dev environment and AWS SSO. Make sure your config file contains the following entry:
[profile surveystream_dev]
sso_start_url = https://idinsight.awsapps.com/start
sso_region = ap-south-1
sso_account_id = 453207568606
sso_role_name = AdministratorAccess
region = ap-south-1
- Verify that you do not have an entry for
surveystream_devin your AWS credentials file (~/.aws/credentials). This is needed to make sure the local endpoints container looks for your temporary SSO-based credentials that are stored in~/.aws/sso/. - From the
rootdirectory, runmake loginto log into AWS SSO. You will be prompted to log in via a browser window that opens automatically. - Open a second terminal window and
cdinto the repository root directory. Runmake web-db-tunnelto open the connection to the remote db via the bastion host. - Build the backend image by running
make image - Start the container by running
make container-up.
Now you should be able to access the endpoints on localhost:5001/api/<endpoint_name>.
To stop the app:
- In your first terminal window, remove the running containers by running
make container-down - In your second terminal window, type
ctrl-cto close the SSM connection to the database.
The API documentation can be accessed at /api/docs. In staging and production environments, this endpoint requires the user to be logged in.
When running the backend locally, the docs can be accessed without logging in at localhost:5001/api/docs.
localhost:5001/api/healthcheck
The tests can be configured by updating the values found in tests/unit/config.yml:
email (string) - The email address to set for the test user. Updating this value will let you customize where emails will be sent for the relevant tests (forgot-password, welcome-user, etc). You will need to manually check receipt of the emails.
The unit tests get packaged with the main application image. Before running the tests, make sure the image is updated:
make image
Once the images are built, the unit tests can be run with the following commands:
make login
make -i run-unit-tests (note the -i flag will ensure the container cleanup happens even if some of the tests fail)
The unit tests will run on GitHub Actions on any pull request action or on a push to the dev, staging, or production branches.
The database schema is managed through Flask-Migrate. Instructions for working with database migrations can be found here.