קישור ל-Secure Source Manager

בדף הזה מוסבר איך ליצור חיבורים ל-Secure Source Manager ואיך לקשר למאגרי Secure Source Manager. השילוב הזה מאפשר לכם להשתמש בתכונות של Developer Connect, כמו תצוגות לוח בקרה של מאגרי Secure Source Manager, ולהשתמש בשרת ה-proxy של Developer Connect כדי לבצע פעולות git, כמו פעולות קריאה מאובטחות.

לפני שמתחילים

  1. נכנסים לחשבון Google.

    אם עדיין אין חשבון, יוצרים חשבון חדש.

  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Developer Connect API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Developer Connect API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  8. אופציונלי: יוצרים מפתח הצפנה בניהול הלקוח (CMEK) להצפנת סודות האימות שנוצרים על ידי Developer Connect.
  9. אופציונלי: כדי להשתמש בהוראות של שורת הפקודה במדריך הזה, מבצעים את השלבים הבאים:
    1. מתקינים את Google Cloud CLI. אם כבר התקנתם את ה-CLI של gcloud בעבר, צריך לוודא שפועלת אצלכם הגרסה העדכנית ביותר של gcloud components update.
    2. יוצרים חשבון שירות של Developer Connect על ידי הרצת הפקודה הבאה, כש-PROJECT_ID הוא Google Cloud מזהה הפרויקט:
              gcloud beta services identity create \
                  --service=developerconnect.googleapis.com \
                  --project=PROJECT_ID
              

הדרישות של Secure Source Manager

  • מוודאים שיש לכם מופע פעיל של Secure Source Manager שנפרס ב Google Cloud אזור.
  • החיבור של Developer Connect והמופע של Secure Source Manager חייבים להיות באותו אזור.
  • מקצים לסוכן השירות (P4SA) של Developer Connect את התפקיד roles/securesourcemanager.developerConnectLinker בפרויקט של מופע Secure Source Manager.

התפקידים הנדרשים

כדי לקבל את ההרשאות שדרושות ליצירת חיבורים וקישורים, צריך לבקש מהאדמין להקצות לכם את תפקידי ה-IAM הבאים:

  • כדי ליצור חיבור ולקשר למאגר: Developer Connect Admin (roles/developerconnect.admin) בפרויקט שבו רוצים ליצור משאבים של Developer Connect.
  • כדי להעניק הרשאות לסוכן השירות של Developer Connect: אדמין IAM של פרויקט (roles/resourcemanager.projectIamAdmin) בפרויקט שבו פועל Secure Source Manager.

להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.

יכול להיות שאפשר לקבל את ההרשאות הנדרשות גם באמצעות תפקידים בהתאמה אישית או תפקידים מוגדרים מראש.

יצירת חיבור

בקטע הזה מוסבר איך ליצור חיבור בין Developer Connect לבין Secure Source Manager. אם אתם משתמשים במסוף Google Cloud , תוכלו גם להתחיל להוסיף קישורים למאגרי מידע אחרי שתסיימו להגדיר את החיבור.

כדי ליצור חיבור חדש ל-Secure Source Manager, בוחרים באחת מהאפשרויות הבאות:

המסוף

  1. פותחים את Developer Connect במסוף Google Cloud .

    כניסה אל Developer Connect

  2. לוחצים על יצירת קישור.

  3. בוחרים באפשרות Secure Source Manager (ניהול מאובטח של מקורות) כספק המקור.

  4. בקטע Region, בוחרים אזור לחיבור. האזור הזה צריך להיות זהה לאזור של מופע Secure Source Manager.

  5. בשדה Name, מזינים שם לחיבור.

  6. ברשימה Instance, בוחרים מופע.

  7. לוחצים על הצגת הגדרות נוספות כדי לראות הגדרות אופציונליות.

  8. אופציונלי: כדי להשבית את ה-proxy של Developer Connect, מבטלים את הסימון בתיבה Enable Developer Connect proxy.

  9. לוחצים על Continue.

  10. אפשר לקשר למאגרי מידע עכשיו, או לערוך את החיבור מאוחר יותר. כדי לקשר למאגרי מידע, בוחרים מאגרים מהרשימה.

  11. לוחצים על קישור.

הכלי Developer Connect יוצר את הקישורים למאגר ומציג אותם במסוף Google Cloud .

gcloud

כדי ליצור חיבור Developer Connect באמצעות Google Cloud CLI, מריצים את הפקודה הבאה:

gcloud developer-connect connections create CONNECTION_ID \
  --location=REGION \
  --project=CONNECTION_PROJECT_ID \
  --secure-source-manager-instance-config=projects/INSTANCE_PROJECT_ID/locations/REGION/instances/INSTANCE_ID

כאשר:

  • CONNECTION_ID הוא המזהה של החיבור ל-Developer Connect שרוצים ליצור.
  • REGION הוא האזור של החיבור. האזור הזה צריך להיות זהה לאזור של מופע Secure Source Manager.
  • CONNECTION_PROJECT_ID הוא המזהה של הפרויקט שבו רוצים ליצור את החיבור. Google Cloud
  • INSTANCE_PROJECT_ID הוא מזהה הפרויקט של Google Cloud שבו נמצא המופע של Secure Source Manager.
  • INSTANCE_ID הוא המזהה של מופע Secure Source Manager.

curl

כדי ליצור חיבור Developer Connect עם curl, מבצעים את הקריאה הבאה ל-API:

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://developerconnect.googleapis.com/v1/projects/CONNECTION_PROJECT_ID/locations/REGION/connections?connection_id=CONNECTION_ID \
-X POST -H "Content-Type: application/json" \
-d '{"secure_source_manager_instance_config":{"instance":"projects/INSTANCE_PROJECT_ID/locations/REGION/instances/INSTANCE_ID"}}'

כאשר:

  • CONNECTION_ID הוא המזהה של החיבור ל-Developer Connect שרוצים ליצור.
  • REGION הוא האזור של החיבור. האזור הזה צריך להיות זהה לאזור של מופע Secure Source Manager.
  • CONNECTION_PROJECT_ID הוא מזהה הפרויקט שבו רוצים ליצור את החיבור. Google Cloud
  • INSTANCE_PROJECT_ID הוא מזהה הפרויקט של Google Cloud שבו נמצא המופע של Secure Source Manager.
  • INSTANCE_ID הוא המזהה של מופע Secure Source Manager.

אחרי שיוצרים חיבור ל-Secure Source Manager, אפשר לקשר למאגרי מידע. בשלב מאוחר יותר, תוכלו לחזור על השלבים האלה כדי לקשר מאגרי מידע נוספים לפי הצורך.

כדי ליצור קישורים למאגר בחיבור קיים של Secure Source Manager, בוחרים באחת מהאפשרויות הבאות:

המסוף

  1. פותחים את הדף Repositories במסוף Google Cloud .

    פותחים את הדף Repositories

  2. לוחצים על קישור מאגר.

    נפתח החלונית Link Git repositories (קישור מאגרי Git).

  3. ברשימת החיבורים, בוחרים את החיבור של Secure Source Manager.

  4. לוחצים על Continue.

  5. ברשימת המאגרים, בוחרים את המאגרים שרוצים לקשר.

  6. לוחצים על יצירה.

הכלי Developer Connect יוצר את הקישורים למאגר ומציג אותם במסוף Google Cloud .

gcloud

מידע נוסף על ניהול קישורים למאגרי git באמצעות gcloud זמין במאמר בנושא gcloud developer-connect connections git-repository-links.

שימוש בשרת proxy של Developer Connect ב-Cloud Build

כדי להשתמש ב-Developer Connect proxy ב-Cloud Build:

  1. מקצים לסוכן השירות של Secure Source Manager את התפקיד roles/developerconnect.viewer או כל תפקיד אחר עם ההרשאה developerconnect.gitRepositoryLinks.get בפרויקט Developer Connect.
  2. מקשרים את מאגר Secure Source Manager ל-Developer Connect gitRepositoryLink. הוראות מפורטות זמינות במאמר בנושא קישור למאגר Secure Source Manager.
  3. בקובץ .cloudbuild/trigger.yaml בספריית הבסיס של המאגר, מוסיפים רשומה חדשה שמפנה למשאב gitRepositoryLink.

    לדוגמה:

    triggers:
    - name: test-trigger
      project: my-project
      configFilePath: cloudbuild.yaml
      eventType: push
      serviceAccount: projects/my-project/serviceAccounts/my-sa@my-project.iam.gserviceaccount.com
      devConnectGitRepositoryLink: projects/my-project/locations/us-central1/connections/my-ssm-connection/gitRepositoryLinks/my-repo-link
    

היקף הפעילות והמגבלות

אחרי שמגדירים את החיבור, אפשר לבצע פעולות קריאה מאובטחות של git, כמו clone, במופעים של Secure Source Manager באמצעות ה-URI של ה-proxy של Developer Connect.

ה-proxy של Developer Connect לא תומך בפעולות git push. המערכת מונעת פעולות כתיבה שמשתמשות בזהות של חשבון P4SA של DevConnect.

אפשר לעדכן הגדרות אחרות של החיבור, למשל להפעיל או להשבית את ה-proxy של Developer Connect, אבל אי אפשר להפנות את החיבור הקיים למופע אחר של Secure Source Manager.

המאמרים הבאים