Skip to content

Commit 55195ca

Browse files
author
ccushing
committed
Add DNS Zone and Records resources, datasources and docs
* tested extensively with included example files
1 parent aed5e60 commit 55195ca

File tree

13 files changed

+2115
-1
lines changed

13 files changed

+2115
-1
lines changed

docs/dns/records.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# oci_dns_record
2+
3+
## Records Resource
4+
5+
### Records Reference
6+
7+
The following attributes are exported:
8+
* `compartment_id` - (Optional) The OCID of the compartment the resource belongs to.
9+
* `domain` - The fully qualified domain name where the record can be located.
10+
* `is_protected` - A Boolean flag indicating whether or not parts of the record are unable to be explicitly managed.
11+
* `rdata` - The record's data, as whitespace-delimited tokens in type-specific presentation format.
12+
* `record_hash` - A unique identifier for the record within its zone.
13+
* `rrset_version` - The latest version of the record's zone in which its RRSet differs from the preceding version.
14+
* `rtype` - The canonical name for the record's type, such as A or CNAME. For more information, see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
15+
* `ttl` - The Time To Live for the record, in seconds.
16+
* `zone_name_or_id` - The name or OCID of the target zone.
17+
18+
19+
20+
### Create Operation
21+
Replaces records in the specified zone with the records specified in the
22+
request body. If a specified record does not exist, it will be created.
23+
If the record exists, then it will be updated to represent the record in
24+
the body of the request. If a record in the zone does not exist in the
25+
request body, the record will be removed from the zone.
26+
27+
28+
The following arguments are supported:
29+
30+
* `compartment_id` - (Optional) The OCID of the compartment the resource belongs to. If supplied, it must match the Zone's compartment ocid.
31+
* `domain` - (Optional) The fully qualified domain name where the record can be located.
32+
* `rdata` - (Optional) The record's data, as whitespace-delimited tokens in type-specific presentation format.
33+
* `rtype` - (Optional) The canonical name for the record's type, such as A or CNAME. For more information, see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
34+
* `ttl` - (Optional) The Time To Live for the record, in seconds.
35+
* `zone_name_or_id` - (Required) The name or OCID of the target zone.
36+
37+
38+
### Update Operation
39+
Replaces records in the specified zone with the records specified in the
40+
request body. If a specified record does not exist, it will be created.
41+
If the record exists, then it will be updated to represent the record in
42+
the body of the request. If a record in the zone does not exist in the
43+
request body, the record will be removed from the zone.
44+
45+
46+
The following arguments support updates:
47+
* `compartment_id` - The OCID of the compartment the resource belongs to.
48+
* `domain` - (Optional) The fully qualified domain name where the record can be located.
49+
* `rdata` - (Optional) The record's data, as whitespace-delimited tokens in type-specific presentation format.
50+
* `rtype` - (Optional) The canonical name for the record's type, such as A or CNAME. For more information, see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
51+
* `ttl` - (Optional) The Time To Live for the record, in seconds.
52+
53+
54+
** IMPORTANT **
55+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
56+
57+
### Example Usage
58+
59+
```
60+
resource "oci_dns_records" "test_record" {
61+
#Required
62+
zone_name_or_id = "${oci_dns_zone_name_or.test_zone_name_or.id}"
63+
64+
#Optional
65+
compartment_id = "${var.compartment_id}"
66+
#Optional
67+
domain = "${var.record_items_domain}"
68+
rdata = "${var.record_items_rdata}"
69+
rtype = "${var.record_items_rtype}"
70+
ttl = "${var.record_items_ttl}"
71+
}
72+
```
73+
74+
# oci_dns_records
75+
76+
## Records DataSource
77+
78+
Gets a list of records
79+
80+
### Get Operation
81+
Gets all records in the specified zone. The results are
82+
sorted by `domain` in alphabetical order by default. For more
83+
information about records, please see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
84+
85+
The following arguments are supported:
86+
87+
* `compartment_id` - (Optional) The OCID of the compartment the resource belongs to.
88+
* `domain` - (Optional) Search by domain. Will match any record whose domain (case-insensitive) equals the provided value.
89+
* `domain_contains` - (Optional) Search by domain. Will match any record whose domain (case-insensitive) contains the provided value.
90+
* `rtype` - (Optional) Search by record type. Will match any record whose [type](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4) (case-insensitive) equals the provided value.
91+
* `sort_by` - (Optional) The field by which to sort records. Allowed values are: domain|rtype|ttl
92+
* `sort_order` - The order to sort the resources. Allowed values are: ASC|DESC
93+
* `zone_name_or_id` - (Required) The name or OCID of the target zone.
94+
* `zone_version` - (Optional) The version of the zone for which data is requested.
95+
96+
97+
The following attributes are exported:
98+
99+
* `records` - A collection of DNS resource records.
100+
101+
102+
### Example Usage
103+
104+
```
105+
data "oci_dns_records" "test_records" {
106+
#Required
107+
zone_name_or_id = "${oci_dns_zone_name_or.test_zone_name_or.id}"
108+
109+
#Optional
110+
compartment_id = "${var.compartment_id}"
111+
domain = "${var.record_domain}"
112+
domain_contains = "${var.record_domain_contains}"
113+
rtype = "${var.record_rtype}"
114+
zone_version = "${var.record_zone_version}"
115+
}
116+
```

