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

Add Support for Cloud SQL Connections to google_cloudfunctions2_function #20735

Open
abdelmoez-guetat opened this issue Dec 18, 2024 · 0 comments

Comments

@abdelmoez-guetat
Copy link

abdelmoez-guetat commented Dec 18, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Description

At present, the google_cloudfunctions2_function resource in Terraform lacks a built-in way to directly configure Cloud SQL connections for Google Cloud Functions. While there is a workaround to add Cloud SQL connections post-deployment using the gcloud run services update command (gcloud run services update SERVICE_NAME --add-cloudsql-instances=INSTANCE_CONNECTION_NAME), it would be more efficient and user-friendly to have native support for this functionality directly within the Terraform configuration.

Proposed Solution: adding a cloud_sql_connections parameter to the google_cloudfunctions2_function resource. This new parameter would allow users to specify an array of Cloud SQL instance connection names, enabling Terraform to automatically configure the connection between the Cloud Function and Cloud SQL during creation.

New or Affected Resource(s)

  • google_cloudfunctions2_function

Potential Terraform Configuration

resource "google_cloudfunctions2_function" "example" {
  name     = "my-cloud-function"
  location = "us-central1"

  build_config {
    runtime     = "python310"
    entry_point = "main"
    source {
      storage_source {
        bucket = "your-source-bucket"
        object = "source-code.zip"
      }
    }
  }

  service_config {
    environment_variables = {
      DB_USER     = "your-username"
      DB_PASSWORD = "your-password"
      DB_NAME     = "your-database-name"
      DB_HOST     = "/cloudsql/project:region:instance-id"
    }

    vpc_connector = "vpc-connector-project-reference"

    cloud_sql_connections = ["project:region:instance-id"]
  }
}

References

No response

b/386824486

@github-actions github-actions bot added forward/review In review; remove label to forward service/cloudfunctions labels Dec 18, 2024
@zli82016 zli82016 removed the forward/review In review; remove label to forward label Dec 30, 2024
@rileykarson rileykarson added this to the Goals milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants