יצירת מופע של Secure Source Manager

‫Secure Source Manager הוא שירות לדייר יחיד. מופע אחד של Secure Source Manager צריך לכלול רק משתמשים מלקוחGoogle Cloud אחד, אלא אם כמה חברות שיש ביניהן קשר חוזי צריכות להשתמש במופע אחד לצורך שיתוף פעולה.

אם אתם עובדים עם כמה חברות ורוצים לשתף איתן פעולה בקוד המקור, מומלץ ליצור מכונה נפרדת לכל חברה.

כדי ליצור מכונה שמופעל בה VPC Service Controls, קראו את המאמר הגדרת Secure Source Manager בהיקף של VPC Service Controls.

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

  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. Enable the Secure Source Manager API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  4. Install the Google Cloud CLI.

  5. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. 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

  8. Enable the Secure Source Manager API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. 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.

    Enable the API

  9. Install the Google Cloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init

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

כדי לקבל את ההרשאות שנדרשות ליצירת מכונה של Secure Source Manager, צריך לבקש מהאדמין להקצות לכם את התפקיד בעלים של מכונה ב-Secure Source Manager (roles/securesourcemanager.instanceOwner) ב-IAM בפרויקט Google Cloud .

התפקידים של Secure Source Manager לא מופיעים במסוף Google Cloud עד שהם מוקצים לחשבון משתמש. כדי להקצות תפקיד ב-Secure Source Manager בפעם הראשונה, קראו את המאמר הקצאה וביטול של תפקידי IAM.

הצפנת הנתונים

כברירת מחדל, Google Cloud מצפין באופן אוטומטי נתונים במנוחה באמצעות מפתחות הצפנה שמנוהלים על ידי Google. אם יש לכם דרישות תאימות או דרישות רגולטוריות ספציפיות שקשורות למפתחות שמגנים על הנתונים שלכם, אתם יכולים ליצור מכונות של Secure Source Manager שמוצפנות באמצעות מפתחות הצפנה בניהול הלקוח (CMEK).

אל תאחסנו מידע רגיש במזהי מכונות או בזוגות של מפתח/ערך בתוויות, כי הם לא מוצפנים באמצעות CMEK.

אם אתם יוצרים את המכונה הראשונה של Secure Source Manager בפרויקט, אתם צריכים ליצור באופן ידני את סוכן השירות של Secure Source Manager באמצעות הפקודה הבאה:

gcloud beta services identity create \
    --service=securesourcemanager.googleapis.com \
    --project=PROJECT_ID

‫PROJECT_ID הוא מזהה הפרויקט שבו יוצרים את המכונה של Secure Source Manager.

אחרי שיוצרים את סוכן השירות של Secure Source Manager, צריך להקצות את התפקיד "סוכן השירות של Secure Source Manager" (roles/securesourcemanager.serviceAgent) לחשבון הראשי service-PROJECT-NUMBER@gcp-sa-sourcemanager.iam.gserviceaccount.com, אחרת יצירת המכונה תיכשל.

יצירת מכונה

כדי ליצור מכונה:

