הפעלת אישור גישה באמצעות Terraform
Terraform הוא כלי תוכנה בקוד פתוח מסוג תשתית כקוד (IaC), שמאפשר לכם לנהל את בקשות אישור הגישה. באמצעות Terraform אפשר לבצע את כל הפעולות שאפשר לבצע באמצעות ממשקי ה-API של אישור הגישה.
בדף הזה מוסבר איך להפעיל את אישור הגישה באמצעות Terraform. במדריך הזה נעשה שימוש ב-Google Cloud Terraform Provider.
מטרה
במדריך הזה מוסבר איך ליצור קובץ תצורה של Terraform ש:
- הגדרת כתובות אימייל לקבלת התראות על בקשות לאישורי גישה.
- הפעלת אישור גישה לכל המוצרים הנתמכים. Google Cloud כאן אפשר לעיין ברשימה המלאה של מוצרים שנתמכים על ידי אישור גישה. Google Cloud
לפני שמתחילים
- כדי להשתמש ב-Access Approval וב-Access Transparency, הארגון שלכם צריך לעמוד בדרישות תמיכה ספציפיות. מידע נוסף זמין במאמר בנושא הדרישות לשימוש באישור גישה.
- מפעילים את Access Transparency בארגון. מידע נוסף זמין במאמר בנושא הפעלת Access Transparency.
- מוודאים שיש לכם את התפקיד עורך הגדרות של אישור גישה (
roles/accessapproval.configEditor) בניהול הזהויות והרשאות הגישה (IAM). מידע נוסף על תפקידי IAM לאישור גישה זמין במאמר תפקידים לאישור גישה.
יצירת Google Cloud פרויקט
- נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Access Approval API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Access Approval API.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.
התקנת Google Cloud CLI
התקינו את ה-CLI של Google Cloud. אחר כך, אתחלו את ה-CLI של Google Cloud באמצעות הפקודה הבאה:
gcloud initאם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.
כשמתבקשים, בוחרים את הפרויקט שבחרתם או שיצרתם קודם.
אם כבר התקנתם את Google Cloud CLI, אתם יכולים לעדכן אותו באמצעות הפקודה הבאה:
gcloud components update
יצירת קובץ תצורה של Terraform
- פותחים את Cloud Shell כדי להפעיל סשן עצמאי של Cloud Shell.
- פותחים סביבת עבודה.
- יוצרים תיקייה חדשה.
- מוסיפים לתיקייה הזו קובץ תצורה של Terraform בשם
main.tf. מעתיקים את המשאב הבא ומדביקים אותו בקובץ
main.tf.main.tf
variable "parent_value" { type = string } variable "email_1" { type = string } variable "email_2" { type = string } resource "google_folder" "my_folder" { display_name = "my-folder" parent = var.parent_value # parent = "organizations/123456789" } resource "google_folder_access_approval_settings" "folder_access_approval" { folder_id = google_folder.my_folder.folder_id notification_emails = [var.email_1, var.email_2] enrolled_services { cloud_product = "all" } }מזינים ערכים למשתנים הבאים:
-
email_1ו-email_2: מזינים את כתובות האימייל של המשתמשים שרוצים להגדיר כבודקים של בקשות הגישה לפרויקט הזה.
-
parent_value: השם של התיקייה שבה רוצים ליצור את התיקייהmy_folder. מידע נוסף על תיקיות זמין במאמר יצירה וניהול של תיקיות.
-
הרצת קובץ התצורה של Terraform
מריצים את הפקודות הבאות ב-Cloud Shell.
מפעילים את Terraform בספרייה.
terraform initמריצים את קובץ התצורה של Terraform שנוצר.
terraform applyכשמופיעה בקשה לאישור שרוצים להפעיל את קובץ ההגדרות, מזינים yes.
מידע נוסף על הפעלת אישור גישה באמצעות Terraform זמין במסמך Terraform הבא: google_folder_access_approval_settings.
המאמרים הבאים
- שימוש ב-Terraform עם Google Cloud
- שימוש ב-Terraform עם Access Approval
- תחילת העבודה עם Terraform ב- Google Cloud
- תחילת העבודה עם Terraform ב- Google Cloud באמצעות Cloud Shell