Skip to content

Commit b5ce004

Browse files
committed
Field tsig has been removed from oci_dns_zone resource
1 parent 18986b0 commit b5ce004

19 files changed

+104
-150
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
## 4.35.0 (July 14, 2021)
1+
## 4.35.0 (Unreleased)
22

33
### Added
44
- Support for Oracle distribution of Hadoop with Big Data service
55
- Support for APM Synthetics service added
66
- Support for Regional VLANs added to `core`
77
- Support added for VCN DNS Namespace Collision Remediation
88

9+
### Deprecated
10+
- Field `tsig` has been removed from `oci_dns_zone` resource and will be a breaking change for customers who have it defined in their Terraform configuration file
11+
912
## 4.34.0 (July 07, 2021)
1013

1114
### Added

oci/dns_tsig_key_resource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ func (s *DnsTsigKeyResourceCrud) CreatedTarget() []string {
141141
}
142142

143143
func (s *DnsTsigKeyResourceCrud) DeletedPending() []string {
144-
return []string{}
144+
return []string{
145+
string(oci_dns.TsigKeyLifecycleStateDeleting),
146+
}
145147
}
146148

147149
func (s *DnsTsigKeyResourceCrud) DeletedTarget() []string {
148-
return []string{}
150+
return []string{
151+
string(oci_dns.TsigKeyLifecycleStateDeleted),
152+
}
149153
}
150154

