Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crissalvarezh/just-a-db
Project to lauch a db with docker compose and cloudformation in aws instance
https://github.com/crissalvarezh/just-a-db
Last synced: 10 days ago
JSON representation
Project to lauch a db with docker compose and cloudformation in aws instance
- Host: GitHub
- URL: https://github.com/crissalvarezh/just-a-db
- Owner: CrissAlvarezH
- Created: 2024-08-28T04:00:58.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-10T04:37:34.000Z (16 days ago)
- Last Synced: 2025-01-10T05:29:33.606Z (16 days ago)
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Description
It is a simple docker container running a postgres server in a aws ec2 instance with a cron job for backups stored in s3, nothing else, that's it.
**Just run a command and you will have your boring database.**
# How to use
## 1. Setup aws cli in your machine
You need to have [aws cli](https://aws.amazon.com/es/cli/) installed in your machine and configured with your aws credentials with enough permissions to create the stack in cloudformation.
## 2. Setup the environment variables
You need to specify the s3 bucket for backups in a `.env` file in the project root folder, the rest of the variables are optional and will use the default values, use `.env.example` as a reference, example:
```bash
BACKUP_CRON_EXPRESSION="0 2 * * *"
S3_BUCKET=just-a-db-backups
AWS_REGION=us-east-1
```## 3. Launch
Run the following command```shell
make setup
```That's all, it will create the following infrastructure in you aws account:
### Details
- You can see the logs in CloudWatch Logs, the log groups are `just-a-db/database-logs` and `just-a-db/backup-logs`.
- You can see the backups in S3 organized by database name, with files named `backup__.sql.gz`. Only the 3 most recent backups are kept, the oldest ones are deleted.
- The default database is created with the name `just-a-db`.
- The credentials are created in the deployment stack process, you can see them executing the command `make credentials`, it will store the credentials in the `credentials.txt` file.
- In the root folder you will find `just-a-db.pem` file, that is the private key for the ec2 instance, you need to keep it safe and secure.### Useful commands
- `make connect` Connect to the ec2 instance using the private key via ssh.
- `make credentials` Get the credentials for the database and store them in the `credentials.txt` file.
- `make destroy` Destroy the infrastructure (aws cloudformation stack).