docs/dns/zones.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# oci_dns_zone
2+
3+
## Zone Resource
4+
5+
### Zone Reference
6+
7+
The following attributes are exported:
8+
* `compartment_id` - The OCID of the compartment containing the zone.
9+
* `external_masters` - External master servers for the zone.
10+
* `address` - The server's IP address (IPv4 or IPv6).
11+
* `port` - The server's port.
12+
* `tsig` - A TSIG key
13+
* `algorithm` - TSIG Algorithms are encoded as domain names, but most consist of only one non-empty label, which is not required to be explicitly absolute. For a full list of TSIG algorithms, see [Secret Key Transaction Authentication for DNS (TSIG) Algorithm Names](http://www.iana.org/assignments/tsig-algorithm-names/tsig-algorithm-names.xhtml#tsig-algorithm-names-1)
14+
* `name` - A domain name identifying the key for a given pair of hosts.
15+
* `secret` - A base64 string encoding the binary shared secret.
16+
* `name` - The name of the zone.
17+
* `self` - The canonical absolute URL of the resource.
18+
* `serial` - The current serial of the zone. As seen in the zone's SOA record.
19+
* `state` - The Zone's current state.
20+
* `time_created` - The date and time the Zone was created, in the format defined by RFC3339. Example: `2016-08-25T21:10:29.600Z`
21+
* `version` - Version is the never-repeating, totally-orderable, version of the zone, from which the serial field of the zone's SOA record is derived.
22+
* `zone_type` - The type of the zone. Must be either `PRIMARY` or `SECONDARY`.
23+
24+
25+
26+
### Create Operation
27+
Creates a new zone in the specified compartment.
28+
29+
30+
The following arguments are supported:
31+
32+
* `compartment_id` - (Required) The OCID of the compartment containing the zone.
33+
* `external_masters` - (Optional) External master servers for the zone.
34+
* `address` - (Required) The server's IP address (IPv4 or IPv6).
35+
* `port` - (Optional) The server's port.
36+
* `tsig` - (Optional)
37+
* `algorithm` - (Required) TSIG Algorithms are encoded as domain names, but most consist of only one non-empty label, which is not required to be explicitly absolute. For a full list of TSIG algorithms, see [Secret Key Transaction Authentication for DNS (TSIG) Algorithm Names](http://www.iana.org/assignments/tsig-algorithm-names/tsig-algorithm-names.xhtml#tsig-algorithm-names-1)
38+
* `name` - (Required) A domain name identifying the key for a given pair of hosts.
39+
* `secret` - (Required) A base64 string encoding the binary shared secret.
40+
* `name` - (Required) The name of the zone.
41+
* `zone_type` - (Required) The type of the zone. Must be either `PRIMARY` or `SECONDARY`.
42+
43+
44+
### Update Operation
45+
Updates the specified secondary zone with your new external master
46+
server information. For more information about secondary zone, see
47+
[Manage DNS Service Zone](https://docs.us-phoenix-1.oraclecloud.com/Content/DNS/Tasks/managingdnszones.htm).
48+
49+
50+
The following arguments support updates:
51+
* `external_masters` - External master servers for the zone.
52+
* `address` - The server's IP address (IPv4 or IPv6).
53+
* `port` - The server's port.
54+
* `tsig` -
55+
* `algorithm` - (Required) TSIG Algorithms are encoded as domain names, but most consist of only one non-empty label, which is not required to be explicitly absolute. For a full list of TSIG algorithms, see [Secret Key Transaction Authentication for DNS (TSIG) Algorithm Names](http://www.iana.org/assignments/tsig-algorithm-names/tsig-algorithm-names.xhtml#tsig-algorithm-names-1)
56+
* `name` - (Required) A domain name identifying the key for a given pair of hosts.
57+
* `secret` - (Required) A base64 string encoding the binary shared secret.
58+
59+
** IMPORTANT **
60+
Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values
61+
62+
### Example Usage
63+
64+
```
65+
resource "oci_dns_zone" "test_zone" {
66+
#Required
67+
compartment_id = "${var.compartment_id}"
68+
name = "${var.zone_name}"
69+
zone_type = "${var.zone_zone_type}"
70+
71+
#Optional
72+
external_masters {
73+
#Required
74+
address = "${var.zone_external_masters_address}"
75+
76+
#Optional
77+
port = "${var.zone_external_masters_port}"
78+
tsig {
79+
#Required
80+
algorithm = "${var.zone_external_masters_tsig_algorithm}"
81+
name = "${var.zone_external_masters_tsig_name}"
82+
secret = "${var.zone_external_masters_tsig_secret}"
83+
}
84+
}
85+
}
86+
```
87+
88+
# oci_dns_zones
89+
90+
## Zones DataSource
91+
92+
Gets a list of zones
93+
94+
### Get Operation
95+
Gets a list of all zones in the specified compartment. The collection
96+
can be filtered by name, time created, and zone type.
97+
98+
The following arguments are supported:
99+
100+
* `compartment_id` - (Required) The OCID of the compartment the resource belongs to.
101+
* `name` - (Optional) A case-sensitive filter for zone names. Will match any zone with a name that equals the provided value.
102+
* `name_contains` - (Optional) Search by zone name. Will match any zone whose name (case-insensitive) contains the provided value.
103+
* `sort_by` - (Optional) The field by which to sort zones. Allowed values are: name|zoneType|timeCreated
104+
* `sort_order` - The order to sort the resources. Allowed values are: ASC|DESC
105+
* `state` - (Optional) The state of a resource.
106+
* `time_created_greater_than_or_equal_to` - (Optional) An [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) timestamp that states all returned resources were created on or after the indicated time.
107+
* `time_created_less_than` - (Optional) An [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) timestamp that states all returned resources were created before the indicated time.
108+
* `zone_type` - (Optional) Search by zone type, `PRIMARY` or `SECONDARY`. Will match any zone whose type equals the provided value.
109+
110+
111+
The following attributes are exported:
112+
113+
* `zones` - A list of DNS zones.
114+
115+
### Example Usage
116+
117+
```
118+
data "oci_dns_zones" "test_zones" {
119+
#Required
120+
compartment_id = "${var.compartment_id}"
121+
122+
#Optional
123+
name = "${var.zone_name}"
124+
name_contains = "${var.zone_name_contains}"
125+
state = "${var.zone_state}"
126+
time_created_greater_than_or_equal_to = "${var.zone_time_created_greater_than_or_equal_to}"
127+
time_created_less_than = "${var.zone_time_created_less_than}"
128+
zone_type = "${var.zone_zone_type}"
129+
}
130+
```

docs/examples/dns/provider.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Provider config for dns sample
3+
*/
4+
5+
variable "tenancy_ocid" {}
6+
variable "user_ocid" {}
7+
variable "fingerprint" {}
8+
variable "private_key_path" {}
9+
variable "compartment_id" {}
10+
variable "region" {}
11+
12+
provider "oci" {
13+
region = "${var.region}"
14+
tenancy_ocid = "${var.tenancy_ocid}"
15+
user_ocid = "${var.user_ocid}"
16+
fingerprint = "${var.fingerprint}"
17+
private_key_path = "${var.private_key_path}"
18+
}

docs/examples/dns/records.tf

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* This file demonstrates dns record usage
3+
*/
4+
5+
resource "oci_dns_record" "record-a" {
6+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
7+
domain = "${oci_dns_zone.zone1.name}"
8+
rtype = "A"
9+
rdata = "192.168.0.1"
10+
ttl = 3600
11+
}
12+
13+
resource "oci_dns_record" "record-aaaa" {
14+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
15+
domain = "${oci_dns_zone.zone1.name}"
16+
rtype = "AAAA"
17+
rdata = "0000:0000:8a2e:0000:0000:0370:0000:0000"
18+
ttl = 3600
19+
}
20+
21+
resource "oci_dns_record" "record-cname" {
22+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
23+
domain = "el.${oci_dns_zone.zone1.name}"
24+
rtype = "CNAME"
25+
rdata = "${oci_dns_zone.zone1.name}"
26+
ttl = 86400
27+
}
28+
29+
resource "oci_dns_record" "record-alias" {
30+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
31+
domain = "${oci_dns_zone.zone1.name}"
32+
rtype = "ALIAS"
33+
rdata = "red.zone"
34+
ttl = 86400
35+
}
36+
37+
resource "oci_dns_record" "record-ns" {
38+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
39+
rtype = "NS"
40+
rdata = "ns5.p68.dns.oraclecloud.net"
41+
domain = "${oci_dns_zone.zone1.name}"
42+
ttl = 86400
43+
}
44+
45+
resource "oci_dns_record" "record-mx" {
46+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
47+
rtype = "MX"
48+
rdata = "10 mx.dns.oraclecloud.net"
49+
domain = "${oci_dns_zone.zone1.name}"
50+
ttl = 86400
51+
}
52+
53+
resource "oci_dns_record" "record-ptr" {
54+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
55+
rtype = "PTR"
56+
rdata = "some.other.domain.net"
57+
domain = "${oci_dns_zone.zone1.name}"
58+
ttl = 86400
59+
}
60+
61+
resource "oci_dns_record" "record-txt" {
62+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
63+
rtype = "TXT"
64+
rdata = "arbitrary text"
65+
domain = "${oci_dns_zone.zone1.name}"
66+
ttl = 86400
67+
}
68+
69+
70+
data "oci_dns_records" "rs" {
71+
zone_name_or_id = "${oci_dns_zone.zone1.name}"
72+
73+
# optional
74+
compartment_id = "${var.compartment_id}"
75+
domain = "${oci_dns_zone.zone1.name}"
76+
rtype = "NS"
77+
sort_by = "ttl" # domain|rtype|ttl
78+
sort_order = "DESC" # ASC|DESC
79+
}
80+
81+
output "records" {
82+
value = "${data.oci_dns_records.rs.records}"
83+
}

0 commit comments

Comments
 (0)