This is just a pet project to play with and learn about AWS Chalice, A microservice framework for AWS. More can be found at the Chalice website https://chalice.readthedocs.io/en/latest/#.
These instructions will get you a copy of the project up and running.
To get started, you need to have git, python3.6, and pip3 installed, and then install the modules in requirements.txt.
git clone https://github.com/LEXmono/FortuneCookieAPI.git
cd fortunecookie
pip3 -r requirements.txt
- Make two DynamoDB tables in a region of your choice. They should be named
fortunecookie-dev
andfortunecookie-prod
(OR you have to change these values in the config later.) - Make an IAM user and download the credentials.
- Use
aws configure
to set up these credentials.
You will need to create a config file to be able to run the API which lives in the .chalice
directory which is located in the root of the project.
/.chalice/config.json
{
"version": "2.0",
"app_name": "fortunecookie",
"environment_variables": {
"APP_NAME": "fortunecookie",
"SITE_FALLBACK": "https://yoursite/"
},
"stages": {
"dev": {
"api_gateway_stage": "dev",
"region": "us-east-2",
"environment_variables": {
"DYNAMO_TABLE": "fortunecookie-dev"
}
},
"prod": {
"api_gateway_stage": "api",
"region": "us-east-2",
"environment_variables": {
"DYNAMO_TABLE": "fortunecookie-prod"
}
}
}
}
You can now deploy the API using chalice deploy --stage dev
NOTE: Dev here comes from the stage defined in yout config.json. The output should look like the following and return your API URL.
(fortunecookie) mhenry: ~/virtualenvs/fortunecookie/fortunecookie
=> chalice deploy --stage dev
Regen deployment package.
Updating IAM policy for role: fortunecookie-dev
Updating lambda function: fortunecookie-dev
API Gateway rest API already found: 2mvwjcenw2
Deploying to API Gateway stage: dev
https://REDACTED.execute-api.us-east-2.amazonaws.com/dev/
And if you have fortunes in your DynamoDB table, you should get back a fortune by going to https://REDACTED.execute-api.us-east-2.amazonaws.com/dev/fortune
- Michael Henry - Initial work - LEXmono
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details