Menggunakan batasan kustom

Google Cloud 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 hierarki resource.Google Cloud Anda dapat menerapkan kebijakan organisasi di level organisasi, folder, atau project.

Kebijakan Organisasi memberikan batasan yang telah ditetapkan untuk berbagai layananGoogle Cloud . Namun, jika menginginkan kontrol yang lebih terperinci dan dapat disesuaikan atas kolom tertentu yang dibatasi dalam kebijakan organisasi, Anda juga dapat membuat batasan kustom dan menggunakan batasan kustom tersebut dalam kebijakan organisasi.

Manfaat

Anda dapat menggunakan kebijakan organisasi kustom untuk mengizinkan atau menolak operasi tertentu pada batch dan sesi Serverless for Apache Spark. Misalnya, jika permintaan untuk membuat workload batch gagal memenuhi validasi batasan kustom sebagaimana ditetapkan oleh kebijakan organisasi Anda, permintaan akan gagal, dan error akan ditampilkan kepada pemanggil.

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.

Harga

Layanan Kebijakan Organisasi, termasuk batasan yang telah ditetapkan dan khusus, ditawarkan tanpa biaya.

Sebelum memulai

  1. Menyiapkan project Anda
    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. Enable the Serverless for Apache Spark API.

      Enable the API

    5. Install the Google Cloud CLI.

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

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

      gcloud init
    8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

      Go to project selector

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

    10. Enable the Serverless for Apache Spark API.

      Enable the API

    11. Install the Google Cloud CLI.

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

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

      gcloud init
    14. Pastikan Anda mengetahui ID organisasi Anda.
    15. Peran yang diperlukan

      Untuk mendapatkan izin yang diperlukan untuk mengelola kebijakan organisasi, 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.

      Peran bawaan ini berisi izin yang diperlukan untuk mengelola kebijakan organisasi. Untuk melihat izin yang benar-benar diperlukan, luaskan bagian Izin yang diperlukan:

      Izin yang diperlukan

      Izin berikut diperlukan untuk mengelola kebijakan organisasi:

      • orgpolicy.constraints.list
      • orgpolicy.policies.create
      • orgpolicy.policies.delete
      • orgpolicy.policies.list
      • orgpolicy.policies.update
      • orgpolicy.policy.get
      • orgpolicy.policy.set

      Anda mungkin juga bisa mendapatkan izin ini dengan peran khusus atau peran bawaan lainnya.

      Membuat batasan khusus

      Batasan kustom ditentukan dalam file YAML oleh resource, metode, kondisi, dan tindakan yang diterapkan padanya. Serverless for Apache Spark mendukung batasan kustom yang diterapkan ke metode CREATE dari resource batch dan sesi.

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

      Membuat batasan kustom untuk resource batch

      Untuk membuat file YAML untuk batasan kustom Serverless for Apache Spark untuk resource batch, gunakan format berikut:

      name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
      resourceTypes:
      - dataproc.googleapis.com/Batch
      methodTypes: 
      - CREATE
      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 dimulai dengan custom., dan hanya boleh menyertakan huruf besar, huruf kecil, atau angka, misalnya, custom.batchMustHaveSpecifiedCategoryLabel. Panjang maksimum kolom ini adalah 70 karakter, tidak menghitung awalan, misalnya, organizations/123456789/customConstraints/custom.

      • CONDITION: kondisi CEL yang ditulis berdasarkan representasi resource layanan yang didukung. Kolom ini memiliki panjang maksimal 1000 karakter. Untuk mengetahui informasi selengkapnya tentang resource yang tersedia untuk menulis kondisi, lihat Batasan Dataproc Serverless pada resource dan operasi. Kondisi sampel: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service']).

      • ACTION: tindakan yang akan diambil jika kondisi terpenuhi. Ini dapat berupa ALLOW atau DENY.

      • DISPLAY_NAME: nama yang mudah dibaca manusia untuk batasan. Contoh nama tampilan: "Terapkan persyaratan label 'kategori' batch". 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 2000 karakter. Contoh deskripsi: "Hanya izinkan pembuatan batch Dataproc jika memiliki label 'category' dengan nilai 'retail', 'ads', atau 'service'".

      Membuat batasan kustom untuk resource sesi

      Untuk membuat file YAML untuk batasan kustom Serverless for Apache Spark untuk resource sesi, gunakan format berikut:

      name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
      resourceTypes:
      - dataproc.googleapis.com/Session
      methodTypes: 
      - CREATE
      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 dimulai dengan custom., dan hanya boleh menyertakan huruf besar, huruf kecil, atau angka, misalnya, custom.SessionNameMustStartWithTeamName. Panjang maksimum kolom ini adalah 70 karakter, tidak menghitung awalan organizations/123456789/customConstraints/. Contoh, organizations/123456789/customConstraints/custom.

      • CONDITION: kondisi CEL yang ditulis berdasarkan representasi resource layanan yang didukung. Kolom ini memiliki panjang maksimal 1000 karakter. Untuk mengetahui informasi selengkapnya tentang resource yang tersedia untuk menulis kondisi, lihat Batasan Dataproc Serverless pada resource dan operasi. Kondisi sampel: (resource.name.startsWith("dataproc").

      • ACTION: tindakan yang akan diambil jika kondisi terpenuhi. Ini dapat berupa ALLOW atau DENY.

      • DISPLAY_NAME: nama yang mudah dibaca manusia untuk batasan. Contoh nama tampilan: "Terapkan sesi harus memiliki TTL < 2 jam". 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 2000 karakter. Contoh deskripsi: "Hanya izinkan pembuatan sesi jika TTL yang ditetapkan dapat diterima".

      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 batasan khusus

      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.batchMustHaveSpecifiedCategoryLabel

      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 batasan khusus

      Bagian ini menjelaskan cara menguji batasan kustom untuk resource batch dan sesi.

      Menguji batasan kustom untuk resource batch

      Contoh pembuatan batch berikut mengasumsikan bahwa batasan kustom telah dibuat dan diterapkan pada pembuatan batch untuk mewajibkan batch memiliki label "category" yang dilampirkan dengan nilai "retail", "ads", atau "service: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service']).

      gcloud dataproc batches submit spark \
        --region us-west1
        --jars file:///usr/lib/spark/examples/jars/spark-examples.jar \
        --class org.apache.spark.examples.SparkPi  \
        --network default \
        --labels category=foo \
        --100
      

      Contoh output:

      Operation denied by custom org policies: ["customConstraints/custom.batchMustHaveSpecifiedCategoryLabel": ""Only allow Dataproc batch creation if it has a 'category' label with
        a 'retail', 'ads', or 'service' value""]
      

      Menguji batasan khusus untuk resource sesi

      Contoh pembuatan sesi berikut mengasumsikan bahwa batasan kustom telah dibuat dan diterapkan pada pembuatan sesi untuk mewajibkan sesi memiliki name yang dimulai dengan orgName.

      gcloud beta dataproc sessions create spark test-session
        --location us-central1
      

      Contoh output:

      Operation denied by custom org policy:
      ["customConstraints/custom.denySessionNameNotStartingWithOrgName": "Deny session
      creation if its name does not start with 'orgName'"]
      

      Batasan Serverless for Apache Spark pada resource dan operasi

      Bagian ini mencantumkan batasan kustom Google Cloud Serverless for Apache Spark yang tersedia untuk resource batch dan sesi.

      Batasan batch Google Cloud Serverless for Apache Spark yang didukung

      Batasan kustom Serverless for Apache Spark berikut tersedia untuk digunakan saat Anda membuat (mengirimkan) workload batch:

      Umum

      • resource.labels

      PySparkBatch

      • resource.pysparkBatch.mainPythonFileUri
      • resource.pysparkBatch.args
      • resource.pysparkBatch.pythonFileUris
      • resource.pysparkBatch.jarFileUris
      • resource.pysparkBatch.fileUris
      • resource.pysparkBatch.archiveUris

      SparkBatch

      • resource.sparkBatch.mainJarFileUri
      • resource.sparkBatch.mainClass
      • resource.sparkBatch.args
      • resource.sparkBatch.jarFileUris
      • resource.sparkBatch.fileUris
      • resource.sparkBatch.archiveUris

      SparRBatch

      • resource.sparkRBatch.mainRFileUri
      • resource.sparkRBatch.args
      • resource.sparkRBatch.fileUris
      • resource.sparkRBatch.archiveUris

      SparkSqlBatch

      • resource.sparkSqlBatch.queryFileUri
      • resource.sparkSqlBatch.queryVariables
      • resource.sparkSqlBatch.jarFileUris

      RuntimeConfig

      • resource.runtimeConfig.version
      • resource.runtimeConfig.containerImage
      • resource.runtimeConfig.properties
      • resource.runtimeConfig.repositoryConfig.pypiRepositoryConfig.pypiRepository
      • resource.runtimeConfig.autotuningConfig.scenarios
      • resource.runtimeConfig.cohort

      ExecutionConfig

      • resource.environmentConfig.executionConfig.serviceAccount
      • resource.environmentConfig.executionConfig.networkUri
      • resource.environmentConfig.executionConfig.subnetworkUri
      • resource.environmentConfig.executionConfig.networkTags
      • resource.environmentConfig.executionConfig.kmsKey
      • resource.environmentConfig.executionConfig.idleTtl
      • resource.environmentConfig.executionConfig.ttl
      • resource.environmentConfig.executionConfig.stagingBucket
      • resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType

      PeripheralsConfig

      • resource.environmentConfig.peripheralsConfig.metastoreService
      • resource.environmentConfig.peripheralsConfig.sparkHistoryServerConfig.dataprocCluster

      Batasan sesi Serverless for Apache Spark yang didukung Google Cloud

      Atribut sesi Google Cloud Serverless for Apache Spark berikut tersedia untuk digunakan saat Anda membuat batasan kustom pada sesi serverless:

      Umum

      • resource.name
      • resource.sparkConnectSession
      • resource.user
      • resource.sessionTemplate

      JupyterSession

      • resource.jupyterSession.kernel
      • resource.jupyterSession.displayName

      RuntimeConfig

      • resource.runtimeConfig.version
      • resource.runtimeConfig.containerImage
      • resource.runtimeConfig.properties
      • resource.runtimeConfig.repositoryConfig.pypiRepositoryConfig.pypiRepository
      • resource.runtimeConfig.autotuningConfig.scenarios
      • resource.runtimeConfig.cohort

      ExecutionConfig

      • resource.environmentConfig.executionConfig.serviceAccount
      • resource.environmentConfig.executionConfig.networkUri
      • resource.environmentConfig.executionConfig.subnetworkUri
      • resource.environmentConfig.executionConfig.networkTags
      • resource.environmentConfig.executionConfig.kmsKey
      • resource.environmentConfig.executionConfig.idleTtl
      • resource.environmentConfig.executionConfig.ttl
      • resource.environmentConfig.executionConfig.stagingBucket
      • resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType

      PeripheralsConfig

      • resource.environmentConfig.peripheralsConfig.metastoreService
      • resource.environmentConfig.peripheralsConfig.sparkHistoryServerConfig.dataprocCluster

      Contoh batasan kustom untuk kasus penggunaan umum

      Bagian ini menyertakan contoh batasan kustom untuk kasus penggunaan umum bagi resource batch dan sesi.

      Contoh batasan kustom untuk resource batch

      Tabel berikut memberikan contoh batasan kustom batch Serverless for Apache Spark:

      Deskripsi Sintaksis batasan
      Batch harus melampirkan label "kategori" dengan nilai yang diizinkan.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustHaveSpecifiedCategoryLabel
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition: ("category" in resource.labels) && (resource.labels['category'] in ['retail', 'ads', 'service'])
          actionType: ALLOW
          displayName: Enforce batch "category" label requirement.
          description: Only allow batch creation if it attaches a "category" label with an allowable value.
      Batch harus menetapkan versi runtime yang diizinkan.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustUseAllowedVersion
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition:  (has(resource.runtimeConfig.version)) && (resource.runtimeConfig.version in ["2.0.45", "2.0.48"])
          actionType: ALLOW
          displayName: Enforce batch runtime version.
          description: Only allow batch creation if it sets an allowable runtime version.
      Harus menggunakan SparkSQL.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustUseSparkSQL
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition: (has(resource.sparkSqlBatch))
          actionType: ALLOW
          displayName: Enforce batch only use SparkSQL Batch.
          description: Only allow creation of SparkSQL Batch.
      Batch harus menetapkan TTL kurang dari 2 jam.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchMustSetLessThan2hTtl
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition:  (has(resource.environmentConfig.executionConfig.ttl)) && (resource.environmentConfig.executionConfig.ttl <= duration('2h'))
          actionType: ALLOW
          displayName: Enforce batch TTL.
          description: Only allow batch creation if it sets an allowable TTL.
      Batch tidak dapat menyetel lebih dari 20 eksekutor awal Spark.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchInitialExecutorMax20
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition: (has(resource.runtimeConfig.properties)) && ('spark.executor.instances' in resource.runtimeConfig.properties)
           && (int(resource.runtimeConfig.properties['spark.executor.instances'])>20)
          actionType: DENY
          displayName: Enforce maximum number of batch Spark executor instances.
          description: Deny batch creation if it specifies more than 20 Spark executor instances.
      Batch tidak dapat menyetel lebih dari 20 eksekutor awal alokasi dinamis Spark.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchDynamicAllocationInitialExecutorMax20
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition: (has(resource.runtimeConfig.properties)) && ('spark.dynamicAllocation.initialExecutors' in resource.runtimeConfig.properties)
           && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.initialExecutors'])>20)
          actionType: DENY
          displayName: Enforce maximum number of batch dynamic allocation initial executors.
          description: Deny batch creation if it specifies more than 20 Spark dynamic allocation initial executors.
      Batch tidak boleh mengizinkan lebih dari 20 eksekutor alokasi dinamis.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchDynamicAllocationMaxExecutorMax20
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition: (resource.runtimeConfig.properties['spark.dynamicAllocation.enabled']=='false') || (('spark.dynamicAllocation.maxExecutors' in resource.runtimeConfig.properties) && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.maxExecutors'])<=20))
          actionType: ALLOW
          displayName: Enforce batch maximum number of dynamic allocation executors.
          description:  Only allow batch creation if dynamic allocation is disabled or
          the maximum number of dynamic allocation executors is set to less than or equal to 20.
      Batch harus menetapkan kunci KMS ke pola yang diizinkan.
          name: organizations/ORGANIZATION_ID/custom.batchKmsPattern
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition:  matches(resource.environmentConfig.executionConfig.kmsKey, '^keypattern[a-z]$')
          actionType: ALLOW
          displayName: Enforce batch KMS Key pattern.
          description: Only allow batch creation if it sets the KMS key to an allowable pattern.
      Batch harus menetapkan awalan bucket penyiapan ke nilai yang diizinkan.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchStagingBucketPrefix
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition:  resource.environmentConfig.executionConfig.stagingBucket.startsWith(ALLOWED_PREFIX)
          actionType: ALLOW
          displayName: Enforce batch staging bucket prefix.
          description: Only allow batch creation if it sets the staging bucket prefix to ALLOWED_PREFIX.
      Setelan memori batch executor harus diakhiri dengan akhiran m dan kurang dari 20000 m.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.batchExecutorMemoryMax
          resourceTypes:
          - dataproc.googleapis.com/Batch
          methodTypes:
          - CREATE
          condition:  ('spark.executor.memory' in resource.runtimeConfig.properties) && (resource.runtimeConfig.properties['spark.executor.memory'].endsWith('m')) && (int(resource.runtimeConfig.properties['spark.executor.memory'].split('m')[0])<20000)
          actionType: ALLOW
          displayName: Enforce batch executor maximum memory.
          description: Only allow batch creation if the executor memory setting ends with a suffix 'm' and is less than 20000 m.

      Contoh batasan kustom untuk resource sesi

      Tabel berikut memberikan contoh batasan kustom sesi Serverless for Apache Spark:

      Deskripsi Sintaksis batasan
      Sesi harus menetapkan sessionTemplate ke string kosong.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateMustBeEmpty
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: resource.sessionTemplate == ""
          actionType: ALLOW
          displayName: Enforce empty session templates.
          description: Only allow session creation if session template is empty string.
      sessionTemplate harus sama dengan ID template yang disetujui.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionTemplateIdMustBeApproved
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition:
          resource.sessionTemplate.startsWith("https://www.googleapis.com/compute/v1/projects/")
            &&
            resource.sessionTemplate.contains("/locations/") &&
            resource.sessionTemplate.contains("/sessionTemplates/") &&
             (
               resource.sessionTemplate.endsWith("/1") ||
               resource.sessionTemplate.endsWith("/2") ||
               resource.sessionTemplate.endsWith("/13")
             )
          actionType: ALLOW
          displayName: Enforce templateId must be 1, 2, or 13.
          description: Only allow session creation if session template ID is in the
          approved list, that is, 1, 2 and 13.
      Sesi harus menggunakan kredensial pengguna akhir untuk mengautentikasi beban kerja.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.AllowEUCSessions
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition:
          resource.environmentConfig.executionConfig.authenticationConfig.userWorkloadAuthenticationType=="END_USER_CREDENTIALS"
          actionType: ALLOW
          displayName: Require end user credential authenticated sessions.
          description: Allow session creation only if the workload is authenticated
          using end-user credentials.
      Sesi harus menetapkan versi runtime yang diizinkan.
          name: organizations/ORGANIZATION_ID/custom.sessionMustUseAllowedVersion
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: (has(resource.runtimeConfig.version)) &&
          (resource.runtimeConfig.version in ["2.0.45", "2.0.48"])
          actionType: ALLOW
          displayName: Enforce session runtime version.
          description: Only allow session creation if it sets an allowable runtime
          version.
      Sesi harus menetapkan TTL kurang dari 2 jam.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionMustSetLessThan2hTtl
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: (has(resource.environmentConfig.executionConfig.ttl)) &&
          (resource.environmentConfig.executionConfig.ttl <= duration('2h'))
          actionType: ALLOW
          displayName: Enforce session TTL.
          description: Only allow session creation if it sets an allowable TTL.
      Sesi tidak dapat menyetel lebih dari 20 eksekutor awal Spark.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionInitialExecutorMax20
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: (has(resource.runtimeConfig.properties)) &&
          ('spark.executor.instances' in resource.runtimeConfig.properties) &&
          (int(resource.runtimeConfig.properties['spark.executor.instances'])>20)
          actionType: DENY
          displayName: Enforce maximum number of session Spark executor instances.
          description: Deny session creation if it specifies more than 20 Spark executor
          instances.
      Sesi tidak dapat menyetel lebih dari 20 alokasi dinamis Spark awal eksekutor.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionDynamicAllocationInitialExecutorMax20
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: (has(resource.runtimeConfig.properties)) &&
          ('spark.dynamicAllocation.initialExecutors' in resource.runtimeConfig.properties)
          && (int(resource.runtimeConfig.properties['spark.dynamicAllocation.initialExecutors'])>20)
          actionType: DENY
          displayName: Enforce maximum number of session dynamic allocation initial executors.
          description: Deny session creation if it specifies more than 20 Spark dynamic
          allocation initial executors.
      Sesi harus menetapkan kunci KMS ke pola yang diizinkan.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionKmsPattern
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: matches(resource.environmentConfig.executionConfig.kmsKey, '^keypattern[a-z]$')
          actionType: ALLOW
          displayName: Enforce session KMS Key pattern.
          description: Only allow session creation if it sets the KMS key to an
          allowable pattern.
      Sesi harus menetapkan awalan bucket penyiapan ke nilai yang diizinkan.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionStagingBucketPrefix
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: resource.environmentConfig.executionConfig.stagingBucket.startsWith(ALLOWED_PREFIX)
          actionType: ALLOW
          displayName: Enforce session staging bucket prefix.
          description: Only allow batch creation if it sets the staging bucket prefix
          to ALLOWED_PREFIX.
      Setelan memori eksekutor sesi harus diakhiri dengan akhiran m dan kurang dari 20000 m.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.sessionExecutorMemoryMax
          resourceTypes:
          - dataproc.googleapis.com/Session
          methodTypes:
          - CREATE
          condition: ('spark.executor.memory' in resource.runtimeConfig.properties) &&
          (resource.runtimeConfig.properties['spark.executor.memory'].endsWith('m')) &&
          (int(resource.runtimeConfig.properties['spark.executor.memory'].split('m')[0])<20000)
          actionType: ALLOW
          displayName: Enforce session executor maximum memory.
          description: Only allow session creation if the executor memory setting ends
          with a suffix 'm' and is less than 20000 m.

      Langkah berikutnya