Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlo-colombo/terrafrom-server-setup
https://github.com/carlo-colombo/terrafrom-server-setup
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/carlo-colombo/terrafrom-server-setup
- Owner: carlo-colombo
- Created: 2016-11-11T17:54:31.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T17:42:06.000Z (about 8 years ago)
- Last Synced: 2024-10-31T19:12:40.270Z (2 months ago)
- Language: HCL
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# terrafrom-server-setup
## Objective
Recreating with [terraform](https://www.terraform.io) a setup I already have with `docker-compose`. The setup consist of `nginx` acting as reverse proxy in front of a couple of different webservices (1 static website, 2 telegram bot, 1 rest service). Additionally `https` is provided with `letsencrypt`. All the services are deployed as docker images, plus there is a docker image that host nginx (and another that provide the letsencrypt certificates). Request on the port `80` of the webserver will be dispatched to the relevenat webservice based on the `Host` header.### Actual situation
`docker-compose` allow to spin up a set of images based on a yaml configuration fiele (yeah yaml!!! :-D ). `docker-compose` does not implement (AFAIK) any type of templating in its configuration file this bring duplication and embedding of secrets inside of the configuration.### Expected improvment using Terraform
- configuration reusability between similar services (bots)
- removing secrets from the configuration
- terraform output can be used to automate succesful step (eg ping to `/status` endpoint )### [nginx-proxy](https://github.com/jwilder/nginx-proxy)
nginx-proxy sets up a container running nginx and docker-gen. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.### Prepare
#### pull docker images
```
> docker pull carlocolombo/dublin_bus_telegram-bot
> docker pull carlocolombo/webhook_me
> docker pull jwilder/nginx-proxy
```#### create a `secrets.tfvars` to contain telegram bot keys and hashids salt
```
webhook_me_bot_token = "ask The Bot Father"
dublin_bus_bot_token = "ask The Bot Father"
hashids_salt = "a random string"
```### Terraform commands
```
# See the resource that terraform is planning to create
> terraform plan -var-file=secrets.tfvars# Create and run the containers
> terraform apply -var-file=secrets.tfvars# Tear down everything
> terraform destroy -var-file=secrets.tfvars
```