Skip to content

Commit 92b74da

Browse files
committedJan 11, 2020
chore: add terraform configuration for A-type DNS records.
Part of #1000 [skip ci]
1 parent 2bd8d05 commit 92b74da

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎infra/terraform/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
```console
1515
$ terraform import digitalocean_droplet.web <id>
1616
$ terraform import digitalocean_domain.site my-stamps.ru
17+
$ terraform import digitalocean_record.www my-stamps.ru,<id>
18+
$ terraform import digitalocean_record.no-www my-stamps.ru,<id>
1719
```
20+
The ids can be obtained by API:
21+
- https://developers.digitalocean.com/documentation/v2/#list-all-droplets
22+
- https://developers.digitalocean.com/documentation/v2/#list-all-domain-records
1823
* Plan and apply:
1924
```console
2025
$ terraform plan -out terraform.tfplan

‎infra/terraform/my-stamps.tf

+14
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ resource "digitalocean_droplet" "web" {
2222
resource "digitalocean_domain" "site" {
2323
name = "my-stamps.ru"
2424
}
25+
26+
# https://www.terraform.io/docs/providers/do/r/record.html
27+
resource "digitalocean_record" "no-www" {
28+
domain = digitalocean_domain.site.name
29+
type = "A"
30+
name = "@"
31+
value = digitalocean_droplet.web.ipv4_address
32+
}
33+
resource "digitalocean_record" "www" {
34+
domain = digitalocean_domain.site.name
35+
type = "A"
36+
name = "www"
37+
value = digitalocean_droplet.web.ipv4_address
38+
}

0 commit comments

Comments
 (0)
Please sign in to comment.