-
Notifications
You must be signed in to change notification settings - Fork 0
/
IAM_Roles
39 lines (29 loc) · 1.54 KB
/
IAM_Roles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Set the project ID
PROJECT_ID=<your-project-id>
# Set the expiry date for the roles (e.g. 7 days from now)
EXPIRY_DATE=$(date -d "+7 days" +%Y-%m-%dT%H:%M:%SZ)
# Add the first user with Compute Engine admin role and expiry date
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member='user:<first-user-email>' \
--role='roles/compute.admin' \
--condition='expression=request.time < timestamp("'"$EXPIRY_DATE"'")'
# Add the second user with Compute Engine instance admin role and expiry date
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member='user:<second-user-email>' \
--role='roles/compute.instanceAdmin' \
--condition='expression=request.time < timestamp("'"$EXPIRY_DATE"'")'
# Add the third user with Compute Engine network admin role and expiry date
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member='user:<third-user-email>' \
--role='roles/compute.networkAdmin' \
--condition='expression=request.time < timestamp("'"$EXPIRY_DATE"'")'
# Add the fourth user with Compute Engine security admin role and expiry date
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member='user:<fourth-user-email>' \
--role='roles/compute.securityAdmin' \
--condition='expression=request.time < timestamp("'"$EXPIRY_DATE"'")'
# Add the fifth user with Compute Engine storage admin role and expiry date
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member='user:<fifth-user-email>' \
--role='roles/compute.storageAdmin' \
--condition='expression=request.time < timestamp("'"$EXPIRY_DATE"'")'