Menggunakan kebijakan organisasi kustom

Halaman ini menunjukkan cara menggunakan batasan kustom Layanan Kebijakan Organisasi untuk membatasi operasi tertentu pada resource berikut: Google Cloud

  • healthcare.googleapis.com/Dataset
  • healthcare.googleapis.com/FhirStore
  • healthcare.googleapis.com/DicomStore
  • healthcare.googleapis.com/Hl7V2Store
  • healthcare.googleapis.com/ConsentStore

Untuk mempelajari lebih lanjut Kebijakan Organisasi, lihat Kebijakan organisasi kustom.

Tentang batasan dan kebijakan organisasi

Google Cloud Layanan Kebijakan Organisasi memberi Anda kontrol terpusat dan terprogram atas resource organisasi. Sebagai administrator kebijakan organisasi, Anda dapat menentukan kebijakan organisasi, yang merupakan serangkaian batasan yang disebut batasan yang berlaku untuk Google Cloud resource dan turunan dari resource tersebut dalam Google Cloud hierarki resource. Anda dapat menerapkan kebijakan organisasi di tingkat organisasi, folder, atau project.

Kebijakan Organisasi menyediakan batasan terkelola bawaan untuk berbagai layanan Google Cloud . Namun, jika menginginkan kontrol yang lebih terperinci dan dapat disesuaikan atas kolom tertentu yang dibatasi dalam kebijakan organisasi, Anda juga dapat membuat batasan khusus dan menggunakan batasan khusus tersebut dalam kebijakan organisasi.

Pewarisan kebijakan

Secara default, kebijakan organisasi diwarisi oleh turunan resource tempat Anda menerapkan kebijakan tersebut. Misalnya, jika Anda menerapkan kebijakan pada folder, Google Cloud akan menerapkan kebijakan tersebut pada semua project di folder tersebut. Untuk mempelajari lebih lanjut perilaku ini dan cara mengubahnya, lihat Aturan evaluasi hierarki.

Batasan

Kolom healthcare.googleapis.com/Hl7V2Store berikut tidak didukung:

Kolom healthcare.googleapis.com/FhirStore berikut tidak didukung:

