Skip to content

Commit a8a3c58

Browse files
committed
OAS-8725 | add enable-private-dns setting
1 parent ccd0518 commit a8a3c58

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

docs/resources/private_endpoint.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ resource "oasis_private_endpoint" "my_aws_private_endpoint" {
9393
name = "tf-private-endpoint-test"
9494
description = "Terraform generated AWS private endpoint"
9595
deployment = oasis_deployment.my_aws_oneshard_deployment.id
96+
enable_private_dns = true
9697
dns_names = ["test.example.com", "test2.example.com"]
9798
aws {
9899
principal {
@@ -117,6 +118,7 @@ resource "oasis_private_endpoint" "my_aws_private_endpoint" {
117118
- `aks` (Block List, Max: 1) Private Endpoint Resource Private Endpoint AKS field (see [below for nested schema](#nestedblock--aks))
118119
- `aws` (Block List, Max: 1) Private Endpoint Resource Private Endpoint AWS field (see [below for nested schema](#nestedblock--aws))
119120
- `description` (String) Private Endpoint Resource Private Endpoint Description field
121+
- `enable_private_dns` (Bool) If set, private DNS zone integration is enabled for this private endpoint service. For GCP this bool is immutable, so can only be set during the creation.
120122
- `dns_names` (List of String) Private Endpoint Resource Private Endpoint DNS Names field (list of dns names)
121123
- `gcp` (Block List, Max: 1) Private Endpoint Resource Private Endpoint GCP field (see [below for nested schema](#nestedblock--gcp))
122124

internal/resource_private_endpoint.go

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2022-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -33,10 +33,11 @@ import (
3333

3434
const (
3535
// Private Endpoint field names
36-
privateEndpointNameFieldName = "name"
37-
privateEndpointDescriptionFieldName = "description"
38-
privateEndpointDeploymentFieldName = "deployment"
39-
privateEndpointDNSNamesFieldName = "dns_names"
36+
privateEndpointNameFieldName = "name"
37+
privateEndpointDescriptionFieldName = "description"
38+
privateEndpointDeploymentFieldName = "deployment"
39+
prirvateEndpointEnablePrivateDNSFieldName = "enable_private_dns"
40+
privateEndpointDNSNamesFieldName = "dns_names"
4041

4142
// AKS field names
4243
privateEndpointAKSFieldName = "aks"
@@ -79,6 +80,11 @@ func resourcePrivateEndpoint() *schema.Resource {
7980
Description: "Private Endpoint Resource Private Endpoint Deployment ID field",
8081
Required: true,
8182
},
83+
prirvateEndpointEnablePrivateDNSFieldName: {
84+
Type: schema.TypeBool,
85+
Description: "Private Endpoint Resource Private Endpoint Enable Private DNS field",
86+
Optional: true,
87+
},
8288
privateEndpointDNSNamesFieldName: {
8389
Type: schema.TypeList,
8490
Description: "Private Endpoint Resource Private Endpoint DNS Names field (list of dns names)",
@@ -200,13 +206,14 @@ func resourcePrivateEndpointRead(ctx context.Context, d *schema.ResourceData, m
200206
// flattenPrivateEndpointResource will take a Private Endpoint object and turn it into a flat map for terraform digestion.
201207
func flattenPrivateEndpointResource(privateEndpoint *network.PrivateEndpointService) map[string]interface{} {
202208
return map[string]interface{}{
203-
privateEndpointNameFieldName: privateEndpoint.GetName(),
204-
privateEndpointDescriptionFieldName: privateEndpoint.GetDescription(),
205-
privateEndpointDeploymentFieldName: privateEndpoint.GetDeploymentId(),
206-
privateEndpointDNSNamesFieldName: privateEndpoint.GetAlternateDnsNames(),
207-
privateEndpointAKSFieldName: flattenAKSResource(privateEndpoint.GetAks()),
208-
privateEndpointAWSFieldName: flattenAWSResource(privateEndpoint.GetAws()),
209-
privateEndpointGCPFieldName: flattenGCPResource(privateEndpoint.GetGcp()),
209+
privateEndpointNameFieldName: privateEndpoint.GetName(),
210+
privateEndpointDescriptionFieldName: privateEndpoint.GetDescription(),
211+
privateEndpointDeploymentFieldName: privateEndpoint.GetDeploymentId(),
212+
prirvateEndpointEnablePrivateDNSFieldName: privateEndpoint.GetEnablePrivateDns(),
213+
privateEndpointDNSNamesFieldName: privateEndpoint.GetAlternateDnsNames(),
214+
privateEndpointAKSFieldName: flattenAKSResource(privateEndpoint.GetAks()),
215+
privateEndpointAWSFieldName: flattenAWSResource(privateEndpoint.GetAws()),
216+
privateEndpointGCPFieldName: flattenGCPResource(privateEndpoint.GetGcp()),
210217
}
211218
}
212219

@@ -308,6 +315,9 @@ func expandPrivateEndpointResource(d *schema.ResourceData) (*network.PrivateEndp
308315
} else {
309316
return nil, fmt.Errorf("unable to find parse field %s", privateEndpointDeploymentFieldName)
310317
}
318+
if v, ok := d.GetOk(prirvateEndpointEnablePrivateDNSFieldName); ok {
319+
ret.EnablePrivateDns = v.(bool)
320+
}
311321
if v, ok := d.GetOk(privateEndpointDNSNamesFieldName); ok {
312322
dnsNames, err := expandPrivateEndpointStringList(v.([]interface{}))
313323
if err != nil {
@@ -455,6 +465,9 @@ func resourcePrivateEndpointUpdate(ctx context.Context, d *schema.ResourceData,
455465
if d.HasChange(privateEndpointDescriptionFieldName) {
456466
privateEndpoint.Description = d.Get(privateEndpointDescriptionFieldName).(string)
457467
}
468+
if d.HasChange(prirvateEndpointEnablePrivateDNSFieldName) {
469+
privateEndpoint.EnablePrivateDns = d.Get(prirvateEndpointEnablePrivateDNSFieldName).(bool)
470+
}
458471
if d.HasChange(privateEndpointDNSNamesFieldName) {
459472
dnsNames, err := expandPrivateEndpointStringList(d.Get(privateEndpointDNSNamesFieldName).([]interface{}))
460473
if err != nil {

internal/resource_private_endpoint_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2022-2023 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -92,14 +92,16 @@ func TestFlattenPrivateEndpoint(t *testing.T) {
9292
Name: "test-private-endpoint",
9393
Description: "test-description",
9494
DeploymentId: deploymentId,
95+
EnablePrivateDns: true,
9596
AlternateDnsNames: []string{"test.example.com"},
9697
}
9798

9899
expected := map[string]interface{}{
99-
privateEndpointNameFieldName: "test-private-endpoint",
100-
privateEndpointDescriptionFieldName: "test-description",
101-
privateEndpointDeploymentFieldName: deploymentId,
102-
privateEndpointDNSNamesFieldName: []string{"test.example.com"},
100+
privateEndpointNameFieldName: "test-private-endpoint",
101+
privateEndpointDescriptionFieldName: "test-description",
102+
privateEndpointDeploymentFieldName: deploymentId,
103+
prirvateEndpointEnablePrivateDNSFieldName: true,
104+
privateEndpointDNSNamesFieldName: []string{"test.example.com"},
103105
}
104106

105107
t.Run("flattening with aks field", func(tt *testing.T) {

0 commit comments

Comments
 (0)