151155
func (s *DnsTsigKeyResourceCrud) Create() error {

oci/dns_tsig_key_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"strconv"
1010
"testing"
11+
"time"
1112

1213
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
1314
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
@@ -247,10 +248,18 @@ func testAccCheckDnsTsigKeyDestroy(s *terraform.State) error {
247248

248249
request.RequestMetadata.RetryPolicy = getRetryPolicy(true, "dns")
249250

250-
_, err := client.GetTsigKey(context.Background(), request)
251+
response, err := client.GetTsigKey(context.Background(), request)
251252

252253
if err == nil {
253-
return fmt.Errorf("resource still exists")
254+
deletedLifecycleStates := map[string]bool{
255+
string(oci_dns.TsigKeyLifecycleStateDeleted): true,
256+
}
257+
if _, ok := deletedLifecycleStates[string(response.LifecycleState)]; !ok {
258+
//resource lifecycle state is not in expected deleted lifecycle states.
259+
return fmt.Errorf("resource lifecycle state: %s is not in expected deleted lifecycle states", response.LifecycleState)
260+
}
261+
//resource lifecycle state is in expected deleted lifecycle states. continue with next one.
262+
continue
254263
}
255264

256265
//Verify that exception is for '404 not found'.
@@ -297,6 +306,8 @@ func sweepDnsTsigKeyResource(compartment string) error {
297306
fmt.Printf("Error deleting TsigKey %s %s, It is possible that the resource is already deleted. Please verify manually \n", tsigKeyId, error)
298307
continue
299308
}
309+
waitTillCondition(testAccProvider, &tsigKeyId, tsigKeySweepWaitCondition, time.Duration(3*time.Minute),
310+
tsigKeySweepResponseFetchOperation, "dns", true)
300311
}
301312
}
302313
return nil
@@ -313,6 +324,7 @@ func getTsigKeyIds(compartment string) ([]string, error) {
313324

314325
listTsigKeysRequest := oci_dns.ListTsigKeysRequest{}
315326
listTsigKeysRequest.CompartmentId = &compartmentId
327+
listTsigKeysRequest.LifecycleState = oci_dns.TsigKeySummaryLifecycleStateActive
316328
listTsigKeysResponse, err := dnsClient.ListTsigKeys(context.Background(), listTsigKeysRequest)
317329

318330
if err != nil {
@@ -325,3 +337,21 @@ func getTsigKeyIds(compartment string) ([]string, error) {
325337
}
326338
return resourceIds, nil
327339
}
340+
341+
func tsigKeySweepWaitCondition(response common.OCIOperationResponse) bool {
342+
// Only stop if the resource is available beyond 3 mins. As there could be an issue for the sweeper to delete the resource and manual intervention required.
343+
if tsigKeyResponse, ok := response.Response.(oci_dns.GetTsigKeyResponse); ok {
344+
return tsigKeyResponse.LifecycleState != oci_dns.TsigKeyLifecycleStateDeleted
345+
}
346+
return false
347+
}
348+
349+
func tsigKeySweepResponseFetchOperation(client *OracleClients, resourceId *string, retryPolicy *common.RetryPolicy) error {
350+
_, err := client.dnsClient().GetTsigKey(context.Background(), oci_dns.GetTsigKeyRequest{
351+
TsigKeyId: resourceId,
352+
RequestMetadata: common.RequestMetadata{
353+
RetryPolicy: retryPolicy,
354+
},
355+
})
356+
return err
357+
}

oci/dns_zone_resource.go

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,6 @@ func DnsZoneResource() *schema.Resource {
7777
Optional: true,
7878
Computed: true,
7979
},
80-
"tsig": {
81-
Type: schema.TypeList,
82-
Optional: true,
83-
Computed: true,
84-
MaxItems: 1,
85-
MinItems: 1,
86-
Elem: &schema.Resource{
87-
Schema: map[string]*schema.Schema{
88-
// Required
89-
"algorithm": {
90-
Type: schema.TypeString,
91-
Required: true,
92-
},
93-
"name": {
94-
Type: schema.TypeString,
95-
Required: true,
96-
},
97-
"secret": {
98-
Type: schema.TypeString,
99-
Required: true,
100-
Sensitive: true,
101-
},
102-
103-
// Optional
104-
105-
// Computed
106-
},
107-
},
108-
},
10980
"tsig_key_id": {
11081
Type: schema.TypeString,
11182
Optional: true,
@@ -500,17 +471,6 @@ func (s *DnsZoneResourceCrud) mapToExternalMaster(fieldKeyFormat string) (oci_dn
500471
result.Port = &tmp
501472
}
502473

503-
if tsig, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "tsig")); ok {
504-
if tmpList := tsig.([]interface{}); len(tmpList) > 0 {
505-
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "tsig"), 0)
506-
tmp, err := s.mapToTSIG(fieldKeyFormatNextLevel)
507-
if err != nil {
508-
return result, fmt.Errorf("unable to convert tsig, encountered error: %v", err)
509-
}
510-
result.Tsig = &tmp
511-
}
512-
}
513-
514474
if tsigKeyId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "tsig_key_id")); ok {
515475
tmp := tsigKeyId.(string)
516476
result.TsigKeyId = &tmp
@@ -530,10 +490,6 @@ func ExternalMasterToMap(obj oci_dns.ExternalMaster) map[string]interface{} {
530490
result["port"] = int(*obj.Port)
531491
}
532492

533-
if obj.Tsig != nil {
534-
result["tsig"] = []interface{}{TSIGToMap(obj.Tsig)}
535-
}
536-
537493
if obj.TsigKeyId != nil {
538494
result["tsig_key_id"] = string(*obj.TsigKeyId)
539495
}
@@ -551,45 +507,6 @@ func NameserverToMap(obj oci_dns.Nameserver) map[string]interface{} {
551507
return result
552508
}
553509

554-
func (s *DnsZoneResourceCrud) mapToTSIG(fieldKeyFormat string) (oci_dns.Tsig, error) {
555-
result := oci_dns.Tsig{}
556-
557-
if algorithm, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "algorithm")); ok {
558-
tmp := algorithm.(string)
559-
result.Algorithm = &tmp
560-
}
561-
562-
if name, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "name")); ok {
563-
tmp := name.(string)
564-
result.Name = &tmp
565-
}
566-
567-
if secret, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "secret")); ok {
568-
tmp := secret.(string)
569-
result.Secret = &tmp
570-
}
571-
572-
return result, nil
573-
}
574-
575-
func TSIGToMap(obj *oci_dns.Tsig) map[string]interface{} {
576-
result := map[string]interface{}{}
577-
578-
if obj.Algorithm != nil {
579-
result["algorithm"] = string(*obj.Algorithm)
580-
}
581-
582-
if obj.Name != nil {
583-
result["name"] = string(*obj.Name)
584-
}
585-
586-
if obj.Secret != nil {
587-
result["secret"] = string(*obj.Secret)
588-
}
589-
590-
return result
591-
}
592-
593510
func (s *DnsZoneResourceCrud) updateCompartment(compartment interface{}) error {
594511
changeCompartmentRequest := oci_dns.ChangeZoneCompartmentRequest{}
595512

oci/dns_zones_data_source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func DnsZonesDataSource() *schema.Resource {
5757
Type: schema.TypeString,
5858
Optional: true,
5959
},
60+
"tsig_key_id": {
61+
Type: schema.TypeString,
62+
Optional: true,
63+
},
6064
"view_id": {
6165
Type: schema.TypeString,
6266
Optional: true,
@@ -144,6 +148,11 @@ func (s *DnsZonesDataSourceCrud) Get() error {
144148
request.TimeCreatedLessThan = &oci_common.SDKTime{Time: tmp}
145149
}
146150

151+
if tsigKeyId, ok := s.D.GetOkExists("tsig_key_id"); ok {
152+
tmp := tsigKeyId.(string)
153+
request.TsigKeyId = &tmp
154+
}
155+
147156
if viewId, ok := s.D.GetOkExists("view_id"); ok {
148157
tmp := viewId.(string)
149158
request.ViewId = &tmp

website/docs/d/dns_records.html.markdown

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ description: |-
1313

1414
This data source provides the list of Records in Oracle Cloud Infrastructure DNS service.
1515

16-
Gets all records in the specified zone. The results are
17-
sorted by `domain` in alphabetical order by default. For more
18-
information about records, see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
16+
Gets all records in the specified zone. The results are sorted by `domain` in alphabetical order by default.
17+
For more information about records, see [Resource Record (RR) TYPEs](https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
18+
For private zones, the scope query parameter is required with a value of `PRIVATE`. When the zone name is
19+
provided as a path parameter and `PRIVATE` is used for the scope query parameter then the viewId query
20+
parameter is required.
1921

2022

2123
## Example Usage

website/docs/d/dns_resolver.html.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ description: |-
1010
# Data Source: oci_dns_resolver
1111
This data source provides details about a specific Resolver resource in Oracle Cloud Infrastructure DNS service.
1212

13-
Get information about a specific resolver. Note that attempting to get a
14-
resolver in the DELETED lifecycleState will result in a 404 to be
15-
consistent with other operations of the API.
13+
Gets information about a specific resolver. Note that attempting to get a
14+
resolver in the DELETED lifecycleState will result in a `404` response to be
15+
consistent with other operations of the API. Requires a `PRIVATE` scope query parameter.
1616

1717

1818
## Example Usage
@@ -54,8 +54,8 @@ The following attributes are exported:
5454
* `forwarding_address` - An IP address from which forwarded queries may be sent. For VNIC endpoints, this IP address must be part of the subnet and will be assigned by the system if unspecified when isForwarding is true.
5555
* `is_forwarding` - A Boolean flag indicating whether or not the resolver endpoint is for forwarding.
5656
* `is_listening` - A Boolean flag indicating whether or not the resolver endpoint is for listening.
57-
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified.
58-
* `name` - The name of the resolver endpoint. Must be unique within the resolver.
57+
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified when isListening is true.
58+
* `name` - The name of the resolver endpoint. Must be unique, case-insensitive, within the resolver.
5959
* `self` - The canonical absolute URL of the resource.
6060
* `state` - The current state of the resource.
6161
* `subnet_id` - The OCID of a subnet. Must be part of the VCN that the resolver is attached to.
@@ -71,12 +71,12 @@ The following attributes are exported:
7171
* `id` - The OCID of the resolver.
7272
* `is_protected` - A Boolean flag indicating whether or not parts of the resource are unable to be explicitly managed.
7373
* `rules` - Rules for the resolver. Rules are evaluated in order.
74-
* `action` - The action determines the behavior of the rule. If a query matches a supplied condition then the action will apply. If there are no conditions on the rule then all queries are subject to the specified action.
74+
* `action` - The action determines the behavior of the rule. If a query matches a supplied condition, the action will apply. If there are no conditions on the rule, all queries are subject to the specified action.
7575
* `FORWARD` - Matching requests will be forwarded from the source interface to the destination address.
7676
* `client_address_conditions` - A list of CIDR blocks. The query must come from a client within one of the blocks in order for the rule action to apply.
7777
* `destination_addresses` - IP addresses to which queries should be forwarded. Currently limited to a single address.
7878
* `qname_cover_conditions` - A list of domain names. The query must be covered by one of the domains in order for the rule action to apply.
79-
* `source_endpoint_name` - Name of an endpoint, that is a sub-resource of the resolver, to use as the forwarding interface. The endpoint must have isForwarding set to true.
79+
* `source_endpoint_name` - Case-insensitive name of an endpoint, that is a sub-resource of the resolver, to use as the forwarding interface. The endpoint must have isForwarding set to true.
8080
* `self` - The canonical absolute URL of the resource.
8181
* `state` - The current state of the resource.
8282
* `time_created` - The date and time the resource was created in "YYYY-MM-ddThh:mm:ssZ" format with a Z offset, as defined by RFC 3339.

website/docs/d/dns_resolver_endpoint.html.markdown

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ description: |-
1010
# Data Source: oci_dns_resolver_endpoint
1111
This data source provides details about a specific Resolver Endpoint resource in Oracle Cloud Infrastructure DNS service.
1212

13-
Get information about a specific resolver endpoint. Note that attempting to get a resolver endpoint
14-
in the DELETED lifecycle state will result in a 404 to be consistent with other operations of the API.
13+
Gets information about a specific resolver endpoint. Note that attempting to get a resolver endpoint
14+
in the DELETED lifecycle state will result in a `404` response to be consistent with other operations of the
15+
API. Requires a `PRIVATE` scope query parameter.
1516

1617

1718
## Example Usage
@@ -45,9 +46,9 @@ The following attributes are exported:
4546
* `forwarding_address` - An IP address from which forwarded queries may be sent. For VNIC endpoints, this IP address must be part of the subnet and will be assigned by the system if unspecified when isForwarding is true.
4647
* `is_forwarding` - A Boolean flag indicating whether or not the resolver endpoint is for forwarding.
4748
* `is_listening` - A Boolean flag indicating whether or not the resolver endpoint is for listening.
48-
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified.
49-
* `name` - The name of the resolver endpoint. Must be unique within the resolver.
50-
* `nsg_ids` - An array of NSG OCIDs for the resolver endpoint.
49+
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified when isListening is true.
50+
* `name` - The name of the resolver endpoint. Must be unique, case-insensitive, within the resolver.
51+
* `nsg_ids` - An array of network security group OCIDs for the resolver endpoint. These must be part of the VCN that the resolver endpoint is a part of.
5152
* `self` - The canonical absolute URL of the resource.
5253
* `state` - The current state of the resource.
5354
* `subnet_id` - The OCID of a subnet. Must be part of the VCN that the resolver is attached to.

website/docs/d/dns_resolver_endpoints.html.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ This data source provides the list of Resolver Endpoints in Oracle Cloud Infrast
1212

1313
Gets a list of all endpoints within a resolver. The collection can be filtered by name or lifecycle state.
1414
It can be sorted on creation time or name both in ASC or DESC order. Note that when no lifecycleState
15-
query parameter is provided that the collection does not include resolver endpoints in the DELETED
16-
lifecycle state to be consistent with other operations of the API.
15+
query parameter is provided, the collection does not include resolver endpoints in the DELETED
16+
lifecycle state to be consistent with other operations of the API. Requires a `PRIVATE` scope query parameter.
1717

1818

1919
## Example Usage
@@ -55,9 +55,9 @@ The following attributes are exported:
5555
* `forwarding_address` - An IP address from which forwarded queries may be sent. For VNIC endpoints, this IP address must be part of the subnet and will be assigned by the system if unspecified when isForwarding is true.
5656
* `is_forwarding` - A Boolean flag indicating whether or not the resolver endpoint is for forwarding.
5757
* `is_listening` - A Boolean flag indicating whether or not the resolver endpoint is for listening.
58-
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified.
59-
* `name` - The name of the resolver endpoint. Must be unique within the resolver.
60-
* `nsg_ids` - An array of NSG OCIDs for the resolver endpoint.
58+
* `listening_address` - An IP address to listen to queries on. For VNIC endpoints this IP address must be part of the subnet and will be assigned by the system if unspecified when isListening is true.
59+
* `name` - The name of the resolver endpoint. Must be unique, case-insensitive, within the resolver.
60+
* `nsg_ids` - An array of network security group OCIDs for the resolver endpoint. These must be part of the VCN that the resolver endpoint is a part of.
6161
* `self` - The canonical absolute URL of the resource.
6262
* `state` - The current state of the resource.
6363
* `subnet_id` - The OCID of a subnet. Must be part of the VCN that the resolver is attached to.

website/docs/d/dns_resolvers.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ This data source provides the list of Resolvers in Oracle Cloud Infrastructure D
1313
Gets a list of all resolvers within a compartment. The collection can
1414
be filtered by display name, id, or lifecycle state. It can be sorted
1515
on creation time or displayName both in ASC or DESC order. Note that
16-
when no lifecycleState query parameter is provided that the collection
16+
when no lifecycleState query parameter is provided, the collection
1717
does not include resolvers in the DELETED lifecycleState to be consistent
18-
with other operations of the API.
18+
with other operations of the API. Requires a `PRIVATE` scope query parameter.
1919

2020

2121
## Example Usage

0 commit comments

Comments
 (0)