Skip to content

Commit ba9d3e0

Browse files
committed
ci: use Terraform for managing MailGun account
Fix #1302 [skip ci]
1 parent 8f9cd27 commit ba9d3e0

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

infra/terraform/.terraform.lock.hcl

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/terraform/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
$ curl -sS -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cache-Control: no-cache' -d "api_key=$UPTIMEROBOT_TOKEN" 'https://api.uptimerobot.com/v2/getPSPs' | jq '.psps[].id'
6161
1234
6262
```
63+
* Import existing MailGun configuration (optionally; only the first time)
64+
```console
65+
$ terraform import mailgun_domain.mystamps us:my-stamps.ru
66+
```
6367
* Plan and apply:
6468
```console
6569
$ terraform plan -out terraform.tfplan

infra/terraform/my-stamps.tf

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# @todo #1000 CI: validate and check Terraform configuration
2-
# @todo #1000 Terraform: add Mailgun
32

43
# How to obtain a token: https://docs.digitalocean.com/reference/api/create-personal-access-token/
54
variable "do_token" {
@@ -18,6 +17,27 @@ variable "uptimerobot_token" {
1817
sensitive = true
1918
}
2019

20+
# How to create API Key:
21+
# - https://app.mailgun.com/settings/api_security
22+
# - https://help.mailgun.com/hc/en-us/articles/203380100-Where-can-I-find-my-API-keys-and-SMTP-credentials
23+
variable "mailgun_token" {
24+
description = "MailGun API key"
25+
type = string
26+
sensitive = true
27+
}
28+
29+
# Mailgun provider docs: https://registry.terraform.io/providers/wgebis/mailgun/0.7.7/docs
30+
provider "mailgun" {
31+
api_key = var.mailgun_token
32+
}
33+
34+
# https://registry.terraform.io/providers/wgebis/mailgun/0.7.7/docs/resources/domain
35+
resource "mailgun_domain" "mystamps" {
36+
name = "my-stamps.ru"
37+
region = "us"
38+
}
39+
40+
2141
# Digital Ocean provider docs: https://registry.terraform.io/providers/digitalocean/digitalocean/2.28.1/docs
2242
provider "digitalocean" {
2343
token = var.do_token
+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
do_token = "<insert-token-here>"
22
uptimerobot_token = "<insert-token-here>"
3+
mailgun_token = "<insert-token-here>"

infra/terraform/versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ terraform {
1010
source = "vexxhost/uptimerobot"
1111
version = "0.8.2"
1212
}
13+
mailgun = {
14+
source = "wgebis/mailgun"
15+
version = "0.7.7"
16+
}
1317
}
1418
}

0 commit comments

Comments
 (0)