Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/conradludgate/terraform-provider-caddy
Configure caddy through terraform
https://github.com/conradludgate/terraform-provider-caddy
caddy caddy2 terraform terraform-provider
Last synced: 3 months ago
JSON representation
Configure caddy through terraform
- Host: GitHub
- URL: https://github.com/conradludgate/terraform-provider-caddy
- Owner: conradludgate
- License: mit
- Created: 2021-01-09T07:55:08.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-27T15:47:26.000Z (almost 3 years ago)
- Last Synced: 2024-06-19T04:22:05.599Z (8 months ago)
- Topics: caddy, caddy2, terraform, terraform-provider
- Language: Go
- Homepage: https://registry.terraform.io/providers/conradludgate/caddy/latest
- Size: 211 KB
- Stars: 14
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-provider-caddy
This is a terraform provider to manage the [caddy api](https://caddyserver.com/).
## Setup
First you will need caddy running with the admin api enabled. This provider supports two methods to accesing the API endpoint
### HTTP Endpoint
The simplest is to just use the default endpoint `http://localhost:2019`.
This is the default caddy uses and the default that this provider will use too.However, this is not recommended as it is not secure.
### Unix Sockets
The recommended method is to use unix sockets. Modify your caddy config to use the admin endpoint `unix//path/to/admin.sock`.
Next, run caddy (preferrably with `-resume` and in the background. If you have systemd, check out the caddy-api service file).Once caddy is running, it should create the unix socket at the path specified. Test it by running the following (making sure you have permission to access the socket)
```sh
curl -H "Host: " --unix-socket /path/to/admin.sock http://localhost/config/
```If you don't get an error, all is good to go! Finally, set up the provider like so
```tf
provider "caddy" {
host = "unix:///path/to/admin.sock
}
```### SSH
In addition to using any of the two above methods to connect to the admin API, you can proxy the request through SSH to ensure authorized access over the internet.
Ensure you can SSH into the server where Caddy is running, and that user can access the admin endpoint, the add the following to your provider config```tf
provider "caddy" {
host = "unix:///path/to/admin.sock
ssh = {
host = "[email protected]:22" // port is required
key_file = "~/.ssh/id_rsa" // or specify a password in the host field 'user:[email protected]:22'
host_key = "example.com ssh_rsa ...." // in 'known_hosts' format.
}
}
```