This project is a deployment of a inventory management software called Snipe-IT focused on automation of:
- Deployment in the cloud
- Recovery of the server is there has been any problems with it
- Backups to a S3 bucket of the MySQL database
For this, the main technologies used are Terraform, to deploy the resources to AWS, and Docker Compose, to run the Snipe-IT and MySQL services.
To install this project in the cloud the necessary steps must be performed:
I recommend to make your repository private as the terraform state files contain sensitive information like the bucket name or the AWS account.
Update the contents of deployment/snipeit/web_key.pub
with your public key. Otherwise, I will be able to access your machine, and we don’t want that…
Copy the src/example.env
file into src/.env
and edit it to add your configuration of the services. Note that the passwords are the ones used in the local MySQL database.
In order to obtain the key make sure to run the following code:
docker run --rm snipe/snipe-it
And now copy the whole key with the base64 included to your configuration.
Copy the deployment/example.tfvars
file into deployment/terraform.tfvars
and edit it to add your configuration. Make sure to set up the correct aws_region
and aws_profile
based on your configuration.
Go to the deployment/
folder and run the following code to deploy the terraform configuration in your AWS:
terraform init
terraform apply
Tip: I like using Terraform workspaces to manage the different deployments.
Make sure to have valid credentials for AWS. I recommend using AWS profiles.
Go to the S3 bucket that Terraform has created and upload the src/.env
file to the root of the bucket.
This is done so if there are any problems and the EC2 instance has to be recreated, it has all the configuration available for later use.
Backups are performed with a cron job that runs every day at 5 am. If you want to change it make sure to edit this line.
- [ ] Automatic restore of the backups when starting up.
- [ ] Create a systemd service instead of a cronjob for automatic backups.
- [ ] Configuration to edit.
If you have any other ideas make sure to open an issue. Also if you want to add features just open a pull request.
Check out my website to see who am I.
And if you want to get in contact with me, you can contact me via LinkedIn.