I have a cloud composer environment:
resource "google_composer_environment" "default" {
name = "default"
region = "us-central1"
config {
node_count = 5
node_config {
zone = "us-central1-a"
machine_type = "n1-standard-2"
}
}
}
and a cloud function that I use to trigger that environment
resource "google_cloudfunctions_function" "trigger_dag" {
name = "trigger_dag"
runtime = "python37"
labels = {
"deployment-tool" = "terraform"
}
event_trigger {
event_type = "google.pubsub.topic.publish"
resource = "projects/${var.project_id}/topics/trigger_dag"
}
entry_point = "trigger_dag"
environment_variables = {
"AIRFLOW_URI" = google_composer_environment.default.config.0.airflow_uri
}
source_repository {
url = local.repo_url
}
timeouts {}
depends_on = [google_composer_environment.default]
}
However, I also need to give the cloud function an IAP client id to use when calling the DAG: https://cloud.google.com/composer/docs/how-to/using/triggering-with-gcf#getting_the_client_id
Is there a way, in Terraform, to run the python script to generate the client id whenever the DAG is recreated (so the webserver changes and the old id is not valid), and set that id as an environment variable on the cloud function?