‫CLI של gcloud

  1. מריצים את הפקודה הבאה כדי ליצור מכונה. יכול להיות שתתבקשו לאמת את ה-CLI של gcloud.

    gcloud source-manager instances create INSTANCE_ID \
        --region=LOCATION \
        --project=PROJECT_ID \
        --kms-key=projects/KEY_PROJECT/locations/KEY_LOCATION/keyRings/KEYRING_NAME/cryptoKeys/KEY
    

    כאשר:

    • ‫INSTANCE_ID הוא המזהה הקבוע של המכונה. המזהה צריך לכלול רק אותיות קטנות, מספרים ומקפים, להתחיל באות, ואי אפשר לשנות אותו אחרי שיוצרים אותו.

    • ‫LOCATION הוא האזור שבו רוצים ליצור את המכונה. למידע על מיקומים נתמכים, ראו מיקומים.

    • ‫PROJECT_ID הוא מזהה הפרויקט שבו רוצים ליצור מכונה.

    • ‫-kms-key הוא דגל אופציונלי. צריך לכלול את הפרמטר הזה אם רוצים להשתמש במפתח הצפנה בניהול הלקוח (CMEK) כדי ליצור את המכונה. מפתחות CMEK צריכים להיות באותו מיקום שבו אתם יוצרים את המכונה, אבל הם יכולים להיות בפרויקט אחר. אם אתם רוצים להשתמש בהצפנה שמוגדרת כברירת מחדל ב-Google, אל תשתמשו בדגל הזה. אם רוצים להצפין את הנתונים באמצעות CMEK, מחליפים את הערכים הבאים:

      • ‫KEY_PROJECT בפרויקט שבו יצרתם את המפתח.
      • ‫KEY_LOCATION במיקום של המפתח.
      • ‫KEYRING_NAME בשם של אוסף המפתחות.
      • ‫KEY בשם של המפתח.

    מתחילה פעולה ממושכת של יצירת מכונה. הפלט אמור להיראות כך:

    Create request issued for [my-instance].
    done: false
    metadata:
      '@type': type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata
      apiVersion: v1
      createTime: '2023-02-27T20:57:52.315609549Z'
      requestedCancellation: false
      target: projects/my-project/locations/us-central1/instances/my-instance
      verb: create
    name: projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e
    

    כאשר projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e הוא OPERATION_NAME.

    יצירת המכונה נמשכת עד 60 דקות.

  2. שימו לב לערך של OPERATION_NAME, כי תצטרכו להשתמש בו כדי לבדוק את סטטוס הפעולה.

  3. כדי לבדוק את הסטטוס של הפעולה create, מריצים את הפקודה הבאה:

    gcloud source-manager operations describe OPERATION_NAME \
        --region=LOCATION
    

    מחליפים את מה שכתוב בשדות הבאים:

    • OPERATION_NAME בשם הפעולה מהתגובה לפקודת היצירה.
    • ‫LOCATION באזור שבו רוצים ליצור את המכונה. למידע על מיקומים נתמכים, ראו מיקומים.

    כשהמכונה תהיה מוכנה, התגובה תיראה בערך כך:

    {
    "name": "projects/my-project/locations/us-central1/operations/operation-123456789012-5ec69948c0f2b-60dd727f-a9b97a2e",
    "metadata": {
      "@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
      "createTime": "2022-11-01T14:31:32.420469714Z",
      "endTime": "2022-11-01T14:48:34.140378114Z",
      "target": "projects/my-project/locations/us-central1/instances/test",
      "verb": "create",
      "requestedCancellation": false,
      "apiVersion": "v1"
    },
    "done": true,
    "response": {
      "@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.Instance",
      "name": "projects/my-project/locations/us-central1/instances/test",
      "createTime": "2022-11-01T14:31:32.416413630Z",
      "updateTime": "2022-11-01T14:31:32.416413630Z",
      "labels": {
        "ldap": "user",
        "source": "manual"
      },
      "state": "ACTIVE",
      "hostConfig": {
        "html": "test-098765432109.us-central1.sourcemanager.dev",
        "api": "test-098765432109-api.us-central1.sourcemanager.dev",
        "gitHttp": "test-098765432109-git.us-central1.sourcemanager.dev"
      }
    }
    }
    

    כאשר test-098765432109.us-central1.sourcemanager.dev הוא כתובת ה-URL של המכונה ב-HTML.

  4. מעתיקים את כתובת ה-URL ב-HTML מהפקודה לבדיקת הסטטוס שנוצרה בהצלחה. תצטרכו את כתובת ה-URL הזו כדי לגשת למכונה דרך ממשק האינטרנט שלה.

