Skip to content

Commit

Permalink
Add Dataplex Asset resource (GoogleCloudPlatform#6310)
Browse files Browse the repository at this point in the history
* Initial commit, verify asset.yaml

* Use an existing public bucket

* Add Dataplex Asset into provider.go

* Use a sample bucket instead of a hardcoded one

* Fix asset YAML to have asset field

* Fix asset YAML to have bucket field

* Try again with a hardcoded bucket

* minor syntax fix

* Using handwritten tests since GCS buckets are not in DCL

* Fix bucket name reference in Dataplex Asset

* Ignore updates to bucket after creation

* Change dataplex terraform resource name to primary for the tests

* Add override for resource_spec.name. This is an immutable field and is normalized by the API.

* upgrade dcl to 1.16

* Update test to use dataplexZone instead of zone

* Add back comment accidentally removed in merge
  • Loading branch information
saurabh-net authored and hao-nan-li committed Aug 31, 2022
1 parent bdfd47f commit 13bd241
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/go.mod.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve

require (
cloud.google.com/go/bigtable v1.13.0
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
4 changes: 4 additions & 0 deletions mmv1/third_party/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1520,3 +1520,7 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1 h1:ex
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1 h1:ex2UFZoVSbfsHK0zDsilMpXXs1vBDwi2wk1Fxd5N3D0=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.2 h1:FWEE9Fk1bC4oE4O1jvI7gskksmpUh/vpX9J+GPP/WhA=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.2/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0 h1:+zbrl0sUHK+oav4Nhru21AjJLPwnmQCL01oZYzYiPac=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
2 changes: 1 addition & 1 deletion tpgtools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
bitbucket.org/creachadair/stringset v0.0.9
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/hcl v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions tpgtools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1 h1:ex2UFZoVSbfsHK0zDsilMpXXs1vBDwi2wk1Fxd5N3D0=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.15.1/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0 h1:+zbrl0sUHK+oav4Nhru21AjJLPwnmQCL01oZYzYiPac=
github.com/GoogleCloudPlatform/declarative-resource-client-library v1.16.0/go.mod h1:i6Pmzp7aolLmJY86RaJ9wjqm/HFleMeN7Vl5uIWLwE8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
Empty file.
Empty file.
60 changes: 60 additions & 0 deletions tpgtools/overrides/dataplex/samples/asset/basic_asset.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
resource "google_storage_bucket" "basic_bucket" {
name = "dataplex-bucket-%{random_suffix}"
location = "{{region}}"
uniform_bucket_level_access = true
lifecycle {
ignore_changes = [
labels
]
}

project = "{{project}}"
}

resource "google_dataplex_lake" "basic_lake" {
name = "{{lake}}"
location = "{{region}}"
project = "{{project}}"
}


resource "google_dataplex_zone" "basic_zone" {
name = "{{zone}}"
location = "{{region}}"
lake = google_dataplex_lake.basic_lake.name
type = "RAW"

discovery_spec {
enabled = false
}


resource_spec {
location_type = "SINGLE_REGION"
}

project = "{{project}}"
}


resource "google_dataplex_asset" "primary" {
name = "{{asset}}"
location = "{{region}}"

lake = google_dataplex_lake.basic_lake.name
dataplex_zone = google_dataplex_zone.basic_zone.name

discovery_spec {
enabled = false
}

resource_spec {
name = "projects/{{project}}/buckets/dataplex-bucket-%{random_suffix}"
type = "STORAGE_BUCKET"
}

project = "{{project}}"
depends_on = [
google_storage_bucket.basic_bucket
]
}
16 changes: 16 additions & 0 deletions tpgtools/overrides/dataplex/samples/asset/basic_asset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# optional test level config -- needed for updates basic.tf.tmpl def
updates:
- resource: ./basic_asset.tf.tmpl
variables:
- name: lake
type: resource_name
- name: zone
type: resource_name
- name: asset
type: resource_name
- name: bucket
type: resource_name
- name: project
type: project
- name: region
type: region
2 changes: 2 additions & 0 deletions tpgtools/overrides/dataplex/samples/asset/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore_read:
- "resource_spec.0.name"

0 comments on commit 13bd241

Please sign in to comment.