Skip to content

Commit 874d912

Browse files
Add support for domainNames to Service Attachment (#6003) (#11702)
Co-authored-by: Shuya Ma <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Shuya Ma <[email protected]>
1 parent 17fb961 commit 874d912

6 files changed

+49
-6
lines changed

.changelog/6003.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added support for `domain_names` attribute in `google_compute_service_attachment`
3+
```

google/resource_clouddeploy_delivery_pipeline_generated_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ resource "google_clouddeploy_delivery_pipeline" "primary" {
114114
description = "updated description"
115115
116116
labels = {
117-
my_third_label = "example-label-3"
118-
119117
my_second_label = "updated-example-label-2"
118+
119+
my_third_label = "example-label-3"
120120
}
121121
122122
project = "%{project_name}"

google/resource_clouddeploy_target_generated_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ resource "google_clouddeploy_target" "primary" {
9191
name = "tf-test-target%{random_suffix}"
9292
9393
annotations = {
94-
my_second_annotation = "example-annotation-2"
95-
9694
my_first_annotation = "example-annotation-1"
95+
96+
my_second_annotation = "example-annotation-2"
9797
}
9898
9999
description = "basic description"
@@ -175,9 +175,9 @@ resource "google_clouddeploy_target" "primary" {
175175
}
176176
177177
labels = {
178-
my_third_label = "example-label-3"
179-
180178
my_second_label = "updated-example-label-2"
179+
180+
my_third_label = "example-label-3"
181181
}
182182
183183
project = "%{project_name}"

google/resource_compute_service_attachment.go

+29
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ attachment.`,
118118
Optional: true,
119119
Description: `An optional description of this resource.`,
120120
},
121+
"domain_names": {
122+
Type: schema.TypeList,
123+
Optional: true,
124+
ForceNew: true,
125+
Description: `If specified, the domain name will be used during the integration between
126+
the PSC connected endpoints and the Cloud DNS. For example, this is a
127+
valid domain name: "p.mycompany.com.". Current max number of domain names
128+
supported is 1.`,
129+
Elem: &schema.Schema{
130+
Type: schema.TypeString,
131+
},
132+
},
121133
"region": {
122134
Type: schema.TypeString,
123135
Computed: true,
@@ -218,6 +230,12 @@ func resourceComputeServiceAttachmentCreate(d *schema.ResourceData, meta interfa
218230
} else if v, ok := d.GetOkExists("enable_proxy_protocol"); !isEmptyValue(reflect.ValueOf(enableProxyProtocolProp)) && (ok || !reflect.DeepEqual(v, enableProxyProtocolProp)) {
219231
obj["enableProxyProtocol"] = enableProxyProtocolProp
220232
}
233+
domainNamesProp, err := expandComputeServiceAttachmentDomainNames(d.Get("domain_names"), d, config)
234+
if err != nil {
235+
return err
236+
} else if v, ok := d.GetOkExists("domain_names"); !isEmptyValue(reflect.ValueOf(domainNamesProp)) && (ok || !reflect.DeepEqual(v, domainNamesProp)) {
237+
obj["domainNames"] = domainNamesProp
238+
}
221239
consumerRejectListsProp, err := expandComputeServiceAttachmentConsumerRejectLists(d.Get("consumer_reject_lists"), d, config)
222240
if err != nil {
223241
return err
@@ -341,6 +359,9 @@ func resourceComputeServiceAttachmentRead(d *schema.ResourceData, meta interface
341359
if err := d.Set("enable_proxy_protocol", flattenComputeServiceAttachmentEnableProxyProtocol(res["enableProxyProtocol"], d, config)); err != nil {
342360
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
343361
}
362+
if err := d.Set("domain_names", flattenComputeServiceAttachmentDomainNames(res["domainNames"], d, config)); err != nil {
363+
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
364+
}
344365
if err := d.Set("consumer_reject_lists", flattenComputeServiceAttachmentConsumerRejectLists(res["consumerRejectLists"], d, config)); err != nil {
345366
return fmt.Errorf("Error reading ServiceAttachment: %s", err)
346367
}
@@ -573,6 +594,10 @@ func flattenComputeServiceAttachmentEnableProxyProtocol(v interface{}, d *schema
573594
return v
574595
}
575596

597+
func flattenComputeServiceAttachmentDomainNames(v interface{}, d *schema.ResourceData, config *Config) interface{} {
598+
return v
599+
}
600+
576601
func flattenComputeServiceAttachmentConsumerRejectLists(v interface{}, d *schema.ResourceData, config *Config) interface{} {
577602
return v
578603
}
@@ -668,6 +693,10 @@ func expandComputeServiceAttachmentEnableProxyProtocol(v interface{}, d Terrafor
668693
return v, nil
669694
}
670695

696+
func expandComputeServiceAttachmentDomainNames(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
697+
return v, nil
698+
}
699+
671700
func expandComputeServiceAttachmentConsumerRejectLists(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
672701
return v, nil
673702
}

google/resource_compute_service_attachment_generated_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
5555
region = "us-west2"
5656
description = "A service attachment configured with Terraform"
5757
58+
domain_names = ["gcp.tfacc.hashicorptest.com."]
5859
enable_proxy_protocol = true
5960
connection_preference = "ACCEPT_AUTOMATIC"
6061
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
@@ -163,6 +164,7 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
163164
region = "us-west2"
164165
description = "A service attachment configured with Terraform"
165166
167+
domain_names = ["gcp.tfacc.hashicorptest.com."]
166168
enable_proxy_protocol = true
167169
connection_preference = "ACCEPT_MANUAL"
168170
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]

website/docs/r/compute_service_attachment.html.markdown

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
4545
region = "us-west2"
4646
description = "A service attachment configured with Terraform"
4747
48+
domain_names = ["gcp.tfacc.hashicorptest.com."]
4849
enable_proxy_protocol = true
4950
connection_preference = "ACCEPT_AUTOMATIC"
5051
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
@@ -133,6 +134,7 @@ resource "google_compute_service_attachment" "psc_ilb_service_attachment" {
133134
region = "us-west2"
134135
description = "A service attachment configured with Terraform"
135136
137+
domain_names = ["gcp.tfacc.hashicorptest.com."]
136138
enable_proxy_protocol = true
137139
connection_preference = "ACCEPT_MANUAL"
138140
nat_subnets = [google_compute_subnetwork.psc_ilb_nat.id]
@@ -258,6 +260,13 @@ The following arguments are supported:
258260
(Optional)
259261
An optional description of this resource.
260262

263+
* `domain_names` -
264+
(Optional)
265+
If specified, the domain name will be used during the integration between
266+
the PSC connected endpoints and the Cloud DNS. For example, this is a
267+
valid domain name: "p.mycompany.com.". Current max number of domain names
268+
supported is 1.
269+
261270
* `consumer_reject_lists` -
262271
(Optional)
263272
An array of projects that are not allowed to connect to this service

0 commit comments

Comments
 (0)