๐ Getting started¶
You should be up and running in approx. 3 minutes as long as you already have following software already installed on your machine:
๐ป Install the hlambda server¶
Run the hlambda core stand-alone server using docker
docker run -d -p 8081:1331 --env HLAMBDA_ADMIN_SECRET=demo --name hlambda-server --restart=always -v hlambda_metadata:/usr/src/app/metadata hlambda/hlambda-core:latest
... or run the recommended stack (including Hasura and PostgreSQL ) using docker compose
... well you should already be up and running, if you access http://localhost:8081
you should be presented with the hlambda server console login screen. If you did not change the commands above the admin secret should be demo
. But let's use the hlambda-cli
to create our first hlambda app.
๐งฐ Install Hlambda CLI ¶
This will add Hlambda CLI to your arsenal, now you can use hl
, hla
or hlambda
.
๐ Using Hlambda CLI¶
Check if the console is installed globally, in your terminal you can now run
let's initialize new configuration in the new folder test
change working directory to test
To easily use all hlambda cli commands in the future you can save the admin_secret in the config.yaml
manually or just run
this will edit the config.yaml file and save admin secret value in that file (๐งจ please take extra care when commiting config.yaml
file to not leak secrets , check Environments section for more details but we suggest you to use env replacer syntax
like {{ENV_HLAMBDA_ADMIN_SECRET}}
and keeping your secrets in the environemnt variables)
(Optional) You can read the values in the config.yaml
by running
(Optional) You can check the structure of the initial demo codebase or edit any part of the code with "Visual Studio Code" before deploying(applying metadata) by running:
You can now apply the changes by running
That is it! Enjoy! ๐
๐ต๏ธโโ๏ธ Testing¶
You can use curl
to test the API
or even better hlambda cli for the simple request test
If you want to check your new API in browser just run:Happy hacking!
๐ Bonus¶
All commands have aliases, thus you can run all this even quicker. For example
is equivalent toyou can also get the remote logs by running:
or with aliases
๐ฆ Environments¶
If you have multiple deployments of the same app you can now add environments to your hlambda config using hlambda-cli
To add dev
environment use
this will add new dev
folder environment in ./environments/dev
with config.yaml
example content of the ./environments/dev/config.yaml
version: 1
endpoint: "{{ENV_DEV_HLAMBDA_ENDPOINT}}"
admin_secret: "{{ENV_DEV_HLAMBDA_ADMIN_SECRET}}"
this will be used instead of the values in root config.yaml
file.
๐งจ Important! - You can hardcode but it is the best practice to use env replacer syntax
{{ENV_DEV_HLAMBDA_ADMIN_SECRET}}
the value will be the one provided in the ENV_DEV_HLAMBDA_ADMIN_SECRET
environment variable at the CLI command run-time.
โจ Hlambda cli also supports .env file ๐ so you can create .env
file in the root
Any hlambda CLI command can now be excuted for different environment, example
why is this useful? You can commit the code without commiting secrets to the version control system. And you can have repository containing your metadata and multiple deployments configurations with URL and secrets saved in CI/CD pipeline as different env variables.
to add custom_name
environemnt use
to delete environment named "staging"
this will remove the whole environment folder.