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