I am new to terraform I want to create a Google Cloud Function using Terraform but want to pull the source code from Github.
I managed to do this zipping up the function and copying it into Cloud Storage using Terraform, but I do not like this workflow as I have to run a script to kick things off. I rather just do a PR on Github and see the new code in GCP.
I already setup Google Cloud Source Repositories to source from my Github.
The Terraform doc to use the "source_repository" argument is not clear to me. What I would like to do is just grab the source from HEAD on the master branch.
I just would like to know how to specify the “source_repository” argument in this case.
My cloud source repository URL is https://source.cloud.google.com/projectName/github_offiecDomain_gitRepoName
My cloud function terraform script looks like
resource "google_cloudfunctions_function" "js_function" {
source_repository {
url = "https://source.cloud.google.com/projectName/github_offiecDomain_gitRepoName"
}
}
When I terraform apply
it returns an error
google_cloudfunctions_function.js_function: Creating...
Error: googleapi: Error 400: The request has errors, badRequest
on main.tf line 89, in resource "google_cloudfunctions_function" "js_function":
89: resource "google_cloudfunctions_function" "js_function" {
EDIT Upon moving my log level to trace
Here is what I have
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: ff
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: {
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "error": {
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "code": 400,
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "message": "The request has errors",
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "errors": [
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: {
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "message": "The request has errors",
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "domain": "global",
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "reason": "badRequest"
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: }
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: ],
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: "status": "INVALID_ARGUMENT"
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: }
2020-08-05T11:07:30.722+0500 [DEBUG] plugin.terraform-provider-google_v3.17.0_x5: }
I suppose that my URL argument is not valid. Any leads how can I write my URL?