https://github.com/nargonath/do-terraform-nodejs
This repo is an attempt for setting up a fully configured DigitalOcean infrastructure for a NodeJS server with a database hosted on a different droplet within a VPC and a frontend
https://github.com/nargonath/do-terraform-nodejs
database digitalocean docker droplet nodejs nodejs-server packer terraform vpc
Last synced: 2 months ago
JSON representation
This repo is an attempt for setting up a fully configured DigitalOcean infrastructure for a NodeJS server with a database hosted on a different droplet within a VPC and a frontend
- Host: GitHub
- URL: https://github.com/nargonath/do-terraform-nodejs
- Owner: Nargonath
- License: mit
- Created: 2020-06-04T18:54:16.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T16:54:22.000Z (almost 6 years ago)
- Last Synced: 2025-09-01T18:44:59.526Z (10 months ago)
- Topics: database, digitalocean, docker, droplet, nodejs, nodejs-server, packer, terraform, vpc
- Language: HCL
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
DigitalOcean Terraform NodeJS server
This repo is an attempt for setting up a fully configured DigitalOcean infrastructure for a NodeJS server with a database hosted on a different droplet within a VPC and a frontend
# Setup
## Custom Droplet image
This project uses [Packer](https://www.packer.io/) from Hashicorp to create custom droplet images with everything setup.
The Packer configuration uses a variable file for its secrets: `packer-secrets.json`. You'll find an example file in this repo for the structure to follow.
### Build your snapshot
To build your snapshot using Packer:
```bash
packer build \
-var 'size=s-1vcpu-1gb' \
-var-file 'packer-secrets.json' \
packer.json
```
## Infrastructure configuration
This terraform configuration requires multiples variables files for which you can find examples in the repository:
- `secrets.tfvars`
- `ssh_keys.tfvars`
You need to copy-paste the examples, remove the `.example` in the name of the file and fill them up with your real data.
# Create the infrastructure
You can create the infrastructure with `terraform apply -var-file="secrets.tfvars" -var-file="ssh_keys.tfvars"`
# Resources
This article gives guidelines to improve terraform usage: https://cloudskiff.com/terraform-code-quality/?utm_source=Slack&utm_medium=TerraformCodeQuality.