Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add event_filters to event triggers in cloudfunctions2 resource (#6…
Browse files Browse the repository at this point in the history
…278)

* Add `eventFilters` in cloudfunctions2 API definition

* Remove trailing whitespace

* Start adding cloudfunctions2 eventarc acceptance test that uses GCS

* Add missing IAM bindings to prevent API errors during `FullGcsExample` acceptance test

* Make `eventTrigger.pubsubTopic` default from the API to handle topics made by Eventarc

* Update field description for `attribute` - info to learn more about possible values

* Remove unneeded attribute from `google_storage_bucket_object`

* Add API service enabling to new project in test, fix provider used to make project

* Fix inbuilt function call in acceptance test

* Add explicit dependencies to try make API calls happen after the API is turned on

* Remove generated acceptance test and add handwritten test with 2 stages

* Remove `depends_on` attributes from example config

* Fix bug in test's TF config, make project ID and name the same

* Replace use of `for_each` in acceptance test

There is an open issue about how for_each loops don't work : hashicorp/terraform-plugin-sdk#536

* Add `run.googleapis.com` to project

* Change `disable_dependent_services` to `false` for eventarc API in acceptance tests

Change example config to match, too

* Enable `artifactregistry.googleapis.com` in acceptance test & example

* Add missing IAM binding to cloud function service account - `roles/artifactregistry.reader`

Odd that this is needed, as it wasn't required when I created a similar cloud function in an existing GCP project (where APIs were already activated etc)

* Add explicit dependency between cloud function resource and IAM bindings for its service account

Address "Unable to retrieve the repository metadata" error that suggests service account doesn't have permissions in place

* Enable `cloudbuild.googleapis.com` API in acceptance test and example

* Enable `pubsub.googleapis.com` API in acceptance test and example

* Fix test so step 1 of test enables all the APIs

* Replace zipped cloud function code with zip made by `archive_file` Terraform resource

* Add repo-level IAM binding (in addition to project level) using inferred repo ID

* Fix missing quotation mark in test

:(

* Split project into 3 stages and remove repo-specific IAM binding

This is after running the test locally and it succeeding in 3 steps but not in 2 steps

* Fix problem where TF couldn't delete resources at end of test

Couldn't delete the cloud function because the API had been disabled

* Update test to get project ID from ENV instead of project created by the test

Update test and example block with needed variables

Remove handwritten test

* Fix API spec to make required fields required

* Update event_filter fields' descriptions for clarity

* Change GCS event_filter test to basic as it can't use all fields

* Add example test that shows the operator field in use

* Fix whitespace

* Add test for updating `event_filters` blocks

* Reuse generated cloudfunction2 test functions in handwritten test

Make code homogenous between the two tests to faciliatate this

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Aug 2, 2022
1 parent 91be234 commit 9547877
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/terraform-json v0.14.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220801151312-377d68839293
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220802150259-f258378c3824
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ github.com/hashicorp/terraform-plugin-log v0.4.1 h1:xpbmVhvuU3mgHzLetOmx9pkOL2rm
github.com/hashicorp/terraform-plugin-log v0.4.1/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 h1:/cdI5di5XA+N80gXzXF4YcHq36DprBskubk6Z8i26ZQ=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0/go.mod h1:L3SHkD/Q8zPVgXviQmpVwy9nKwpXXZscVIpVEnQ/T50=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220801151312-377d68839293 h1:KkuOvtWYT05+T/iZmCeKGjD/xk4zRqnhIV4a0yzV1Aw=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220801151312-377d68839293/go.mod h1:T6wRtXtyoiwtEgc5kB4n9mTAQPyy8qOc13162y6Ifyc=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220802150259-f258378c3824 h1:7HNPUS/PkQ2AS/dqNhnNrg3ysidFO2hw3fjoRK8cGc4=
github.com/hashicorp/terraform-provider-google v1.20.1-0.20220802150259-f258378c3824/go.mod h1:T6wRtXtyoiwtEgc5kB4n9mTAQPyy8qOc13162y6Ifyc=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
Expand Down

0 comments on commit 9547877

Please sign in to comment.