API

  1. מריצים את הפקודה הבאה כדי ליצור מכונה. יכול להיות שתתבקשו לאמת את ה-CLI של gcloud.

    curl \
        -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        https://securesourcemanager.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/instances?instance_id=INSTANCE_ID \
        -H "Content-Type: application/json" \
        -d '{ "kms_key":"projects/KEY_PROJECT/locations/KEY_LOCATION/keyRings/KEYRING_NAME/cryptoKeys/KEY"}'
    
    

    כאשר:

    • ‫INSTANCE_ID הוא המזהה הקבוע של המכונה. המזהה יכול לכלול רק אותיות קטנות, מספרים ומקפים, והוא חייב להתחיל באות.

    • ‫LOCATION הוא האזור שבו רוצים ליצור את המכונה. למידע על מיקומים נתמכים, ראו מיקומים.

    • ‫PROJECT_ID הוא מזהה הפרויקט שבו רוצים ליצור מכונה.

    • ‫-d הוא דגל אופציונלי של נתוני HTTP POST, שאפשר להשתמש בו כדי לציין מפתח CMEK להצפנת המכונה. אם אתם רוצים להשתמש בהצפנה שמוגדרת כברירת מחדל ב-Google, אל תשתמשו בדגל הזה. אם רוצים להצפין את הנתונים באמצעות CMEK, מחליפים את הערכים הבאים:

      • ‫KEY_PROJECT בפרויקט שבו יצרתם את המפתח.
      • ‫KEY_LOCATION במיקום של המפתח.
      • ‫KEYRING_NAME בשם של אוסף המפתחות.
      • ‫KEY בשם של המפתח.

    מתחילה פעולה ממושכת של יצירת מכונה. הפלט אמור להיראות כך:

    {
    "name": "projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e",
    "metadata": {
      "@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
      "createTime": "2022-11-01T14:31:32.420469714Z",
      "target": "projects/my-project/locations/us-central1/instances/test",
      "verb": "create",
      "requestedCancellation": false,
      "apiVersion": "v1"
    },
    "done": false
    }
    

    כאשר projects/my-project/locations/us-central1/operations/operation-1234567894561-5ec69948c0f2b-60dd727f-a9b97a2e הוא OPERATION_NAME.

    יצירת המכונה נמשכת עד 60 דקות.

  2. מעתיקים את OPERATION_NAME.

  3. כדי לבדוק את הסטטוס של פעולת היצירה, מריצים את הפקודה הבאה:

    curl \
        -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        https://securesourcemanager.googleapis.com/v1/OPERATION_NAME
    

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

    כשהמכונה תהיה מוכנה, התגובה תיראה בערך כך:

    {
    "name": "projects/my-project/locations/us-central1/operations/operation-123456789012-5ec69948c0f2b-60dd727f-a9b97a2e",
    "metadata": {
      "@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.OperationMetadata",
      "createTime": "2022-11-01T14:31:32.420469714Z",
      "endTime": "2022-11-01T14:48:34.140378114Z",
      "target": "projects/my-project/locations/us-central1/instances/test",
      "verb": "create",
      "requestedCancellation": false,
      "apiVersion": "v1"
    },
    "done": true,
    "response": {
      "@type": "type.googleapis.com/google.cloud.securesourcemanager.v1.Instance",
      "name": "projects/my-project/locations/us-central1/instances/test",
      "createTime": "2022-11-01T14:31:32.416413630Z",
      "updateTime": "2022-11-01T14:31:32.416413630Z",
      "labels": {
        "ldap": "user",
        "source": "manual"
      },
      "state": "ACTIVE",
      "hostConfig": {
        "html": "test-098765432109.us-central1.sourcemanager.dev",
        "api": "test-098765432109-api.us-central1.sourcemanager.dev",
        "gitHttp": "test-098765432109-git.us-central1.sourcemanager.dev"
      }
    }
    }
    

    כאשר test-098765432109.us-central1.sourcemanager.dev הוא כתובת ה-URL של המכונה ב-HTML.

  4. מעתיקים את כתובת ה-URL ב-HTML מהפקודה לבדיקת הסטטוס שנוצרה בהצלחה. תצטרכו את כתובת ה-URL הזו כדי לגשת למכונה דרך ממשק האינטרנט שלה.

Terraform

כדי ליצור מכונה של Secure Source Manager באמצעות Terraform, משתמשים במשאב google_secure_source_manager_instance.

גישה למכונה

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

כדי ליצור מאגרים במכונה, צריך את התפקיד "יצירת מאגרים" (roles/securesourcemanager.repoCreator) בפרויקט של המכונה ואת התפקיד "יצירת מאגרים במכונה" (roles/securesourcemanager.instanceRepositoryCreator) במכונה של Secure Source Manager.

  1. כדי לגשת למכונה של Secure Source Manager דרך ממשק האינטרנט, מעתיקים את כתובת ה-URL הבאה לסרגל הכתובות בדפדפן.

    INSTANCE_ID-PROJECT_NUMBER.LOCATION.sourcemanager.dev

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫INSTANCE_ID בשם המכונה.
    • ‫PROJECT_NUMBER במספר הפרויקט של המכונה Google Cloud. איך מזהים פרויקטים?
    • ‫LOCATION באזור של המכונה.

  2. מופיע מסך OAuth שבו אתם נשאלים אם אתם רוצים לתת ל-sourcemanager.dev גישה לחשבון Google שלכם.

  3. לחצו על הלחצן Allow (אישור).

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

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