Add basic 1st gen functions support#10119
Add basic 1st gen functions support#10119inlined wants to merge 4 commits intoinlined.iac.2-terraform-utilsfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the initial support for exporting Firebase Functions as Terraform configurations. It enables the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for exporting 1st generation Cloud Functions to Terraform. The changes include adding a new 'terraform' exporter, implementing the logic to convert function endpoints into Terraform resource blocks, and adding corresponding unit tests.
My review focuses on improving code quality, documentation, and ensuring correctness of the generated Terraform configuration. I've identified a few areas for improvement:
- A missing feature in Terraform generation for event-triggered function retries.
- Violations of the repository's style guide regarding the use of
anyand missing documentation. - A minor typo in a variable description.
Overall, this is a solid addition. The author has clearly marked areas with hacks that will be addressed later, which is helpful context.
2ee2e3e to
fe941ed
Compare
a1f5549 to
70a2bfb
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces Terraform export support for 1st generation Cloud Functions. The changes include adding a new 'terraform' exporter, implementing the logic to generate main.tf and variables.tf from function definitions, and adding corresponding unit tests. The implementation cleverly uses Terraform interpolated values to work with the existing functions discovery mechanism.
My review focuses on improving type safety, documentation, and code maintainability. I've pointed out a violation of the style guide regarding the use of any, suggested adding documentation to a new public function, and proposed a refactoring to reduce code duplication. I also noted the hardcoded 'latest' version for secrets, which might be a point for future improvement.
| // TODO: Where does this get resolved normally? | ||
| version: "latest", |
There was a problem hiding this comment.
The secret version is hardcoded to "latest". While the TODO comment acknowledges this, hardcoding to latest can lead to unexpected behavior in production if the secret is updated, as it's not a stable reference. It's generally safer to use specific secret versions. If this is a temporary measure for this PR, it would be good to create a follow-up issue to track making this configurable.
There was a problem hiding this comment.
Intentional. Leaving open for now until I look up how to solve it and what those ramifications are (e.g. making more things async)
|
|
||
| const mainTf = result["main.tf"]; | ||
| expect(mainTf).to.include('resource "google_cloudfunctions_function" "my_func"'); | ||
| expect(mainTf).to.include('resource "google_cloudfunctions_function_iam_binding" "my_func"'); |
There was a problem hiding this comment.
Could you assert on the entire string, instead of includes, kind of like minion? This will also allow me to see a full example in case there are any missed edges.
Adds the Terraform exporter and implements 1st gen functions (not including "advanced" trigger types).
This is a checkpoint to get feedback and more invasive testing will be done in the future. There's some hacks present in the way we run the builder because a separate PR is going to need to update both firebase-functions and firebase-tools to allow injecting TF variables and declaring dependencies on standard variables (so as to not create a variables.tf that asks for more things than are used)
This is not really sufficient yet because I don't have providers declarations. Will come in part 4 where I actually field test this