Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acceptance Testing Framework for_each Resource Support (unexpected index type (string)) #536

Open
bflad opened this issue Aug 14, 2020 · 2 comments
Labels
bug Something isn't working subsystem/tests Issues and feature requests related to the testing framework.

Comments

@bflad
Copy link
Contributor

bflad commented Aug 14, 2020

SDK version

v2.0.1

Use-cases

For parity with real world Terraform configurations, we would like to utilize resource for_each support in acceptance testing configurations for the Terraform AWS Provider, to automatically validate documented configuration practices.

Essentially, we would like to enable the commented configuration below, which matches our resource and examples documentation.

https://github.com/terraform-providers/terraform-provider-aws/blob/d104477b8209c4829d1d9601ca3cac7e5cf1cdd5/aws/resource_aws_acm_certificate_validation_test.go#L202-L245

Attempted Solutions

The acceptance testing framework currently throws an error when applying a test configuration with for_each usage:

    TestAccAWSAcmCertificateValidation_basic: testing_new_config.go:52: unexpected index type (string) for "aws_route53_record.test", for_each is not supported
    TestAccAWSAcmCertificateValidation_basic: testing_new.go:57: unexpected index type (string) for "aws_route53_record.test", for_each is not supported
--- FAIL: TestAccAWSAcmCertificateValidation_basic (70.91s)

Since test configuration workarounds are currently applied, any resources changes will require manual re-verification of certain functionality.

Proposal

Support for_each indexed resources in the acceptance test configurations, similar to count resources. In our case, we don't necessarily need all other testing functionality to support for_each indexed resources (e.g. TestCheckFunc), just the successful apply of the configuration would be great for our situation.

References

@bflad bflad added the enhancement New feature or request label Aug 14, 2020
@paddycarver
Copy link
Contributor

I'm not going to lie, I'm not entirely sure why this doesn't work right now. In theory, it should--the test framework shouldn't care about for_each at all, it should never even see it. Terraform should just handle it.

I have a sneaking suspicion there's a deeper problem here or the SDK has trouble handling the output of for_each or something. But we're going to need to do a bit more digging to figure out what's going on here, because you definitely shouldn't be getting apply errors from configs that standalone Terraform can apply; after all, the whole point of the new test driver is that standalone Terraform is applying them.

@paddycarver paddycarver added bug Something isn't working port-to-v1 and removed enhancement New feature or request labels Sep 3, 2020
@paddycarver paddycarver added subsystem/tests Issues and feature requests related to the testing framework. and removed testing labels Dec 17, 2020
@akselleirv
Copy link

Any update on this issue? I would also like to add tests for resources using for_each.

SarahFrench added a commit to hashicorp/magic-modules that referenced this issue Jul 21, 2022
There is an open issue about how for_each loops don't work : hashicorp/terraform-plugin-sdk#536
SarahFrench added a commit to GoogleCloudPlatform/magic-modules that referenced this issue Aug 2, 2022
)

* 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
modular-magician added a commit to modular-magician/terraform-docs-samples that referenced this issue Aug 2, 2022
…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]>
modular-magician added a commit to terraform-google-modules/terraform-docs-samples that referenced this issue Aug 2, 2022
…278) (#114)

* 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]>
modular-magician added a commit to modular-magician/terraform-provider-google-beta that referenced this issue Aug 2, 2022
…shicorp#6278)

* 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]>
modular-magician added a commit to hashicorp/terraform-provider-google-beta that referenced this issue Aug 2, 2022
) (#4547)

* 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]>
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Aug 2, 2022
…shicorp#6278)

* 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]>
modular-magician added a commit to hashicorp/terraform-provider-google that referenced this issue Aug 2, 2022
) (#12222)

* 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]>
modular-magician added a commit to modular-magician/terraform-validator that referenced this issue Aug 2, 2022
…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]>
modular-magician added a commit to GoogleCloudPlatform/terraform-validator that referenced this issue Aug 2, 2022
…278) (#887)

* 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]>
hao-nan-li pushed a commit to hao-nan-li/magic-modules that referenced this issue Sep 6, 2022
…ogleCloudPlatform#6278)

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working subsystem/tests Issues and feature requests related to the testing framework.
Projects
None yet
Development

No branches or pull requests

3 participants