Complete the code to specify the entity that represents a user or service in cloud IAM.
entity = "[1]"
In cloud IAM, a principal is the entity (user, service, or system) that can be granted permissions.
Complete the code to define a set of permissions assigned to a user in cloud IAM.
role = "[1]"
A role in cloud IAM is a collection of permissions assigned to a user or service.
Fix the error in the statement that grants permissions to a user by filling the blank.
grant_access(principal, [1])The function grant_access requires a role to specify what permissions are granted to the principal.
Fill both blanks to create a policy that assigns a role to a principal.
policy = {
'bindings': [
{
'role': '[1]',
'members': ['[2]']
}
]
}This policy binds the roles/viewer role to the user alice@example.com.
Fill all three blanks to create a dictionary comprehension that maps users to their assigned roles if the role includes 'admin'.
admin_users = { [1]: [2] for [3], [2] in user_roles.items() if 'admin' in [2] }This comprehension creates a dictionary of users and their roles where the role contains 'admin'. The keys are users, and the values are roles.