Sebelum memulai

  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.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  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.

    Go to project selector

  8. Make sure that billing is enabled for your Google Cloud project.

  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
  12. Pastikan Anda mengetahui ID organisasi Anda.
  13. Peran yang diperlukan

    Untuk mendapatkan izin yang diperlukan untuk mengelola kebijakan organisasi kustom, minta administrator untuk memberi Anda peran IAM Administrator Kebijakan Organisasi (roles/orgpolicy.policyAdmin) di resource organisasi. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

    Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

    Membuat batasan khusus

    Batasan kustom ditentukan dalam file YAML oleh resource, metode, kondisi, dan tindakan yang didukung oleh layanan tempat Anda menerapkan kebijakan organisasi. Kondisi untuk batasan kustom Anda ditentukan menggunakan Common Expression Language (CEL). Untuk mengetahui informasi selengkapnya tentang cara membangun kondisi dalam batasan khusus menggunakan CEL, lihat bagian CEL tentang Membuat dan mengelola batasan kustom.

    Untuk membuat batasan khusus, buat file YAML menggunakan format berikut:

    name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
    resourceTypes:
    - RESOURCE_NAME
    methodTypes:
    - CREATE
    - UPDATE
    condition: "CONDITION"
    actionType: ACTION
    displayName: DISPLAY_NAME
    description: DESCRIPTION
    

    Ganti kode berikut:

    • ORGANIZATION_ID: ID organisasi Anda, seperti 123456789.

    • CONSTRAINT_NAME: nama yang Anda inginkan untuk batasan kustom baru. Batasan kustom harus diawali dengan custom., dan hanya boleh menyertakan huruf besar, huruf kecil, atau angka. Contohnya, custom.enableHealthcareCMEK. Panjang maksimum kolom ini adalah 70 karakter.

    • RESOURCE_NAME: nama lengkap Google Cloud resource yang berisi objek dan kolom yang ingin Anda batasi. Misalnya, healthcare.googleapis.com/Dataset.

    • CONDITION: kondisi CEL yang ditulis berdasarkan representasi resource layanan yang didukung. Kolom ini memiliki panjang maksimal 1.000 karakter. Lihat Resource yang didukung untuk mengetahui informasi selengkapnya tentang resource yang tersedia untuk menulis kondisi. Contoh, "!has(resource.encryptionSpec)"

    • ACTION: tindakan yang akan diambil jika condition terpenuhi. Nilai yang mungkin adalah ALLOW dan DENY.

    • DISPLAY_NAME: nama yang mudah dibaca manusia untuk batasan. Kolom ini memiliki panjang maksimal 200 karakter.

    • DESCRIPTION: deskripsi batasan yang mudah dipahami untuk ditampilkan sebagai pesan error saat kebijakan dilanggar. Kolom ini memiliki panjang maksimal 2.000 karakter.

    Untuk mengetahui informasi selengkapnya tentang cara membuat batasan kustom, lihat Menentukan batasan kustom.

    Menyiapkan batasan kustom

    Setelah membuat file YAML untuk batasan khusus baru, Anda harus menyiapkannya agar tersedia untuk kebijakan organisasi di organisasi Anda. Untuk menyiapkan batasan kustom, gunakan perintah gcloud org-policies set-custom-constraint:
    gcloud org-policies set-custom-constraint CONSTRAINT_PATH
    Ganti CONSTRAINT_PATH dengan jalur lengkap ke file batasan kustom Anda. Contohnya, /home/user/customconstraint.yaml Setelah selesai, batasan khusus Anda tersedia sebagai kebijakan organisasi dalam daftar kebijakan organisasi. Google Cloud Untuk memverifikasi bahwa ada batasan kustom, gunakan perintah gcloud org-policies list-custom-constraints:
    gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
    Ganti ORGANIZATION_ID dengan ID resource organisasi Anda. Untuk mengetahui informasi selengkapnya, lihat Melihat kebijakan organisasi.

    Menerapkan kebijakan organisasi kustom

    Anda dapat menerapkan batasan dengan membuat kebijakan organisasi yang mereferensikannya, lalu menerapkan kebijakan organisasi tersebut ke resource Google Cloud .

    Konsol

    1. Di konsol Google Cloud , buka halaman Kebijakan organisasi.

      Buka Organization policies

    2. Dari pemilih project, pilih project yang ingin Anda tetapkan kebijakan organisasinya.
    3. Dari daftar di halaman Kebijakan organisasi, pilih batasan Anda untuk melihat halaman Detail kebijakan untuk batasan tersebut.
    4. Untuk mengonfigurasi kebijakan organisasi untuk resource ini, klik Manage policy.
    5. Di halaman Edit kebijakan, pilih Ganti kebijakan induk.
    6. Klik Add a rule.
    7. Di bagian Penerapan, pilih apakah penerapan kebijakan organisasi ini diaktifkan atau dinonaktifkan.
    8. Opsional: Untuk membuat kebijakan organisasi bersyarat pada tag, klik Tambahkan kondisi. Perhatikan bahwa jika menambahkan aturan kondisional ke kebijakan organisasi, Anda harus menambahkan setidaknya satu aturan tanpa syarat atau kebijakan tidak dapat disimpan. Untuk mengetahui informasi selengkapnya, lihat Menetapkan kebijakan organisasi dengan tag.
    9. Klik Uji perubahan untuk menyimulasikan efek kebijakan organisasi. Simulasi kebijakan tidak tersedia untuk batasan terkelola lama. Untuk mengetahui informasi selengkapnya, lihat Menguji perubahan kebijakan organisasi dengan Policy Simulator.
    10. Untuk menyelesaikan dan menerapkan kebijakan organisasi, klik Set policy. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

    gcloud

    Untuk membuat kebijakan organisasi dengan aturan boolean, buat file YAML kebijakan yang merujuk batasan:

          name: projects/PROJECT_ID/policies/CONSTRAINT_NAME
          spec:
            rules:
            - enforce: true
        

    Ganti kode berikut:

    • PROJECT_ID: project tempat Anda ingin menerapkan batasan.
    • CONSTRAINT_NAME: nama yang Anda tentukan untuk batasan kustom. Contoh, custom.enableHealthcareCMEK

    Untuk menerapkan kebijakan organisasi yang berisi batasan, jalankan perintah berikut:

        gcloud org-policies set-policy POLICY_PATH
        

    Ganti POLICY_PATH dengan jalur lengkap ke file YAML kebijakan organisasi Anda. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

    Menguji kebijakan organisasi kustom

    Contoh berikut membuat batasan dan kebijakan kustom yang mewajibkan semua set data baru dalam project tertentu dienkripsi dengan kunci enkripsi yang dikelola pelanggan (CMEK).

    Sebelum memulai, Anda harus mengetahui hal-hal berikut:

    • ID organisasi Anda
    • Project ID

    Membuat batasan

    1. Simpan file berikut sebagai constraint-enable-healthcare-cmek.yaml:

      name: organizations/ORGANIZATION_ID/customConstraints/custom.enableHealthcareCMEK
      resourceTypes:
      - healthcare.googleapis.com/Dataset
      methodTypes:
      - CREATE
      condition: "!has(resource.encryptionSpec)"
      actionType: DENY
      displayName: Enable Healthcare CMEK
      description: All new datasets must be CMEK-encrypted.
      

      Hal ini menentukan batasan untuk setiap set data baru, jika set data tidak dienkripsi dengan CMEK, operasi akan ditolak.

    2. Terapkan batasan:

      gcloud org-policies set-custom-constraint ~/constraint-enable-healthcare-cmek.yaml
      
    3. Pastikan batasan ada:

      gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
      

      Outputnya mirip dengan yang berikut ini:

      CUSTOM_CONSTRAINT                       ACTION_TYPE  METHOD_TYPES   RESOURCE_TYPES                     DISPLAY_NAME
      custom.enableHealthcareCMEK             DENY         CREATE         healthcare.googleapis.com/Dataset   Enable Healthcare CMEK
      ...
      

    Membuat kebijakan

    1. Simpan file berikut sebagai policy-enable-healthcare-cmek.yaml:

      name: projects/PROJECT_ID/policies/custom.enableHealthcareCMEK
      spec:
        rules:
        - enforce: true
      

      Ganti PROJECT_ID dengan project ID Anda.

    2. Terapkan kebijakan:

      gcloud org-policies set-policy ~/policy-enable-healthcare-cmek.yaml
      
    3. Pastikan kebijakan ada:

      gcloud org-policies list --project=PROJECT_ID
      

      Outputnya mirip dengan hal berikut ini:

      CONSTRAINT                    LIST_POLICY    BOOLEAN_POLICY    ETAG
      custom.enableHealthcareCMEK   -              SET               COCsm5QGENiXi2E=
      

    Setelah Anda menerapkan kebijakan, tunggu sekitar dua menit hingga Cloud Healthcare API mulai menerapkan kebijakan tersebut.

    Menguji kebijakan

    Mencoba membuat set data Cloud Healthcare API tanpa memberikan kunci CMEK di project:

    curl -X POST \
         -H "Authorization: Bearer $(gcloud auth print-access-token)" \
         -H "Content-Type: application/json; charset=utf-8" \
         -d "" \
         "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID"
    

    Outputnya adalah sebagai berikut:

    Operation denied by custom org policies: ["customConstraints/custom.enableHealthcareCMEK": "All new datasets must be CMEK-encrypted."]
    

    Resource yang didukung Cloud Healthcare API

    Tabel berikut mencantumkan resource Cloud Healthcare API yang dapat Anda rujuk dalam batasan kustom.

    Resource Kolom
    healthcare.googleapis.com/ConsentStore resource.defaultConsentTtl
    resource.enableConsentCreateOnUpdate
    resource.name
    healthcare.googleapis.com/Dataset resource.encryptionSpec.kmsKeyName
    resource.name
    resource.timeZone
    healthcare.googleapis.com/DicomStore resource.name
    resource.notificationConfig.pubsubTopic
    resource.notificationConfig.sendForBulkImport
    resource.notificationConfigs.pubsubTopic
    resource.streamConfigs.bigqueryDestination.force
    resource.streamConfigs.bigqueryDestination.tableUri
    resource.streamConfigs.bigqueryDestination.writeDisposition
    healthcare.googleapis.com/FhirStore resource.bulkExportGcsDestination.uriPrefix
    resource.complexDataTypeReferenceParsing
    resource.consentConfig.accessDeterminationLogConfig.logLevel
    resource.consentConfig.accessEnforced
    resource.consentConfig.consentHeaderHandling.profile
    resource.consentConfig.version
    resource.defaultSearchHandlingStrict
    resource.disableReferentialIntegrity
    resource.disableResourceVersioning
    resource.enableHistoryModifications
    resource.enableUpdateCreate
    resource.name
    resource.notificationConfigs.pubsubTopic
    resource.notificationConfigs.sendFullResource
    resource.notificationConfigs.sendPreviousResourceOnDelete
    resource.streamConfigs.bigqueryDestination.datasetUri
    resource.streamConfigs.bigqueryDestination.force
    resource.streamConfigs.bigqueryDestination.schemaConfig.lastUpdatedPartitionConfig.expirationMs
    resource.streamConfigs.bigqueryDestination.schemaConfig.lastUpdatedPartitionConfig.type
    resource.streamConfigs.bigqueryDestination.schemaConfig.recursiveStructureDepth
    resource.streamConfigs.bigqueryDestination.schemaConfig.schemaType
    resource.streamConfigs.bigqueryDestination.writeDisposition
    resource.streamConfigs.deidentifiedStoreDestination.config.dicom.filterProfile
    resource.streamConfigs.deidentifiedStoreDestination.config.dicom.keepList.tags
    resource.streamConfigs.deidentifiedStoreDestination.config.dicom.removeList.tags
    resource.streamConfigs.deidentifiedStoreDestination.config.dicom.skipIdRedaction
    resource.streamConfigs.deidentifiedStoreDestination.config.fhir.defaultKeepExtensions
    resource.streamConfigs.deidentifiedStoreDestination.config.fhir.fieldMetadataList.action
    resource.streamConfigs.deidentifiedStoreDestination.config.fhir.fieldMetadataList.paths
    resource.streamConfigs.deidentifiedStoreDestination.config.image.additionalInfoTypes
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.action
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.modality
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.pixelBox.height
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.pixelBox.left
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.pixelBox.top
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.pixelBox.width
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.relativeBox.relativeHeight
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.relativeBox.relativeLeft
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.relativeBox.relativeTop
    resource.streamConfigs.deidentifiedStoreDestination.config.image.areasOfInterest.relativeBox.relativeWidth
    resource.streamConfigs.deidentifiedStoreDestination.config.image.excludeInfoTypes
    resource.streamConfigs.deidentifiedStoreDestination.config.image.minLikelihood
    resource.streamConfigs.deidentifiedStoreDestination.config.image.textRedactionMode
    resource.streamConfigs.deidentifiedStoreDestination.config.image.useBurnedInAnnotationAttribute
    resource.streamConfigs.deidentifiedStoreDestination.config.text.additionalTransformations.characterMaskConfig.maskingCharacter
    resource.streamConfigs.deidentifiedStoreDestination.config.text.additionalTransformations.infoTypes
    resource.streamConfigs.deidentifiedStoreDestination.config.text.excludeInfoTypes
    resource.streamConfigs.deidentifiedStoreDestination.config.text.transformations.characterMaskConfig.maskingCharacter
    resource.streamConfigs.deidentifiedStoreDestination.config.text.transformations.infoTypes
    resource.streamConfigs.deidentifiedStoreDestination.config.useRegionalDataProcessing
    resource.streamConfigs.deidentifiedStoreDestination.store
    resource.streamConfigs.resourceTypes
    resource.validationConfig.disableFhirpathValidation
    resource.validationConfig.disableProfileValidation
    resource.validationConfig.disableReferenceTypeValidation
    resource.validationConfig.disableRequiredFieldValidation
    resource.validationConfig.enabledImplementationGuides
    resource.version
    healthcare.googleapis.com/Hl7V2Store resource.name
    resource.notificationConfigs.filter
    resource.notificationConfigs.pubsubTopic
    resource.parserConfig.allowNullHeader
    resource.parserConfig.schema.ignoreMinOccurs
    resource.parserConfig.schema.schemas.version.mshField
    resource.parserConfig.schema.schemas.version.value
    resource.parserConfig.schema.schematizedParsingType
    resource.parserConfig.schema.types.type.fields.maxOccurs
    resource.parserConfig.schema.types.type.fields.minOccurs
    resource.parserConfig.schema.types.type.fields.name
    resource.parserConfig.schema.types.type.fields.table
    resource.parserConfig.schema.types.type.fields.type
    resource.parserConfig.schema.types.type.name
    resource.parserConfig.schema.types.type.primitive
    resource.parserConfig.schema.types.version.mshField
    resource.parserConfig.schema.types.version.value
    resource.parserConfig.schema.unexpectedFieldHandling
    resource.parserConfig.schema.unexpectedSegmentHandling
    resource.parserConfig.segmentTerminator
    resource.parserConfig.version
    resource.rejectDuplicateMessage

    Langkah berikutnya