Skip to content

Commit dac6b8e

Browse files
Introduce Destination resource (GoogleCloudPlatform#16002)
1 parent 0b4839b commit dac6b8e

4 files changed

Lines changed: 345 additions & 2 deletions

File tree

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: 'Destination'
16+
description: |
17+
'Manage Multicloud Data Transfer Destinations'
18+
references:
19+
guides:
20+
'QUICKSTART_TITLE': 'https://docs.cloud.google.com/data-transfer-essentials/docs/create-resources'
21+
api: 'https://docs.cloud.google.com/network-connectivity/docs/reference/networkconnectivity/rest/v1/projects.locations.multicloudDataTransferConfigs.destinations'
22+
23+
base_url: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs/{{multicloud_data_transfer_config}}/destinations'
24+
self_link: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs/{{multicloud_data_transfer_config}}/destinations/{{name}}'
25+
26+
create_url: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs/{{multicloud_data_transfer_config}}/destinations?destination_id={{name}}'
27+
28+
update_verb: 'PATCH'
29+
update_mask: true
30+
31+
autogen_async: true
32+
33+
async:
34+
operation:
35+
base_url: '{{op_id}}'
36+
37+
examples:
38+
- name: "network_connectivity_destination_basic"
39+
primary_resource_id: "example"
40+
vars:
41+
config_name: "basic-config"
42+
destination_name: "basic-destination"
43+
44+
parameters:
45+
- name: 'multicloudDataTransferConfig'
46+
type: String
47+
required: true
48+
immutable: true
49+
url_param_only: true
50+
description: |
51+
The multicloud data transfer config of the destination.
52+
- name: 'location'
53+
type: String
54+
required: true
55+
immutable: true
56+
url_param_only: true
57+
description: |
58+
The location of the destination.
59+
- name: 'name'
60+
type: String
61+
required: true
62+
immutable: true
63+
url_param_only: true
64+
description: |
65+
The name of the destination.
66+
67+
properties:
68+
- name: 'createTime'
69+
type: Time
70+
output: true
71+
description: |
72+
Time when the `Destination` resource was created.
73+
- name: 'updateTime'
74+
type: Time
75+
output: true
76+
description: |
77+
Time when the `Destination` resource was updated.
78+
- name: 'labels'
79+
type: KeyValueLabels
80+
description: |
81+
User-defined labels.
82+
- name: 'etag'
83+
type: Fingerprint
84+
output: true
85+
description: |
86+
The etag is computed by the server, and might be sent with update and
87+
delete requests so that the client has an up-to-date value before
88+
proceeding.
89+
- name: 'description'
90+
type: String
91+
description: |
92+
A description of this resource.
93+
- name: 'ipPrefix'
94+
type: String
95+
required: true
96+
immutable: true
97+
description: |
98+
The IP prefix that represents your workload on another CSP.
99+
- name: 'endpoints'
100+
type: Array
101+
required: true
102+
is_set: true
103+
description: |
104+
The list of DestinationEndpoint resources configured for the IP prefix.
105+
item_type:
106+
type: NestedObject
107+
properties:
108+
- name: 'asn'
109+
type: String
110+
required: true
111+
description: |
112+
The ASN of the remote IP prefix.
113+
- name: 'csp'
114+
type: String
115+
required: true
116+
description: |
117+
The CSP of the remote IP prefix.
118+
- name: 'state'
119+
type: Enum
120+
output: true
121+
enum_values:
122+
- 'VALID'
123+
- 'INVALID'
124+
description: |
125+
The state of the DestinationEndpoint resource.
126+
- name: 'updateTime'
127+
type: Time
128+
output: true
129+
description: |
130+
Time when the DestinationEndpoint resource was updated.
131+
- name: 'stateTimeline'
132+
type: NestedObject
133+
output: true
134+
description: |
135+
The timeline of the expected `Destination` states or the current rest
136+
state. If a state change is expected, the value is `ADDING`,
137+
`DELETING` or `SUSPENDING`, depending on the action specified.
138+
properties:
139+
- name: 'states'
140+
type: Array
141+
output: true
142+
description: The state and activation time details of the resource state.
143+
item_type:
144+
type: NestedObject
145+
properties:
146+
- name: 'state'
147+
type: Enum
148+
output: true
149+
enum_values:
150+
- 'ADDING'
151+
- 'ACTIVE'
152+
- 'DELETING'
153+
- 'SUSPENDING'
154+
- 'SUSPENDED'
155+
description: 'The state of the resource.'
156+
- name: 'effectiveTime'
157+
type: Time
158+
output: true
159+
description: |
160+
Accompanies only the transient states, which include `ADDING`,
161+
`DELETING`, and `SUSPENDING`, to denote the time until which the
162+
transient state of the resource will be effective. For instance, if the
163+
state is `ADDING`, this field shows the time when the resource state
164+
transitions to `ACTIVE`.
165+
- name: 'uid'
166+
type: String
167+
output: true
168+
description: |
169+
The Google-generated unique ID for the `Destination` resource.
170+
This value is unique across all `Destination` resources.
171+
If a resource is deleted and another with the same name is
172+
created, the new resource is assigned a different and unique ID.

mmv1/products/networkconnectivity/MulticloudDataTransferConfig.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ references:
2323
base_url: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs'
2424
self_link: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs/{{name}}'
2525

26-
immutable: false
27-
2826
create_url: 'projects/{{project}}/locations/{{location}}/multicloudDataTransferConfigs?multicloudDataTransferConfigId={{name}}'
2927

3028
update_verb: 'PATCH'
@@ -74,6 +72,7 @@ properties:
7472
User-defined labels.
7573
- name: 'etag'
7674
type: Fingerprint
75+
output: true
7776
description: |
7877
The etag is computed by the server, and might be sent with update and
7978
delete requests so that the client has an up-to-date value before
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
resource "google_network_connectivity_multicloud_data_transfer_config" "config" {
2+
name = "{{index $.Vars "config_name"}}"
3+
location = "europe-west4"
4+
description = "A basic multicloud data transfer config for the destination example"
5+
}
6+
7+
resource "google_network_connectivity_destination" "{{$.PrimaryResourceId}}" {
8+
name = "{{index $.Vars "destination_name"}}"
9+
location = "europe-west4"
10+
multicloud_data_transfer_config = google_network_connectivity_multicloud_data_transfer_config.config.name
11+
description = "A basic destination"
12+
labels = {
13+
foo = "bar"
14+
}
15+
ip_prefix = "10.0.0.0/8"
16+
endpoints {
17+
asn = "14618"
18+
csp = "AWS"
19+
}
20+
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package networkconnectivity_test
19+
20+
import (
21+
"fmt"
22+
"log"
23+
"strconv"
24+
"strings"
25+
"testing"
26+
"time"
27+
28+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
29+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
30+
"github.com/hashicorp/terraform-plugin-testing/terraform"
31+
32+
"github.com/hashicorp/terraform-provider-google/google/acctest"
33+
"github.com/hashicorp/terraform-provider-google/google/envvar"
34+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
35+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
36+
37+
"google.golang.org/api/googleapi"
38+
)
39+
40+
var (
41+
_ = fmt.Sprintf
42+
_ = log.Print
43+
_ = strconv.Atoi
44+
_ = strings.Trim
45+
_ = time.Now
46+
_ = resource.TestMain
47+
_ = terraform.NewState
48+
_ = envvar.TestEnvVar
49+
_ = tpgresource.SetLabels
50+
_ = transport_tpg.Config{}
51+
_ = googleapi.Error{}
52+
)
53+
54+
func TestAccNetworkConnectivityDestination_update(t *testing.T) {
55+
t.Parallel()
56+
57+
context := map[string]interface{}{
58+
"random_suffix": acctest.RandString(t, 10),
59+
}
60+
61+
acctest.VcrTest(t, resource.TestCase{
62+
PreCheck: func() { acctest.AccTestPreCheck(t) },
63+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
64+
CheckDestroy: testAccCheckNetworkConnectivityDestinationDestroyProducer(t),
65+
Steps: []resource.TestStep{
66+
{
67+
Config: testAccNetworkConnectivityDestination_basic(context),
68+
},
69+
{
70+
ResourceName: "google_network_connectivity_destination.example",
71+
ImportState: true,
72+
ImportStateVerify: true,
73+
ImportStateVerifyIgnore: []string{"labels", "location", "multicloud_data_transfer_config", "name", "terraform_labels"},
74+
},
75+
{
76+
Config: testAccNetworkConnectivityDestination_update(context),
77+
ConfigPlanChecks: resource.ConfigPlanChecks{
78+
PreApply: []plancheck.PlanCheck{
79+
plancheck.ExpectResourceAction("google_network_connectivity_destination.example", plancheck.ResourceActionUpdate),
80+
},
81+
},
82+
},
83+
{
84+
ResourceName: "google_network_connectivity_destination.example",
85+
ImportState: true,
86+
ImportStateVerify: true,
87+
ImportStateVerifyIgnore: []string{"labels", "location", "multicloud_data_transfer_config", "name", "terraform_labels"},
88+
},
89+
},
90+
})
91+
}
92+
93+
func testAccNetworkConnectivityDestination_basic(context map[string]interface{}) string {
94+
return acctest.Nprintf(`
95+
resource "google_network_connectivity_multicloud_data_transfer_config" "config" {
96+
name = "tf-test-basic-config%{random_suffix}"
97+
location = "europe-west3"
98+
description = "A basic multicloud data transfer config for the destination example"
99+
services {
100+
service_name = "big-query"
101+
}
102+
services {
103+
service_name = "cloud-storage"
104+
}
105+
}
106+
107+
resource "google_network_connectivity_destination" "example" {
108+
name = "tf-test-basic-destination%{random_suffix}"
109+
location = "europe-west3"
110+
multicloud_data_transfer_config = google_network_connectivity_multicloud_data_transfer_config.config.name
111+
description = "A basic destination"
112+
labels = {
113+
foo = "bar"
114+
}
115+
ip_prefix = "10.0.0.0/8"
116+
endpoints {
117+
asn = "14618"
118+
csp = "AWS"
119+
}
120+
}
121+
`, context)
122+
}
123+
124+
func testAccNetworkConnectivityDestination_update(context map[string]interface{}) string {
125+
return acctest.Nprintf(`
126+
resource "google_network_connectivity_multicloud_data_transfer_config" "config" {
127+
name = "tf-test-basic-config%{random_suffix}"
128+
location = "europe-west3"
129+
description = "A basic multicloud data transfer config for the destination example"
130+
}
131+
132+
resource "google_network_connectivity_destination" "example" {
133+
name = "tf-test-basic-destination%{random_suffix}"
134+
location = "europe-west3"
135+
multicloud_data_transfer_config = google_network_connectivity_multicloud_data_transfer_config.config.name
136+
description = "Updated desfintion of basic destination"
137+
labels = {
138+
abc = "xyz"
139+
foo = "baz"
140+
}
141+
ip_prefix = "10.0.0.0/8"
142+
endpoints {
143+
asn = "45102"
144+
csp = "Alibaba"
145+
}
146+
endpoints {
147+
asn = "14618"
148+
csp = "AWS"
149+
}
150+
}
151+
`, context)
152+
}

0 commit comments

Comments
 (0)