'Terraform IAM binding for GCP Cloud Tasks

[Edited]

My concern is related with this open issue

As I know there is no iam binding module in terraform for GCP CloudTasks.

The only solution is using module = terraform-google-modules/gcloud/google, where you can run gcloud commands within terraform.

That means in case that I want to assign viewer role to 3xSAs + 5xUsers + 2xGroups I should have 10 copies of my terraform-google-modules/gcloud/google module.

Similar with running 10 times bellow command:

gcloud tasks queues add-iam-policy-binding GCP_CLOUD_TASK_ID --member=serviceAccount:SERVICE_ACCOUNT --role=roles/cloudtasks.viewer

Suppose I have additional roles: cloudtasks.viewer, cloudtasks.enqueuer, cloudtasks.taskRunner etc., in result I get a lot of gcloud module copies in my .tf definition file.

Is there a workaround using tf loops, conditionals to simply de tf file definitions with gcloud module? Couldn't find any examples and can't figure it out by myself.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source