애셋 보기

이 문서에서는 Cloud Shell에서 Cloud 애셋 인벤토리와 Google Cloud CLI를 사용하여 애셋을 보는 방법을 보여줍니다.

시작하기 전에

이 문서의 안내를 완료하려면 Cloud 애셋 인벤토리 API를 사용 설정하고 Cloud 애셋 인벤토리 및 Compute Engine에 액세스할 수 있는 권한을 설정해야 합니다.

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  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. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  4. Enable the Cloud Asset Inventory 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. 이 가이드에 기존 프로젝트를 사용하는 경우 이 가이드를 완료하는 데 필요한 권한이 있는지 확인합니다. 새 프로젝트를 만든 경우 필요한 권한이 이미 있습니다.

  7. Enable the Cloud Asset Inventory 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. 필요한 역할

    이 안내를 완료하는 데 필요한 권한을 얻으려면 관리자에게 조직, 폴더 또는 프로젝트에 대한 다음 IAM 역할을 부여해 달라고 요청하세요.

    역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

    이러한 사전 정의된 역할에는 이 안내를 완료하는 데 필요한 권한이 포함되어 있습니다. 필요한 정확한 권한을 보려면 필수 권한 섹션을 펼치세요.

    필수 권한

    이 안내를 완료하려면 다음 권한이 필요합니다.

    • 애셋 메타데이터를 나열하려면 다음을 실행하세요. cloudasset.assets.listResource
    • Compute Engine VM 인스턴스를 만들려면 다음 단계를 따르세요.
      • compute.disks.create
      • compute.instances.create
      • compute.instances.delete
      • compute.instances.setServiceAccount
      • compute.projects.get
      • compute.subnetworks.use
      • compute.subnetworks.useExternalIp
      • compute.zoneOperations.get

    커스텀 역할이나 다른 사전 정의된 역할을 사용하여 이 권한을 부여받을 수도 있습니다.

    애셋 보기

    원하는 프로젝트에서 Cloud 애셋 인벤토리에서 볼 수 있도록 Compute Engine VM 인스턴스를 만듭니다.

    1. Google Cloud 콘솔에서 VM 인스턴스 페이지로 이동합니다.

      VM 인스턴스로 이동

    2. 인스턴스 만들기를 클릭합니다.

    3. 인스턴스의 이름을 입력합니다.

    4. 만들기를 클릭합니다.

    5. 인스턴스가 생성될 때까지 기다립니다.

    프로젝트의 모든 VM 인스턴스를 나열합니다.

    1. Google Cloud 콘솔에서 Cloud Shell 활성화를 클릭합니다.

    2. Cloud Shell에서 다음 명령어를 실행합니다.

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

      PROJECT_ID를 애셋을 나열할 프로젝트의 ID로 바꿉니다.

      이전 코드 샘플에서는 compute.googleapis.com/Instance 애셋 유형이 Compute Engine VM 인스턴스를 나열하는 데만 사용됩니다. 모든 애셋 유형을 보려면 애셋 유형을 참조하세요.

      콘텐츠 유형 resource도 설정되었습니다. 그러면 응답에서 반환되어야 하는 resource 메타데이터도 지정됩니다. 콘텐츠 유형이 설정되지 않으면 애셋 이름, 마지막 업데이트 시간, 속해 있는 프로젝트와 같은 각 애셋에 대한 기본 정보만 반환됩니다.

    삭제

    이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.

    1. Google Cloud 콘솔에서 VM 인스턴스 페이지로 이동합니다.

      VM 인스턴스로 이동

    2. 만든 VM 인스턴스의 이름과 동일한 행에서 작업 더보기를 클릭합니다.

    3. 삭제를 클릭한 후 삭제되었는지 확인합니다.

    다음 단계

    • 애셋 보기와 관련된 더 많은 옵션을 알아보려면 애셋 나열을 참조하세요.