Skip to content

Terraform module which creates DNS domain and records on Alibaba Cloud

License

Notifications You must be signed in to change notification settings

alibabacloud-automation/terraform-alicloud-dns

Repository files navigation

Terraform module which create DNS on Alibaba Cloud.
terraform-alicloud-dns

English | 简体中文

Terraform module which creates DNS resources on Alibaba Cloud and add records.

These types of resources are supported:

Usage

Create a DNS.

Create a DNS without any record.

module "dns" {
  source        = "terraform-alicloud-modules/dns/alicloud"
  domain_name   = "dns001.abc"
}

Create a DNS and add the new group.

module "dns" {
  source        = "terraform-alicloud-modules/dns/alicloud"
  domain_name   = "dns001.abc"
  create_group  = true
  group_name    = "dns-group"
}

Create a DNS and add records.

module "dns" {
  source        = "terraform-alicloud-modules/dns/alicloud"
  domain_name   = "dns001.abc"
  records = [
    {
      rr       = "www"
      type     = "A"
      ttl      = 600
      value    = "223.5.5.5"
      priority = 1
      line     = "default"
    },
    {
      rr       = "www"
      type     = "MX"
      ttl      = 600
      value    = "mx.aliyun.com"
      priority = 1
    },
    {
      rr       = "cname"
      type     = "CNAME"
      ttl      = 600
      value    = "mx.aliyun.com"
      priority = 1
    }
  ]
}

Operation of existing DNS.

Add records to existing domain.

module "dns" {
  source               = "terraform-alicloud-modules/dns/alicloud"
  existing_domian_name = "dns002.abc"
  records = [
    {
      rr       = "www"
      type     = "A"
      ttl      = 600
      value    = "223.5.5.5"
      priority = 1
      line     = "default"
    },
    {
      rr       = "www"
      type     = "MX"
      ttl      = 600
      value    = "mx.aliyun.com"
      priority = 1
    },
    {
      rr       = "cname"
      type     = "CNAME"
      ttl      = 600
      value    = "mx.aliyun.com"
      priority = 1
    }
  ]  
}

Examples

Notes

From the version v1.5.0, the module has removed the following provider setting:

provider "alicloud" {
  profile                 = var.profile != "" ? var.profile : null
  shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
  region                  = var.region != "" ? var.region : null
  skip_region_validation  = var.skip_region_validation
  configuration_source    = "terraform-alicloud-modules/dns"
}

If you still want to use the provider setting to apply this module, you can specify a supported version, like 1.4.0:

module "dns" {
  source      = "terraform-alicloud-modules/dns/alicloud"
  version     = "1.4.0"
  region      = "cn-beijing"
  profile     = "Your-Profile-Name"
  domain_name = "dns001.abc"
  // ...
}

If you want to upgrade the module to 1.5.0 or higher in-place, you can define a provider which same region with previous region:

provider "alicloud" {
  region  = "cn-beijing"
  profile = "Your-Profile-Name"
}
module "dns" {
  source      = "terraform-alicloud-modules/dns/alicloud"
  domain_name = "dns001.abc"
  // ...
}

or specify an alias provider with a defined region to the module using providers:

provider "alicloud" {
  region  = "cn-beijing"
  profile = "Your-Profile-Name"
  alias   = "bj"
}
module "dns" {
  source      = "terraform-alicloud-modules/slb-http/alicloud"
  providers   = {
    alicloud = alicloud.bj
  }
  domain_name = "dns001.abc"
  // ...
}

and then run terraform init and terraform apply to make the defined provider effect to the existing module state.

More details see How to use provider in the module

Terraform versions

Name Version
terraform >= 0.13.0
alicloud >= 1.56.0

Submit Issues

If you have any problems when using this module, please opening a provider issue and let us know.

Note: There does not recommend to open an issue on this repo.

Authors

Created and maintained by Alibaba Cloud Terraform Team([email protected])

License

Apache 2 Licensed. See LICENSE for full details.

Reference