Refactor sample app written in python using poet and cdk
- Python 3.11.x
- poerty 1.6.x
If you are using asdf
:
asdf plugin-add poetry https://github.com/asdf-community/asdf-poetry.git
asdf install poetry 1.6.1
Otherwise, after installing python 3.11.x, make sure to install poetry.
curl -sSL https://install.python-poetry.org | python -
after ensuring you have the correct python and poetry installed, run the following:
poetry shell
poetry env use $(which python) # you can run `poetry env info` to ensure python version matches .tool-versions
poetry config virtualenvs.in-project true
poetry install
You will need an API Key for OpenAI. Once you have it, place it in your newly created .env
file.
cp .env-example .env
You will need to request an IAM access key and secret. Then run the following command
aws configure --profile refactor
npm install -g aws-cdk
cdk synth
cdk --profile refactor bootstrap # first time, you will need to bootstrap
cdk --profile refactor deploy
This is a blank project for CDK development with Python.
The cdk.json
file tells the CDK Toolkit how to execute your app.
This project is set up like a standard Python project. The initialization
process also creates a virtualenv within this project, stored under the .venv
directory. To create the virtualenv it assumes that there is a python3
(or python
for Windows) executable in your path with access to the venv
package. If for any reason the automatic creation of the virtualenv fails,
you can create the virtualenv manually.
$ cdk synth
To add additional dependencies, for example other CDK libraries, just add
them to your setup.py
file and rerun the pip install -r requirements.txt
command.
cdk ls
list all stacks in the appcdk synth
emits the synthesized CloudFormation templatecdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk docs
open CDK documentation
To run pytest in parallel do the following. NOTE: You will need to have defined
the following in your .env
file:
- AWS_REGION
- AWS_ACCESS_KEY_ID
- AWS_SECRET_KEY
pytest -n 3
Single table design
index | pk | sk | gs1pk | gs1sk |
---|---|---|---|---|
default | hashKey | rangeKey | ||
itemTypeIdIndex | itemType | id |
hashKey | rangeKey | itemType | id |
---|---|---|---|
ORG-UUID | ORG-UUID | ORG | |
ORG-UUID | USER-UUID | USER | |
ORG-UUID | ROLE-UUID | ROLE |
access | index | query |
---|---|---|
single user | default | hashKey = ORG-UUID and rangeKey = USER-UUID |
single user by email | itemTypeIdIndex | itemType = USER and id = email |
all users in org | default | hashKey = ORG-UUID and begins_with(rangeKey, USER) |
all users | itemTypeIdIndex | itemType = USER |
single org | default | hashKey = ORG-UUID and rangeKey = ORG-UUID |
all orgs | itemTypeIdIndex | itemType = ORG |