A CRUD API to manage users. Main components are the toolchain and the service. The application implements Application Design Framework (ADF) recommendations to organize resources configuration and business logic code.
* Diagram generated using https://github.com/pistazie/cdk-dia
See Getting Started With the AWS CDK for additional details and prerequisites
git clone https://github.com/alexpulver/usermanagement-backend
cd usermanagement-backend
This is optional for deploying the service to sandbox environment, but required for deploying the toolchain.
git remote set-url origin <your fork URL>
python3.11 -m venv .venv
source .venv/bin/activate
# [Optional] Use pip-tools to upgrade dependencies
# Pinning pip-tools to 6.4.0 and pip to 21.3.1 due to
# https://github.com/jazzband/pip-tools/issues/1576
pip install pip-tools==6.4.0
pip install pip==21.3.1
./scripts/install-deps.sh
./scripts/run-tests.sh
Note: If you are planning to upgrade dependencies, first push the upgraded AWS CDK Toolkit version. See This CDK CLI is not compatible with the CDK library used by your application for more details.
vi package.json # Update the "aws-cdk" package version
./scripts/install-deps.sh
./scripts/run-tests.sh
Consider AWS CDK Toolkit (CLI) compatibility when upgrading AWS CDK packages version.
pip-compile --upgrade service/api/requirements.in
pip-compile --upgrade requirements.in
pip-compile --upgrade requirements-dev.in
./scripts/install-deps.sh
./scripts/run-tests.sh
The application uses AWS Service Catalog AppRegistry to manage application metadata.
Prerequisites
- Update the account for
APPLICATION_PRODUCTION_ENVIRONMENT
constant in constants.py - Commit and push the changes:
git commit -a -m 'Environment configuration' && git push
npx cdk deploy UserManagementBackend-Application-Production
The UserManagementBackend-Service-Sandbox
stack uses your default AWS account and Region.
npx cdk deploy UserManagementBackend-Service-Sandbox
Example output for npx cdk deploy UserManagementBackend-Service-Sandbox
:
✅ UserManagementBackend-Service-Sandbox
Outputs:
UserManagementBackend-Service-Sandbox.APIEndpoint = https://bsc9goldsa.execute-api.eu-west-1.amazonaws.com/
Prerequisites
- Fork the repository, if you haven't done this already
- Create AWS CodeStar Connections connection for the deployment pipeline
- Authorize AWS CodeBuild access for the pull request build
- Start creating a new project manually
- Select GitHub as Source provider
- Choose Connect using OAuth
- Authorize access and cancel the project creation
- Update the
GITHUB_CONNECTION_ARN
,GITHUB_OWNER
,GITHUB_REPO
,GITHUB_TRUNK_BRANCH
,TOOLCHAIN_PRODUCTION_ENVIRONMENT
,SERVICE_SHARED_ENVIRONMENTS
constants in constants.py - Commit and push the changes:
git commit -a -m 'Source and environments configuration' && git push
npx cdk deploy UserManagementBackend-Toolchain-Production
Do not forget to delete the stacks to avoid unexpected charges
npx cdk destroy UserManagementBackend-Toolchain-Production
npx cdk destroy UserManagementBackend-Service-Production
npx cdk destroy UserManagementBackend-Service-Sandbox
npx cdk destroy UserManagementBackend-Application-Production
Delete the AWS CodeStar Connections connection if it is no longer needed. Follow the instructions in Delete a connection.
Below are examples that show the available resources and how to use them.
api_endpoint=$(aws cloudformation describe-stacks \
--stack-name UserManagementBackend-Service-Sandbox \
--query 'Stacks[*].Outputs[?OutputKey==`APIEndpoint`].OutputValue' \
--output text)
curl \
-H "Content-Type: application/json" \
-X POST \
-d '{"username":"john", "email":"[email protected]"}' \
"${api_endpoint}/users"
curl \
-H "Content-Type: application/json" \
-X GET \
"${api_endpoint}/users/john"
curl \
-H "Content-Type: application/json" \
-X PUT \
-d '{"username":"john", "country":"US", "state":"WA"}' \
"${api_endpoint}/users"
curl \
-H "Content-Type: application/json" \
-X DELETE \
"${api_endpoint}/users/john"