Skip to content

Commit da211c4

Browse files
committed
Update README.md with detailed instructions and examples
- Add detailed setup instructions for using the reg.ru Terraform provider - Include variable definitions in `variables.tf` - Add main configuration file example with terraform block and provider configuration - Provide examples for creating A, AAAA, MX, and TXT DNS records - Add steps for initializing Terraform and planning configuration changes - Include instructions for applying the Terraform configuration - Add development and build steps using Makefile - Ensure instructions cover cloning the repository, installing dependencies, building the provider, and verifying installation - Update license information
1 parent 8b11975 commit da211c4

File tree

1 file changed

+152
-43
lines changed

1 file changed

+152
-43
lines changed

Diff for: README.md

+152-43
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,152 @@
1-
### Terraform provider for reg.ru DNS records
2-
3-
Example usage:
4-
5-
```hcl
6-
provider "regru" {
7-
api_username = "[email protected]"
8-
api_password = "fo0b4r6az"
9-
}
10-
11-
12-
// will create A record ex.xmplar.com -> 1.1.1.1
13-
resource "regru_dns_record" "test-a" {
14-
zone = "xmplar.com"
15-
name = "ex"
16-
type = "A"
17-
record = "1.1.1.1"
18-
}
19-
20-
// will create CNAME record exit.xmplar.com -> exit.xmplar.com
21-
resource "regru_dns_record" "test-cname" {
22-
zone = "xmplar.com"
23-
name = "exit"
24-
type = "CNAME"
25-
record = "ex.mplar.com"
26-
}
27-
28-
// will create MX record xmplar.com -> 10 mx.yandex.net
29-
resource "regru_dns_record" "test-mx" {
30-
zone = "xmplar.com"
31-
name = "@"
32-
type = "MX"
33-
record = "10 mx.yandex.net"
34-
}
35-
36-
// will create TXT record _acme-challenge.xmplar.com -> apchIhba
37-
resource "regru_dns_record" "test-txt" {
38-
zone = "xmplar.com"
39-
name = "_acme-challenge"
40-
type = "TXT"
41-
record = "apchIhba"
42-
}
43-
```
1+
# Terraform провайдер для управления DNS записями на reg.ru
2+
3+
Этот проект содержит Terraform провайдер для управления DNS записями с использованием API reg.ru. Провайдер позволяет создавать, читать и удалять различные типы DNS записей, включая A, AAAA, CNAME, MX и TXT.
4+
5+
## Установка
6+
7+
Для использования этого провайдера вам необходимо установить Terraform версии 0.12 или выше. Вы можете скачать Terraform с [официального сайта](https://www.terraform.io/downloads.html).
8+
9+
## Конфигурация
10+
11+
1. **Создайте файл переменных**:
12+
13+
Создайте файл `variables.tf` и добавьте следующие переменные:
14+
15+
```hcl
16+
variable "username" {
17+
description = "Username for the reg.ru API"
18+
default = "my_username"
19+
}
20+
21+
variable "password" {
22+
description = "Password for the reg.ru API"
23+
default = "my_password"
24+
}
25+
26+
variable "cert_file" {
27+
description = "Path to the client SSL certificate file"
28+
default = "./my.crt"
29+
}
30+
31+
variable "key_file" {
32+
description = "Path to the client SSL key file"
33+
default = "./my.key"
34+
}
35+
```
36+
37+
2. **Создайте основной конфигурационный файл**:
38+
39+
Создайте файл `main.tf` с основной конфигурацией для провайдера и ресурсов:
40+
41+
```hcl
42+
terraform {
43+
required_providers {
44+
regru = {
45+
version = "~>0.2.0"
46+
source = "letenkov/regru"
47+
}
48+
}
49+
}
50+
51+
provider "regru" {
52+
api_username = var.username
53+
api_password = var.password
54+
cert_file = var.cert_file
55+
key_file = var.key_file
56+
}
57+
58+
resource "regru_dns_record" "example_com" {
59+
zone = "example.com"
60+
name = "@"
61+
type = "A"
62+
record = "185.199.108.153"
63+
}
64+
65+
resource "regru_dns_record" "example_com_ipv6" {
66+
zone = "example.com"
67+
name = "@"
68+
type = "AAAA"
69+
record = "2606:2800:220:1:248:1893:25c8:1946"
70+
}
71+
72+
resource "regru_dns_record" "example_com_mx" {
73+
zone = "example.com"
74+
name = "@"
75+
type = "MX"
76+
record = "10 mail.example.com"
77+
}
78+
79+
resource "regru_dns_record" "example_com_txt" {
80+
zone = "example.com"
81+
name = "@"
82+
type = "TXT"
83+
record = "v=spf1 include:example.com ~all"
84+
}
85+
```
86+
87+
3. **Инициализация Terraform**:
88+
89+
В каталоге с конфигурационными файлами выполните команду:
90+
91+
```sh
92+
terraform init
93+
```
94+
95+
4. **Планирование конфигурации**:
96+
97+
Перед применением конфигурации рекомендуется выполнить команду `terraform plan`, чтобы увидеть, какие изменения будут внесены:
98+
99+
```sh
100+
terraform plan
101+
```
102+
103+
Эта команда покажет, какие ресурсы будут созданы, изменены или удалены.
104+
105+
5. **Применение конфигурации**:
106+
107+
Для создания указанных ресурсов выполните команду:
108+
109+
```sh
110+
terraform apply
111+
```
112+
113+
## Разработка и сборка
114+
115+
Для сборки проекта используется `Makefile`. Убедитесь, что у вас установлен Go.
116+
117+
### Шаги по сборке проекта
118+
119+
1. **Клонируйте репозиторий**:
120+
121+
```sh
122+
git clone https://github.com/yourusername/terraform-regru.git
123+
cd terraform-regru
124+
```
125+
126+
2. **Установите зависимости**:
127+
128+
Выполните команду для установки всех зависимостей:
129+
130+
```sh
131+
make install-deps
132+
```
133+
134+
3. **Соберите провайдер**:
135+
136+
Выполните команду для сборки провайдера:
137+
138+
```sh
139+
make build
140+
```
141+
142+
4. **Убедитесь, что провайдер установлен правильно**:
143+
144+
Проверьте, что собранный провайдер находится в правильной директории:
145+
146+
```sh
147+
ls ~/.terraform.d/plugins/registry.terraform.io/letenkov/regru/0.2.1/$(go env GOOS)_$(go env GOARCH)/
148+
```
149+
150+
## Лицензия
151+
152+
Этот проект лицензируется на условиях лицензии Apache 2.0. Подробнее см. в файле [LICENSE](LICENSE).

0 commit comments

Comments
 (0)