Open gsouf opened 6 days ago
Hi @gsouf!
I have noticed that the code you share lacks several elements and has some errors. I'm sharing with you a correct configuration that works without errors. Please try it and if you still continue with issues share with us your full code as the last example to see what is happening.
resource "google_storage_bucket" "bucket_19681" {
name = "bucket-19681"
location = "US"
}
resource "google_storage_bucket_object" "bucket_object_19681" {
name = "index19681.zip"
bucket = google_storage_bucket.bucket_19681.name
source = "./utils/google_cloud_repository/index.zip"
}
resource "google_cloudfunctions_function" "function_19681" {
name = "function-19681"
description = "something"
runtime = "nodejs16"
available_memory_mb = 128
source_archive_bucket = google_storage_bucket.bucket_19681.name
source_archive_object = google_storage_bucket_object.bucket_object_19681.name
trigger_http = true
entry_point = "helloGET"
}
data "google_compute_default_service_account" "default_sa_19681" {}
resource "google_cloudfunctions_function_iam_member" "cf_function_iam_member_19681" {
project = "my-project"
region = "us-central1"
cloud_function = google_cloudfunctions_function.function_19681.name
role = "roles/viewer"
member = "user:my-example-user@my-example-domain.com"
}
resource "google_cloud_scheduler_job" "c_shceduler_job_19681" {
name = "c-shceduler-job-19681"
description = "something"
region = "us-central1"
schedule = "*/1 * * * *"
time_zone = "UTC"
retry_config {
retry_count = 1
}
http_target {
http_method = "GET"
uri = google_cloudfunctions_function.function_19681.https_trigger_url
oidc_token {
service_account_email = data.google_compute_default_service_account.default_sa_19681.email
}
}
depends_on = [google_cloudfunctions_function_iam_member.cf_function_iam_member_19681]
}
Example function:
exports.helloGET = (req, res) => {
res.status(200).send('Hello world2!');
};
IMPORTANT: We can't check your function code since it goes beyond our scope this is just a simple example to test the last code.
@ggtisc I think my provided example has no error, except that I haven't communicated the other dependent resources to make it more re-readable, I assumed you would understand the origin of the issue by looking at the error message.
Have you tried to modify the cloud function google_cloudfunctions_function" "function_19681
, for example by modifying the zip, and re-run terraform apply
?
This issue occurs only when re-redeploying. Initial deployment works well, when I redeploy, I get the error, but everything is well deployed regardless of that. I think that the value .http_target[0].oidc_token[0].audience
is set automatically somewhere and when we re-deploy it conflicts with what terraform expects. As I have only a vague understanding of how terraform works internally that's just a guess, but it seems like something internal to the google provider and not from the configuration itself.
Community Note
Terraform Version & Provider Version(s)
Terraform v1.9.6 on linux_amd64
Affected Resource(s)
google_cloud_scheduler_job
Terraform Configuration
Debug Output
No response
Expected Behavior
No response
Actual Behavior
Got error "which should be reported in the provider's own issue tracker" after re-applying terraform:
Steps to reproduce
terraform apply
Important Factoids
No response
References
No response