הצגת הנכסים

מסמך זה מראה לכם איך להציג את הנכסים שלכם באמצעות מאגר משאבי ענן ו-Google Cloud CLI ב-Cloud Shell.

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

כדי לבצע את ההוראות שבמסמך הזה, צריך להפעיל את Cloud Asset Inventory API ולהגדיר הרשאות גישה למאגר משאבי ענן ול-Compute Engine.

  1. In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance 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

  2. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  3. Enable the Cloud Asset Inventory 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

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

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

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

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

ההרשאות הנדרשות

כדי לבצע את ההוראות האלה, נדרשות ההרשאות הבאות:

  • כדי להציג רשימה של מטא-נתונים של נכסים: cloudasset.assets.listResource
  • כדי ליצור מכונה וירטואלית של Compute Engine:
    • compute.disks.create
    • compute.instances.create
    • compute.instances.delete
    • compute.instances.setServiceAccount
    • compute.projects.get
    • compute.subnetworks.use
    • compute.subnetworks.useExternalIp
    • compute.zoneOperations.get

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

הצגת הנכסים

בפרויקט שבחרתם, יוצרים מכונה וירטואלית של Compute Engine כדי שתוכלו לראות אותה ב-Cloud Asset Inventory:

  1. נכנסים לדף VM instances במסוף Cloud de Confiance .

    כניסה לדף VM instances

  2. לוחצים על Create instance.

  3. נותנים שם למכונה.

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

  5. מחכים שהמכונה תיווצר.

מציגים את כל המכונות הווירטואליות בפרויקט:

  1. במסוף Cloud de Confiance , לוחצים על Activate Cloud Shell.

  2. ב-Cloud Shell, מריצים את הפקודה הבאה:

    gcloud asset list \
        --project=PROJECT_ID \
        --asset-types=compute.googleapis.com/Instance \
        --content-type=resource
    

    מחליפים את PROJECT_ID במזהה הפרויקט שאת הנכסים שלו רוצים להציג ברשימה.

    בדוגמת הקוד הקודמת, סוג הנכס compute.googleapis.com/Instance משמש רק כדי להציג את המכונות הווירטואליות של Compute Engine. לרשימה המלאה של סוגי הנכסים

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

הסרת המשאבים

כדי לא לצבור חיובים בחשבון Cloud de Confiance על המשאבים שבהם השתמשתם בדף הזה, מבצעים את הפעולות הבאות.

  1. נכנסים לדף VM instances במסוף Cloud de Confiance .

    כניסה לדף VM instances

  2. בשורה של שם המכונה הווירטואלית שיצרתם, לוחצים על More actions.

  3. לוחצים על מחיקה ואז מאשרים את המחיקה.

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