- Python 3.6 installed. Run
python3 -v
to check. - Java 6.0+ installed. Run
java -version
to check.sudo apt install default-jre
(linux)
- DynamoDB installed locally
git clone https://github.com/Wahuh/trackeroo-api.git
cd trackeroo-api
python3 -m venv venv
Activate your virtual environment
source venv/bin/activate
pip install -r requirements.txt
Setup git hooks, linting and formatting on pre-commit.
pre-commit install
pip install awscli
aws configure
- AWS Access Key ID [None]: your_access_key
- AWS Secret Access Key [None]: your_secret_key
- Default region name [None]: eu-west-1
- Default output format [None]: json
Install the Python extension for VSCode: https://marketplace.visualstudio.com/items?itemName=ms-python.python
MAKE SURE YOUR VIRTUAL ENVIRONMENT IS ACTIVATED FIRST
- Press
cmd + shift + p
and search for 'Python: Select Interpreter'. Select the Python 3.6 which is inside yourvenv
folder. - Press
cmd + shift + p
and search for 'Python: Select Linter'. Selectflake8
and you'll be prompted to install it. - Press
cmd + shift + i
and you should be prompted to choose a formatter for Python files. Installblack
as your formatter.
Make sure you are in the same directory as the DynamoDBLocal.jar file.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 7000
Create a directory called .chalice
then inside of it create a config.json
file which looks like:
{
"version": "2.0",
"app_name": "trackeroo-api",
"environment_variables": {
"USER_POOL_ID": user_pool_id # from cognito dashboard
"APP_CLIENT_ID": app_client_id # from cognito dashboard
"REGION_NAME": "eu-west-1",
"USER_POOL_ARN": user_pool_arn # from cognito dashboard
},
"stages": {
"dev": {
"autogen_policy": false,
"api_gateway_stage": "api",
"environment_variables": {
"DATABASE_URL": "http://localhost:7000"
}
}
}
}
In the same directory, create a policy-dev.json
file which looks like:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cognito-identity:*",
"cognito-idp:*",
"cognito-sync:*",
"iam:ListRoles",
"iam:ListOpenIdConnectProviders",
"sns:ListPlatformApplications",
"dynamodb:DescribeStream",
"dynamodb:GetRecords",
"dynamodb:GetShardIterator",
"dynamodb:ListStreams"
],
"Resource": "*"
}
]
}
chalice local