🏡 Homepage
Simple fake AWS Cognito API server for development.
- AdminXxx on User Pools API.
# run with cargo on port 8080
cargo run &
# or run on docker from ghcr
docker run -p 8080:8080 ghcr.io/naokirin/fakey-cognito:main
# or build and run on docker from repository code
docker build -t fakey-cognito .
docker run -p 8080:8080 fakey-cognito
# request AdminGetUser
curl -X POST http://localhost:8080 \
-H 'Content-Type:application/x-amz-json-1.1' \
-H 'X-Amz-Target:AWSCognitoIdentityProviderService.AdminGetUser' \
-d '{"Username":"${USER_NAME}","UserPoolId":"${USER_POOL_ID}"}'
- rust >= 1.55.0
OR
- docker >= 19.03
First read "Get Started".
You use configuration with file (YAML).
Default configuration path is /repository_root/config.yml
.
Following configuration file format.
ActionName:
error_type: <force response error type (e.g. InternalFailure)>
...
When use custom path you specify a command line arguments.
cargo run -- --config /path/to/config.yml
Fackey-cognito returns simple response by default.
It also returns rendering templates if you need custom responses.
Default template path is /repository_root/templates/**/*.json
.
Template file name is a action name and a directory is user_pools
, user_pools_auth
.
You can use request parameters in template.
Example for template file (e.g.user_pools/AdminGetDevice.json
).
{
"Device": {
"DeviceAttributes": [
{
"Name": "DeviceName",
"Value": "DeviceValue"
}
],
"DeviceCreateDate": {{ now() | date(format="%Y%m%d%H%M%S" )}},
"DeviceKey": "{{DeviceKey}}",
"DeviceLastAuthenticatedDate": {{ now() | date(format="%Y%m%d%H%M%S" )}},
"DeviceLastModifiedDate": {{ now() | date(format="%Y%m%d%H%M%S" )}}
}
}
Rendering template by tera (Tera is Jinja2 like template engine).
When use custom path you specify a command line arguments.
cargo run -- --templates /path/to/templates
Can run python hook scripts before responses.
fakey-cognito calls a hook
function in snake_case action name python script.
A hook
function takes a request json body string and should return a json string for using a response template.
Example for AdminGetUser action hook script (e.g.hooks/admin_get_user.py
).
def hook(request):
return '{ "json": "response" }'
Default hook scripts directory path is ./hooks
.
When use custom path you specify a command line arguments.
cargo run -- --hooks /path/to/hooks
- Request parameter validations
- Error response with corrected messages (but supported error types)
- No check any authentication and authorization
Fakey Cognito(fakey-cognito) is under MIT License