אם אתם עובדים עם כמה חברות ורוצים לשתף איתן פעולה בקוד המקור, מומלץ ליצור מכונה נפרדת לכל חברה.
כדי ליצור מכונה שמופעל בה VPC Service Controls, קראו את המאמר הגדרת Secure Source Manager בהיקף של VPC Service Controls.
לפני שמתחילים
-
נכנסים לחשבון Google.
אם עדיין אין חשבון, יוצרים חשבון חדש.
-
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 Secure Source Manager API, if it is not already enabled.
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.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
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 Secure Source Manager API, if it is not already enabled.
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.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
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
מריצים את הפקודה הבאה כדי ליצור מכונה. יכול להיות שתתבקשו לאמת את ה-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 דקות.
שימו לב לערך של
OPERATION_NAME, כי תצטרכו להשתמש בו כדי לבדוק את סטטוס הפעולה.כדי לבדוק את הסטטוס של הפעולה
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.מעתיקים את כתובת ה-URL ב-HTML מהפקודה לבדיקת הסטטוס שנוצרה בהצלחה. תצטרכו את כתובת ה-URL הזו כדי לגשת למכונה דרך ממשק האינטרנט שלה.
API
מריצים את הפקודה הבאה כדי ליצור מכונה. יכול להיות שתתבקשו לאמת את ה-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 דקות.
מעתיקים את
OPERATION_NAME.כדי לבדוק את הסטטוס של פעולת היצירה, מריצים את הפקודה הבאה:
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.מעתיקים את כתובת ה-URL ב-HTML מהפקודה לבדיקת הסטטוס שנוצרה בהצלחה. תצטרכו את כתובת ה-URL הזו כדי לגשת למכונה דרך ממשק האינטרנט שלה.
Terraform
כדי ליצור מכונה של Secure Source Manager באמצעות Terraform, משתמשים במשאב google_secure_source_manager_instance.
גישה למכונה
אחרי שיוצרים את המכונה, אפשר לגשת אליה דרך ממשק האינטרנט שלה באמצעות דפדפן.
כדי ליצור מאגרים במכונה, צריך את התפקיד "יצירת מאגרים" (roles/securesourcemanager.repoCreator) בפרויקט של המכונה ואת התפקיד "יצירת מאגרים במכונה" (roles/securesourcemanager.instanceRepositoryCreator) במכונה של Secure Source Manager.
-
כדי לגשת למכונה של Secure Source Manager דרך ממשק האינטרנט, מעתיקים את כתובת ה-URL הבאה לסרגל הכתובות בדפדפן.
INSTANCE_ID-PROJECT_NUMBER.LOCATION.sourcemanager.devמחליפים את מה שכתוב בשדות הבאים:
- INSTANCE_ID בשם המכונה.
- PROJECT_NUMBER במספר הפרויקט של המכונה Google Cloud. איך מזהים פרויקטים?
- LOCATION באזור של המכונה.
מופיע מסך OAuth שבו אתם נשאלים אם אתם רוצים לתת ל-
sourcemanager.devגישה לחשבון Google שלכם.לחצו על הלחצן Allow (אישור).
ממשק האינטרנט של Secure Source Manager נפתח. אתם יכולים ליצור ולראות מאגרים ואת כל הבעיות ובקשות המשיכה שמשויכות אליהם דרך ממשק האינטרנט.