in terraform-modules/cloud-functions/src/provide-deploy-permissions/main.py [0:0]
def set_policy(project_id,policy):
"""Function to fetch the policy of the project.
Args:
project_id(string)
policy (dict); generated IAM policy of the project that needs to be set.
Returns:
new IAM policy.
"""
import os
from google.oauth2 import service_account
import googleapiclient.discovery
service = googleapiclient.discovery.build(
"cloudresourcemanager", "v1"
)
policy = (
service.projects()
.setIamPolicy(resource=project_id, body={"policy": policy})
.execute()
)
return policy