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 ability to call Cloud Functions and receive results #6209

Open
dinvlad opened this issue Apr 25, 2020 · 2 comments
Open

Add ability to call Cloud Functions and receive results #6209

dinvlad opened this issue Apr 25, 2020 · 2 comments

Comments

@dinvlad
Copy link

dinvlad commented Apr 25, 2020

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 the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Cloud Functions API exposes projects.locations.functions.call method to synchronously invoke a function for testing purposes [1].

Having an ability to do that from inside a Terraform template would significantly raise extensibility of the provider, including an ability to:

  • deploy some resources before they're supported by the provider
  • configure some resources in a security context, where temporary credentials are created/stored in Secret Manager, and we'd like to avoid their storage in Terraform state

This would also mirror similar functionality in other providers and systems, e.g. aws_lambda_invocation or AWS::CloudFormation::CustomResource.

New or Affected Resource(s)

  • google_cloudfunctions_function_call

Potential Terraform Configuration

data "google_cloudfunctions_function_call" "call" {
  project        = google_cloudfunctions_function.function.project
  region         = google_cloudfunctions_function.function.region
  cloud_function = google_cloudfunctions_function.function.name

  data = jsonencode({ hello = "world" })
}

locals {
  cloud_function_output = data.google_cloudfunctions_function_call.call.result
}

References

@ghost ghost added the enhancement label Apr 25, 2020
@danawillow danawillow added this to the Backlog milestone Apr 27, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Jul 1, 2022
Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Jul 1, 2022
Signed-off-by: Modular Magician <[email protected]>
@fishpen0
Copy link

fishpen0 commented Dec 1, 2022

See: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_invocation for the AWS equivalent.

This is often used for fetching data or resources terraform cannot natively support:

data "aws_lambda_invocation" "data_terraform_cant_get" {
  function_name = "myfunction"
}

output "mydata" {
  value = data.aws_lambda_invocation.data_terraform_cant_get.result
}

resource "other_resource" "other" {
  resource_argument = data.aws_lambda_invocation.data_terraform_cant_get.result
}

@SarahFrench
Copy link
Member

Note from triage: Moving out of backlog due to prior art in the AWS provider, but the documentation for this new data source should warn that the Cloud Function shouldn't have side effects. This data source heavily depends on what the CF does.

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

5 participants