Skip to content

Commit

Permalink
private-googleapis data source support
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
drebes authored and modular-magician committed Aug 28, 2019
1 parent 1dc8e3b commit 4ce3c46
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 205 deletions.
8 changes: 7 additions & 1 deletion google/data_source_google_netblock_ip_ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ func dataSourceGoogleNetblockIpRangesRead(d *schema.ResourceData, meta interface
d.Set("cidr_blocks_ipv6", CidrBlocks["cidr_blocks_ipv6"])
// Static ranges
case "restricted-googleapis":
// https://cloud.google.com/vpc/docs/configure-private-google-access-hybrid
// https://cloud.google.com/vpc/docs/private-access-options#domain-vips
CidrBlocks["cidr_blocks_ipv4"] = append(CidrBlocks["cidr_blocks_ipv4"], "199.36.153.4/30")
CidrBlocks["cidr_blocks"] = CidrBlocks["cidr_blocks_ipv4"]
d.Set("cidr_blocks", CidrBlocks["cidr_blocks"])
d.Set("cidr_blocks_ipv4", CidrBlocks["cidr_blocks_ipv4"])
case "private-googleapis":
// https://cloud.google.com/vpc/docs/private-access-options#domain-vips
CidrBlocks["cidr_blocks_ipv4"] = append(CidrBlocks["cidr_blocks_ipv4"], "199.36.153.8/30")
CidrBlocks["cidr_blocks"] = CidrBlocks["cidr_blocks_ipv4"]
d.Set("cidr_blocks", CidrBlocks["cidr_blocks"])
d.Set("cidr_blocks_ipv4", CidrBlocks["cidr_blocks_ipv4"])
case "dns-forwarders":
// https://cloud.google.com/dns/zones/#creating-forwarding-zones
CidrBlocks["cidr_blocks_ipv4"] = append(CidrBlocks["cidr_blocks_ipv4"], "35.199.192.0/19")
Expand Down
19 changes: 19 additions & 0 deletions google/data_source_google_netblock_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ func TestAccDataSourceGoogleNetblockIpRanges_basic(t *testing.T) {
resource.TestCheckResourceAttr("data.google_netblock_ip_ranges.restricted", "cidr_blocks_ipv6.#", "0"),
),
},
{
Config: testAccNetblockIpRangesConfig_private,
Check: resource.ComposeTestCheckFunc(
// Private Google Access Unrestricted VIP
resource.TestCheckResourceAttr("data.google_netblock_ip_ranges.private", "cidr_blocks.#", "1"),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.private",
"cidr_blocks.0", regexp.MustCompile("^(?:[0-9a-fA-F./:]{1,4}){1,2}.*/[0-9]{1,3}$")),
resource.TestCheckResourceAttr("data.google_netblock_ip_ranges.private", "cidr_blocks_ipv4.#", "1"),
resource.TestMatchResourceAttr("data.google_netblock_ip_ranges.private",
"cidr_blocks_ipv4.0", regexp.MustCompile("^(?:[0-9]{1,3}.){3}[0-9]{1,3}/[0-9]{1,2}$")),
resource.TestCheckResourceAttr("data.google_netblock_ip_ranges.private", "cidr_blocks_ipv6.#", "0"),
),
},
{
Config: testAccNetblockIpRangesConfig_dns,
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -133,6 +146,12 @@ data "google_netblock_ip_ranges" "restricted" {
}
`

const testAccNetblockIpRangesConfig_private = `
data "google_netblock_ip_ranges" "private" {
range_type = "private-googleapis"
}
`

const testAccNetblockIpRangesConfig_dns = `
data "google_netblock_ip_ranges" "dns" {
range_type = "dns-forwarders"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ The following arguments are supported:

* `google-netblocks` - Corresponds to IP addresses used for Google services. [More details.](https://support.google.com/a/answer/33786?hl=en)

* `restricted-googleapis` - Corresponds to the IP addresses used for Private Google Access and/or VPC Service Controls API access. [More details.](https://cloud.google.com/vpc/docs/configure-private-google-access-hybrid)
* `restricted-googleapis` - Corresponds to the IP addresses used for Private Google Access only for services that support VPC Service Controls API access. [More details.](https://cloud.google.com/vpc/docs/private-access-options#domain-vips)

* `private-googleapis` - Corresponds to the IP addresses used for Private Google Access for services that do not support VPC Service Controls. [More details.](https://cloud.google.com/vpc/docs/private-access-options#domain-vips)

* `dns-forwarders` - Corresponds to the IP addresses used to originate Cloud DNS outbound forwarding. [More details.](https://cloud.google.com/dns/zones/#creating-forwarding-zones)

Expand Down
255 changes: 255 additions & 0 deletions website/docs/r/big_query_dataset.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in
# .github/CONTRIBUTING.md.
#
# ----------------------------------------------------------------------------
layout: "google"
page_title: "Google: google_bigquery_dataset"
sidebar_current: "docs-google-bigquery-dataset"
description: |-
Datasets allow you to organize and control access to your tables.
---

# google\_bigquery\_dataset

Datasets allow you to organize and control access to your tables.



<div class = "oics-button" style="float: right; margin: 0 0 -15px">
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=bigquery_dataset_basic&cloudshell_image=gcr.io%2Fgraphite-cloud-shell-images%2Fterraform%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
</a>
</div>
## Example Usage - Bigquery Dataset Basic


```hcl
resource "google_bigquery_dataset" "dataset" {
dataset_id = "example_dataset"
friendly_name = "test"
description = "This is a test description"
location = "EU"
default_table_expiration_ms = 3600000
labels = {
env = "default"
}
access {
role = "OWNER"
user_by_email = "[email protected]"
}
access {
role = "READER"
domain = "example.com"
}
}
```

## Argument Reference

The following arguments are supported:


* `dataset_id` -
(Required)
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.


- - -


* `access` -
(Optional)
An array of objects that define dataset access for one or more entities. Structure is documented below.

* `default_table_expiration_ms` -
(Optional)
The default lifetime of all tables in the dataset, in milliseconds.
The minimum value is 3600000 milliseconds (one hour).

Once this property is set, all newly-created tables in the dataset
will have an `expirationTime` property set to the creation time plus
the value in this property, and changing the value will only affect
new tables, not existing ones. When the `expirationTime` for a given
table is reached, that table will be deleted automatically.
If a table's `expirationTime` is modified or removed before the
table expires, or if you provide an explicit `expirationTime` when
creating a table, that value takes precedence over the default
expiration time indicated by this property.

* `default_partition_expiration_ms` -
(Optional)
The default partition expiration for all partitioned tables in
the dataset, in milliseconds.

Once this property is set, all newly-created partitioned tables in
the dataset will have an `expirationMs` property in the `timePartitioning`
settings set to this value, and changing the value will only
affect new tables, not existing ones. The storage in a partition will
have an expiration time of its partition time plus this value.
Setting this property overrides the use of `defaultTableExpirationMs`
for partitioned tables: only one of `defaultTableExpirationMs` and
`defaultPartitionExpirationMs` will be used for any new partitioned
table. If you provide an explicit `timePartitioning.expirationMs` when
creating or updating a partitioned table, that value takes precedence
over the default partition expiration time indicated by this property.

* `description` -
(Optional)
A user-friendly description of the dataset

* `friendly_name` -
(Optional)
A descriptive name for the dataset

* `labels` -
(Optional)
The labels associated with this dataset. You can use these to
organize and group your datasets

* `location` -
(Optional)
The geographic location where the dataset should reside.
See [official docs](https://cloud.google.com/bigquery/docs/dataset-locations).

There are two types of locations, regional or multi-regional. A regional
location is a specific geographic place, such as Tokyo, and a multi-regional
location is a large geographic area, such as the United States, that
contains at least two geographic places.

Possible regional values include: `asia-east1`, `asia-northeast1`,
`asia-southeast1`, `australia-southeast1`, `europe-north1`,
`europe-west2` and `us-east4`.

Possible multi-regional values: `EU` and `US`.

The default value is multi-regional location `US`.
Changing this forces a new resource to be created.

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

* `delete_contents_on_destroy` - (Optional) If set to `true`, delete all the tables in the
dataset when destroying the resource; otherwise,
destroying the resource will fail if tables are present.

The `access` block supports:

* `domain` -
(Optional)
A domain to grant access to. Any users signed in with the
domain specified will be granted the specified access

* `group_by_email` -
(Optional)
An email address of a Google Group to grant access to.

* `role` -
(Optional)
Describes the rights granted to the user specified by the other
member of the access object. Primitive, Predefined and custom
roles are supported. Predefined roles that have equivalent
primitive roles are swapped by the API to their Primitive
counterparts, and will show a diff post-create. See
[official docs](https://cloud.google.com/bigquery/docs/access-control).

* `special_group` -
(Optional)
A special group to grant access to.

Possible values include:

* `projectOwners`: Owners of the enclosing project.

* `projectReaders`: Readers of the enclosing project.

* `projectWriters`: Writers of the enclosing project.

* `allAuthenticatedUsers`: All authenticated BigQuery users.

* `user_by_email` -
(Optional)
An email address of a user to grant access to. For example:
[email protected]

* `view` -
(Optional)
A view from a different dataset to grant access to. Queries
executed against that view will have read access to tables in
this dataset. The role field is not required when this field is
set. If that view is updated by any user, access to the view
needs to be granted again via an update operation. Structure is documented below.


The `view` block supports:

* `dataset_id` -
(Required)
The ID of the dataset containing this table.

* `project_id` -
(Required)
The ID of the project containing this table.

* `table_id` -
(Required)
The ID of the table. The ID must contain only letters (a-z,
A-Z), numbers (0-9), or underscores (_). The maximum length
is 1,024 characters.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:


* `creation_time` -
The time when this dataset was created, in milliseconds since the
epoch.

* `etag` -
A hash of the resource.

* `last_modified_time` -
The date when this dataset or any of its tables was last modified, in
milliseconds since the epoch.
* `self_link` - The URI of the created resource.


## Timeouts

This resource provides the following
[Timeouts](/docs/configuration/resources.html#timeouts) configuration options:

- `create` - Default is 4 minutes.
- `update` - Default is 4 minutes.
- `delete` - Default is 4 minutes.

## Import

Dataset can be imported using any of these accepted formats:

```
$ terraform import google_bigquery_dataset.default {{project}}/{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{project}}:{{dataset_id}}
$ terraform import google_bigquery_dataset.default {{dataset_id}}
```

-> If you're importing a resource with beta features, make sure to include `-provider=google-beta`
as an argument so that Terraform uses the correct provider to import your resource.

## User Project Overrides

This resource supports [User Project Overrides](https://www.terraform.io/docs/providers/google/provider_reference.html#user_project_override).
Loading

0 comments on commit 4ce3c46

Please sign in to comment.