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

cloud-functions v2 - fix reference to bucket_name #951

Merged
merged 2 commits into from
Nov 6, 2022

Conversation

wiktorn
Copy link
Collaborator

@wiktorn wiktorn commented Nov 5, 2022

Use local variable for storage source as it is done for v1 functions.

When bucket_name is provided on input of the module then creation of v2 function fails with an error:

╷
│ Error: Invalid index
│ 
│   on .terraform/modules/[...]/modules/cloud-function/main.tf line 144, in resource "google_cloudfunctions2_function" "function":
│  144:         bucket = google_storage_bucket.bucket[0].name
│     ├────────────────
│     │ google_storage_bucket.bucket is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

These changes fixes this error.

Copied tests from v1 functions to ensure that v2 function is working properly.

@wiktorn
Copy link
Collaborator Author

wiktorn commented Nov 6, 2022

One more thing I noticed with Cloud Functions v2 is that they do not support eventarc triggers.

Because of the difference in structure I think that the best approach is to create separate variable that contains necessary variables. If you are OK with this approach, I can work on that in separate PR.

@ludoo
Copy link
Collaborator

ludoo commented Nov 6, 2022

One more thing I noticed with Cloud Functions v2 is that they do not support eventarc triggers.

Because of the difference in structure I think that the best approach is to create separate variable that contains necessary variables. If you are OK with this approach, I can work on that in separate PR.

Sure. It would be great to also refactor the cloud function module to leverage Terraform 1.3 optional, like we've been doing for several other modules. Would you be up for it?

@ludoo ludoo merged commit 0d80ad3 into GoogleCloudPlatform:master Nov 6, 2022
@wiktorn
Copy link
Collaborator Author

wiktorn commented Nov 7, 2022

@ludoo sure, I'll come back with another PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants