forked from murtll/terraform-provider-regru
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1 changed file
with
152 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,152 @@ | ||
### Terraform provider for reg.ru DNS records | ||
|
||
Example usage: | ||
|
||
```hcl | ||
provider "regru" { | ||
api_username = "[email protected]" | ||
api_password = "fo0b4r6az" | ||
} | ||
// will create A record ex.xmplar.com -> 1.1.1.1 | ||
resource "regru_dns_record" "test-a" { | ||
zone = "xmplar.com" | ||
name = "ex" | ||
type = "A" | ||
record = "1.1.1.1" | ||
} | ||
// will create CNAME record exit.xmplar.com -> exit.xmplar.com | ||
resource "regru_dns_record" "test-cname" { | ||
zone = "xmplar.com" | ||
name = "exit" | ||
type = "CNAME" | ||
record = "ex.mplar.com" | ||
} | ||
// will create MX record xmplar.com -> 10 mx.yandex.net | ||
resource "regru_dns_record" "test-mx" { | ||
zone = "xmplar.com" | ||
name = "@" | ||
type = "MX" | ||
record = "10 mx.yandex.net" | ||
} | ||
// will create TXT record _acme-challenge.xmplar.com -> apchIhba | ||
resource "regru_dns_record" "test-txt" { | ||
zone = "xmplar.com" | ||
name = "_acme-challenge" | ||
type = "TXT" | ||
record = "apchIhba" | ||
} | ||
``` | ||
# Terraform провайдер для управления DNS записями на reg.ru | ||
|
||
Этот проект содержит Terraform провайдер для управления DNS записями с использованием API reg.ru. Провайдер позволяет создавать, читать и удалять различные типы DNS записей, включая A, AAAA, CNAME, MX и TXT. | ||
|
||
## Установка | ||
|
||
Для использования этого провайдера вам необходимо установить Terraform версии 0.12 или выше. Вы можете скачать Terraform с [официального сайта](https://www.terraform.io/downloads.html). | ||
|
||
## Конфигурация | ||
|
||
1. **Создайте файл переменных**: | ||
|
||
Создайте файл `variables.tf` и добавьте следующие переменные: | ||
|
||
```hcl | ||
variable "username" { | ||
description = "Username for the reg.ru API" | ||
default = "my_username" | ||
} | ||
variable "password" { | ||
description = "Password for the reg.ru API" | ||
default = "my_password" | ||
} | ||
variable "cert_file" { | ||
description = "Path to the client SSL certificate file" | ||
default = "./my.crt" | ||
} | ||
variable "key_file" { | ||
description = "Path to the client SSL key file" | ||
default = "./my.key" | ||
} | ||
``` | ||
2. **Создайте основной конфигурационный файл**: | ||
Создайте файл `main.tf` с основной конфигурацией для провайдера и ресурсов: | ||
```hcl | ||
terraform { | ||
required_providers { | ||
regru = { | ||
version = "~>0.2.0" | ||
source = "letenkov/regru" | ||
} | ||
} | ||
} | ||
provider "regru" { | ||
api_username = var.username | ||
api_password = var.password | ||
cert_file = var.cert_file | ||
key_file = var.key_file | ||
} | ||
resource "regru_dns_record" "example_com" { | ||
zone = "example.com" | ||
name = "@" | ||
type = "A" | ||
record = "185.199.108.153" | ||
} | ||
resource "regru_dns_record" "example_com_ipv6" { | ||
zone = "example.com" | ||
name = "@" | ||
type = "AAAA" | ||
record = "2606:2800:220:1:248:1893:25c8:1946" | ||
} | ||
resource "regru_dns_record" "example_com_mx" { | ||
zone = "example.com" | ||
name = "@" | ||
type = "MX" | ||
record = "10 mail.example.com" | ||
} | ||
resource "regru_dns_record" "example_com_txt" { | ||
zone = "example.com" | ||
name = "@" | ||
type = "TXT" | ||
record = "v=spf1 include:example.com ~all" | ||
} | ||
``` | ||
3. **Инициализация Terraform**: | ||
В каталоге с конфигурационными файлами выполните команду: | ||
```sh | ||
terraform init | ||
``` | ||
4. **Планирование конфигурации**: | ||
Перед применением конфигурации рекомендуется выполнить команду `terraform plan`, чтобы увидеть, какие изменения будут внесены: | ||
```sh | ||
terraform plan | ||
``` | ||
Эта команда покажет, какие ресурсы будут созданы, изменены или удалены. | ||
5. **Применение конфигурации**: | ||
Для создания указанных ресурсов выполните команду: | ||
```sh | ||
terraform apply | ||
``` | ||
## Разработка и сборка | ||
Для сборки проекта используется `Makefile`. Убедитесь, что у вас установлен Go. | ||
### Шаги по сборке проекта | ||
1. **Клонируйте репозиторий**: | ||
```sh | ||
git clone https://github.com/yourusername/terraform-regru.git | ||
cd terraform-regru | ||
``` | ||
2. **Установите зависимости**: | ||
Выполните команду для установки всех зависимостей: | ||
```sh | ||
make install-deps | ||
``` | ||
3. **Соберите провайдер**: | ||
Выполните команду для сборки провайдера: | ||
```sh | ||
make build | ||
``` | ||
4. **Убедитесь, что провайдер установлен правильно**: | ||
Проверьте, что собранный провайдер находится в правильной директории: | ||
```sh | ||
ls ~/.terraform.d/plugins/registry.terraform.io/letenkov/regru/0.2.1/$(go env GOOS)_$(go env GOARCH)/ | ||
``` | ||
## Лицензия | ||
Этот проект лицензируется на условиях лицензии Apache 2.0. Подробнее см. в файле [LICENSE](LICENSE). |