Skip to content

Commit 388617f

Browse files
Added DataExchangeSubscription Resource to BigQueryAnalyticsHub (#14370) (#23560)
[upstream:e6f7c988077c2ccf8aba39c0cf5d0ab8cd10312f] Signed-off-by: Modular Magician <[email protected]>
1 parent 63da718 commit 388617f

File tree

3 files changed

+352
-0
lines changed

3 files changed

+352
-0
lines changed

.changelog/14370.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_bigquery_analytics_hub_data_exchange_subscription`
3+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_dataexchangesubscription_test.go.tmpl
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package bigqueryanalyticshub_test
Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This code is generated by Magic Modules using the following:
9+
#
10+
# Configuration: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/bigqueryanalyticshub/DataExchangeSubscription.yaml
11+
# Template: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/resource.html.markdown.tmpl
12+
#
13+
# DO NOT EDIT this file directly. Any changes made to this file will be
14+
# overwritten during the next generation cycle.
15+
#
16+
# ----------------------------------------------------------------------------
17+
subcategory: "BigQuery Analytics Hub"
18+
description: |-
19+
A Bigquery Analytics Hub Data Exchange subscription
20+
---
21+
22+
# google_bigquery_analytics_hub_data_exchange_subscription
23+
24+
A Bigquery Analytics Hub Data Exchange subscription
25+
26+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
27+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
28+
29+
To get more information about DataExchangeSubscription, see:
30+
31+
* [API documentation](https://cloud.google.com/bigquery/docs/reference/analytics-hub/rest/v1/projects.locations.subscriptions)
32+
* How-to Guides
33+
* [Official Documentation](https://cloud.google.com/bigquery/docs/analytics-hub-introduction)
34+
35+
~> **Note:** When importing the resource with `terraform import`, provide the destination/subscriber's project and location
36+
in the format projects/{{subscriber_project}}/locations/{{subscriber_location}}/subscriptions/{{subscription_id}}
37+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
38+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=bigquery_analyticshub_dataexchange_subscription_basic&open_in_editor=main.tf" target="_blank">
39+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
40+
</a>
41+
</div>
42+
## Example Usage - Bigquery Analyticshub Dataexchange Subscription Basic
43+
44+
45+
```hcl
46+
resource "google_bigquery_analytics_hub_data_exchange" "subscription" {
47+
provider = google-beta
48+
location = "us"
49+
data_exchange_id = "my_test_dataexchange"
50+
display_name = "my_test_dataexchange"
51+
description = "Test Data Exchange"
52+
sharing_environment_config {
53+
dcr_exchange_config {}
54+
}
55+
}
56+
57+
resource "google_bigquery_dataset" "subscription" {
58+
provider = google-beta
59+
dataset_id = "listing_src_dataset"
60+
friendly_name = "listing_src_dataset"
61+
description = "Dataset for Listing"
62+
location = "us"
63+
}
64+
65+
resource "google_bigquery_table" "subscription" {
66+
provider = google-beta
67+
deletion_protection = false
68+
table_id = "listing_src_table"
69+
dataset_id = google_bigquery_dataset.subscription.dataset_id
70+
schema = <<EOF
71+
[
72+
{
73+
"name": "name",
74+
"type": "STRING",
75+
"mode": "NULLABLE"
76+
},
77+
{
78+
"name": "post_abbr",
79+
"type": "STRING",
80+
"mode": "NULLABLE"
81+
},
82+
{
83+
"name": "date",
84+
"type": "DATE",
85+
"mode": "NULLABLE"
86+
}
87+
]
88+
EOF
89+
}
90+
91+
resource "google_bigquery_analytics_hub_listing" "subscription" {
92+
provider = google-beta
93+
location = "us"
94+
data_exchange_id = google_bigquery_analytics_hub_data_exchange.subscription.data_exchange_id
95+
listing_id = "my_test_listing"
96+
display_name = "my_test_listing"
97+
description = "Test Listing"
98+
99+
restricted_export_config {
100+
enabled = true
101+
}
102+
103+
bigquery_dataset {
104+
dataset = google_bigquery_dataset.subscription.id
105+
selected_resources {
106+
table = google_bigquery_table.subscription.id
107+
}
108+
}
109+
}
110+
111+
resource "google_bigquery_analytics_hub_data_exchange_subscription" "subscription" {
112+
provider = google-beta
113+
project = google_bigquery_dataset.subscription.project #Subscriber's project
114+
location = "us"
115+
116+
data_exchange_project = google_bigquery_analytics_hub_data_exchange.subscription.project
117+
data_exchange_location = google_bigquery_analytics_hub_data_exchange.subscription.location
118+
data_exchange_id = google_bigquery_analytics_hub_data_exchange.subscription.data_exchange_id
119+
120+
subscription_id = "my_subscription_id"
121+
subscriber_contact = "[email protected]"
122+
123+
destination_dataset {
124+
location = "us"
125+
126+
dataset_reference {
127+
project_id = google_bigquery_dataset.subscription.project #Subscriber's project
128+
dataset_id = "subscribed_dest_dataset"
129+
}
130+
friendly_name = "Subscribed Destination Dataset"
131+
description = "Destination dataset for subscription"
132+
labels = {
133+
environment = "development"
134+
owner = "team-a"
135+
}
136+
}
137+
138+
refresh_policy="ON_READ"
139+
}
140+
```
141+
142+
## Argument Reference
143+
144+
The following arguments are supported:
145+
146+
147+
* `data_exchange_id` -
148+
(Required)
149+
The ID of the data exchange. Must contain only Unicode letters, numbers (0-9), underscores (_). Should not use characters that require URL-escaping, or characters outside of ASCII, spaces.
150+
151+
* `data_exchange_project` -
152+
(Required)
153+
The ID of the Google Cloud project where the Data Exchange is located.
154+
155+
* `data_exchange_location` -
156+
(Required)
157+
The name of the location of the Data Exchange.
158+
159+
* `location` -
160+
(Required)
161+
The geographic location where the Subscription (and its linked dataset) should reside.
162+
This is the subscriber's desired location for the created resources.
163+
See https://cloud.google.com/bigquery/docs/locations for supported locations.
164+
165+
* `subscription_id` -
166+
(Required)
167+
Name of the subscription to create.
168+
169+
170+
* `subscriber_contact` -
171+
(Optional)
172+
Email of the subscriber.
173+
174+
* `destination_dataset` -
175+
(Optional)
176+
BigQuery destination dataset to create for the subscriber.
177+
Structure is [documented below](#nested_destination_dataset).
178+
179+
* `project` - (Optional) The ID of the project in which the resource belongs.
180+
If it is not provided, the provider project is used.
181+
182+
* `refresh_policy` - (Optional) Controls when the subscription is automatically refreshed by the provider.
183+
* `ON_READ`: Default value if not specified. The subscription will be refreshed every time Terraform performs a read operation (e.g., `terraform plan`, `terraform apply`, `terraform refresh`). This ensures the state is always up-to-date.
184+
* `ON_STALE`: The subscription will only be refreshed when its reported `state` (an output-only field from the API) is `STATE_STALE` during a Terraform read operation.
185+
* `NEVER`: The provider will not automatically refresh the subscription.
186+
187+
188+
<a name="nested_destination_dataset"></a>The `destination_dataset` block supports:
189+
190+
* `location` -
191+
(Required)
192+
The geographic location where the dataset should reside.
193+
See https://cloud.google.com/bigquery/docs/locations for supported locations.
194+
195+
* `dataset_reference` -
196+
(Required)
197+
A reference that identifies the destination dataset.
198+
Structure is [documented below](#nested_destination_dataset_dataset_reference).
199+
200+
* `friendly_name` -
201+
(Optional)
202+
A descriptive name for the dataset.
203+
204+
* `description` -
205+
(Optional)
206+
A user-friendly description of the dataset.
207+
208+
* `labels` -
209+
(Optional)
210+
The labels associated with this dataset. You can use these to
211+
organize and group your datasets.
212+
213+
214+
<a name="nested_destination_dataset_dataset_reference"></a>The `dataset_reference` block supports:
215+
216+
* `dataset_id` -
217+
(Required)
218+
A unique ID for this dataset, without the project name. The ID must contain only letters (a-z, A-Z), numbers (0-9), or underscores (_). The maximum length is 1,024 characters.
219+
220+
* `project_id` -
221+
(Required)
222+
The ID of the project containing this dataset.
223+
224+
## Attributes Reference
225+
226+
In addition to the arguments listed above, the following computed attributes are exported:
227+
228+
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/subscriptions/{{subscription_id}}`
229+
230+
* `name` -
231+
The resource name of the subscription. e.g. "projects/myproject/locations/us/subscriptions/123"
232+
233+
* `creation_time` -
234+
Timestamp when the subscription was created.
235+
236+
* `last_modify_time` -
237+
Timestamp when the subscription was last modified.
238+
239+
* `organization_id` -
240+
Organization of the project this subscription belongs to.
241+
242+
* `organization_display_name` -
243+
Display name of the project of this subscription.
244+
245+
* `state` -
246+
Current state of the subscription.
247+
248+
* `resource_type` -
249+
Listing shared asset type.
250+
251+
* `linked_dataset_map` -
252+
Output only. Map of listing resource names to associated linked resource,
253+
e.g. projects/123/locations/us/dataExchanges/456/listings/789 -> projects/123/datasets/my_dataset
254+
For Data Exchange subscriptions, this map may contain multiple entries if the Data Exchange has multiple listings.
255+
Structure is [documented below](#nested_linked_dataset_map).
256+
257+
* `linked_resources` -
258+
Output only. Linked resources created in the subscription. Only contains values if state = STATE_ACTIVE.
259+
Structure is [documented below](#nested_linked_resources).
260+
261+
* `data_exchange` -
262+
Output only. Resource name of the source Data Exchange. e.g. projects/123/locations/us/dataExchanges/456
263+
264+
* `log_linked_dataset_query_user_email` -
265+
Output only. By default, false. If true, the Subscriber agreed to the email sharing mandate that is enabled for DataExchange/Listing.
266+
267+
268+
<a name="nested_linked_dataset_map"></a>The `linked_dataset_map` block contains:
269+
270+
* `resource_name` - (Required) The identifier for this object. Format specified above.
271+
272+
* `listing` -
273+
(Output)
274+
Output only. Listing for which linked resource is created.
275+
276+
* `linked_dataset` -
277+
(Output)
278+
Output only. Name of the linked dataset, e.g. projects/subscriberproject/datasets/linkedDataset
279+
280+
* `linked_pubsub_subscription` -
281+
(Output)
282+
Output only. Name of the Pub/Sub subscription, e.g. projects/subscriberproject/subscriptions/subscriptions/sub_id
283+
284+
<a name="nested_linked_resources"></a>The `linked_resources` block contains:
285+
286+
* `listing` -
287+
(Output)
288+
Output only. Listing for which linked resource is created.
289+
290+
* `linked_dataset` -
291+
(Output)
292+
Output only. Name of the linked dataset, e.g. projects/subscriberproject/datasets/linkedDataset
293+
294+
## Timeouts
295+
296+
This resource provides the following
297+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
298+
299+
- `create` - Default is 20 minutes.
300+
- `update` - Default is 20 minutes.
301+
- `delete` - Default is 20 minutes.
302+
303+
## Import
304+
305+
306+
DataExchangeSubscription can be imported using any of these accepted formats:
307+
308+
* `projects/{{project}}/locations/{{location}}/subscriptions/{{subscription_id}}`
309+
* `{{project}}/{{location}}/{{subscription_id}}`
310+
* `{{location}}/{{subscription_id}}`
311+
312+
313+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import DataExchangeSubscription using one of the formats above. For example:
314+
315+
```tf
316+
import {
317+
id = "projects/{{project}}/locations/{{location}}/subscriptions/{{subscription_id}}"
318+
to = google_bigquery_analytics_hub_data_exchange_subscription.default
319+
}
320+
```
321+
322+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), DataExchangeSubscription can be imported using one of the formats above. For example:
323+
324+
```
325+
$ terraform import google_bigquery_analytics_hub_data_exchange_subscription.default projects/{{project}}/locations/{{location}}/subscriptions/{{subscription_id}}
326+
$ terraform import google_bigquery_analytics_hub_data_exchange_subscription.default {{project}}/{{location}}/{{subscription_id}}
327+
$ terraform import google_bigquery_analytics_hub_data_exchange_subscription.default {{location}}/{{subscription_id}}
328+
```
329+
330+
## User Project Overrides
331+
332+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)