שימוש במדיניות ארגונית בהתאמה אישית

בדף הזה מוסבר איך להשתמש באילוצים מותאמים אישית של Organization Policy Service כדי להגביל פעולות ספציפיות במשאבים הבאים של Google Cloud :

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

מידע נוסף על מדיניות הארגון זמין במאמר בנושא מדיניות ארגונית בהתאמה אישית.

מידע על מדיניות הארגון ואילוצים

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

במסגרת Organization Policy מוצעות מגבלות מנוהלות מובנות עבור שירותים שונים של Google Cloud . עם זאת, אם אתם רוצים שליטה מדויקת יותר בשדות הספציפיים שמוגבלים במדיניות הארגון, אתם יכולים גם ליצור אילוצים בהתאמה אישית ולהשתמש בהם במדיניות הארגון.

העברה בירושה של מדיניות

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

מגבלות

אין תמיכה בשדות הבאים של healthcare.googleapis.com/Hl7V2Store:

אין תמיכה בשדות הבאים של healthcare.googleapis.com/FhirStore:

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

  1. נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  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. Verify that billing is enabled for your Google Cloud project.

  4. התקינו את ה-CLI של Google Cloud.

  5. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  6. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init
  7. 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

  8. Verify that billing is enabled for your Google Cloud project.

  9. התקינו את ה-CLI של Google Cloud.

  10. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  11. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init
  12. חשוב לוודא שאתם יודעים מהו מספר הארגון שלכם.

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

כדי לקבל את ההרשאות שדרושות לניהול של כללי מדיניות ארגוניים בהתאמה אישית, צריך לבקש מהאדמין להקצות לכם את תפקיד ה-IAM 'אדמין של כללי מדיניות ארגוניים' (`roles/orgpolicy.policyAdmin`) במשאב הארגון. להסבר על מתן תפקידים, ראו איך מנהלים את הגישה ברמת הפרויקט, התיקייה והארגון.

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

משאבים נתמכים ב-Cloud Healthcare API

בטבלה הבאה מפורטים המשאבים של Cloud Healthcare API שאפשר להפנות אליהם באילוצים בהתאמה אישית.

משאב שדה
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

הגדרת אילוץ בהתאמה אישית

אילוץ בהתאמה אישית מוגדר בקובץ YAML לפי המשאבים, השיטות, התנאים והפעולות שנתמכים על ידי השירות שבו אתם אוכפים את מדיניות הארגון. התנאים להגבלות המותאמות אישית מוגדרים באמצעות Common Expression Language ‏ (CEL). מידע נוסף על יצירת תנאים באילוצים מותאמים אישית באמצעות CEL זמין בקטע על CEL במאמר יצירה וניהול של אילוצים מותאמים אישית.

המסוף

כדי ליצור אילוץ בהתאמה אישית:

  1. נכנסים לדף Organization policies במסוף Google Cloud .

    מעבר למדיניות הארגון

  2. בבורר הפרויקטים, בוחרים את הפרויקט שרוצים להגדיר לו את מדיניות הארגון.
  3. לוחצים על Custom constraint (הגבלה מותאמת אישית).
  4. בתיבה שם לתצוגה, מזינים שם שאנשים יכולים לקרוא למגבלה. השם הזה משמש בהודעות שגיאה, ואפשר להשתמש בו לצורך זיהוי וניפוי באגים. אל תשתמשו בפרטים אישיים מזהים (PII) או במידע אישי רגיש בשמות לתצוגה, כי השם הזה עלול להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 200 תווים.
  5. בתיבה Constraint ID (מזהה ההגבלה), מזינים את המזהה שרוצים להגדיר להגבלה החדשה בהתאמה אישית. אילוץ מותאם אישית יכול להכיל רק אותיות (כולל אותיות גדולות וקטנות) או מספרים, למשל custom.enableHealthcareCMEK. השדה הזה יכול להכיל עד 70 תווים, לא כולל הקידומת (custom.), לדוגמה, organizations/123456789/customConstraints/custom. אל תכללו פרטים אישיים מזהים (PII) או נתונים רגישים במזהה האילוץ, כי הם עלולים להיחשף בהודעות שגיאה.
  6. בתיבה Description, מזינים תיאור של האילוץ שקל לאנשים לקרוא. התיאור הזה משמש כהודעת שגיאה כשמתרחשת הפרה של המדיניות. לכלול פרטים על הסיבה להפרת המדיניות ואיך לפתור אותה. אל תכללו בתיאור פרטים אישיים מזהים (PII) או מידע אישי רגיש, כי הם עלולים להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 2,000 תווים.
  7. בתיבה Resource type, בוחרים את השם של Google Cloud משאב REST שמכיל את האובייקט והשדה שרוצים להגביל – לדוגמה, container.googleapis.com/NodePool. רוב סוגי המשאבים תומכים בעד 20 אילוצים מותאמים אישית. אם תנסו ליצור עוד אילוצים בהתאמה אישית, הפעולה תיכשל.
  8. בקטע שיטת אכיפה, בוחרים אם לאכוף את ההגבלה על שיטת REST‏ CREATE או על שיטות CREATE ו-UPDATE. אם אוכפים את האילוץ באמצעות השיטה UPDATE במשאב שמפר את האילוץ, מדיניות הארגון חוסמת שינויים במשאב הזה, אלא אם השינוי פותר את ההפרה.
  9. כדי לראות את השיטות הנתמכות לכל שירות, מחפשים את השירות בקטע שירותים שתומכים באילוצים בהתאמה אישית.

  10. כדי להגדיר תנאי, לוחצים על Edit condition.
    1. בחלונית Add condition, יוצרים תנאי CEL שמתייחס למשאב שירות נתמך, לדוגמה, resource.management.autoUpgrade == false. השדה הזה יכול להכיל עד 1,000 תווים. פרטים על השימוש ב-CEL זמינים במאמר בנושא Common Expression Language. מידע נוסף על משאבי השירות שאפשר להשתמש בהם באילוצים בהתאמה אישית זמין במאמר שירותים שתומכים באילוצים בהתאמה אישית.
    2. לוחצים על Save.
  11. בקטע פעולה, בוחרים אם לאשר או לדחות את השיטה שנבדקה אם התנאי מתקיים.
  12. הפעולה deny (דחייה) פירושה שהפעולה ליצירה או לעדכון של המשאב נחסמת אם התנאי מוערך כ-True.

    הפעולה allow (אישור) אומרת שהפעולה ליצירה או לעדכון של המשאב מותרת רק אם התנאי מחזיר את הערך true. כל מקרה אחר, מלבד אלה שמפורטים במפורש בתנאי, נחסם.

  13. לוחצים על יצירת אילוץ.
  14. אחרי שמזינים ערך בכל שדה, מופיעה משמאל הגדרת ה-YAML המקבילה לאילוץ המותאם אישית הזה.

gcloud

  1. כדי ליצור אילוץ בהתאמה אישית, יוצרים קובץ YAML בפורמט הבא:
  2. name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
    resourceTypes: RESOURCE_NAME
    methodTypes:
      - CREATE
    - UPDATE
    condition: "CONDITION" actionType: ACTION displayName: DISPLAY_NAME description: DESCRIPTION

    מחליפים את מה שכתוב בשדות הבאים:

    • ORGANIZATION_ID: מזהה הארגון, למשל 123456789.
    • CONSTRAINT_NAME: השם שרוצים לתת לאילוץ המותאם אישית החדש. אילוץ מותאם אישית יכול להכיל רק אותיות (כולל אותיות רישיות וקטנות) או מספרים, למשל, custom.enableHealthcareCMEK. השדה הזה יכול להכיל עד 70 תווים, לא כולל הקידומת (custom.) – לדוגמה, organizations/123456789/customConstraints/custom. אל תכללו פרטים אישיים מזהים (PII) או נתונים רגישים במזהה האילוץ, כי הם עלולים להיחשף בהודעות שגיאה.
    • RESOURCE_NAME: השם המלא של המשאב Google Cloudשמכיל את האובייקט והשדה שרוצים להגביל. לדוגמה: healthcare.googleapis.com/Dataset. רוב סוגי המשאבים תומכים בעד 20 אילוצים מותאמים אישית. אם תנסו ליצור עוד אילוצים בהתאמה אישית, הפעולה תיכשל.
    • methodTypes: שיטות ה-REST שבהן האילוץ נאכף. הערך יכול להיות CREATE או גם CREATE וגם UPDATE. אם אוכפים את האילוץ באמצעות השיטה UPDATE על משאב שמפר את האילוץ, שינויים במשאב הזה נחסמים על ידי מדיניות הארגון, אלא אם השינוי פותר את ההפרה.
    • כדי לראות את השיטות הנתמכות לכל שירות, מחפשים את השירות ב שירותים שתומכים באילוצים בהתאמה אישית.

    • CONDITION: תנאי CEL שנכתב על סמך ייצוג של משאב שירות נתמך. השדה הזה יכול להכיל עד 1,000 תווים. לדוגמה: "!has(resource.encryptionSpec)".
    • מידע נוסף על המשאבים שאפשר לכתוב תנאים לגביהם זמין במאמר משאבים נתמכים.

    • ACTION: הפעולה שתתבצע אם התנאי condition יתקיים. הערכים האפשריים הם ALLOW ו-DENY.
    • הפעולה allow (אישור) אומרת שאם התנאי מקבל את הערך True, הפעולה ליצירה או לעדכון של המשאב מותרת. המשמעות היא שכל מקרה אחר, חוץ מהמקרה שמופיע במפורש בתנאי, ייחסם.

      הפעולה deny (דחייה) פירושה שאם התנאי מחזיר את הערך True, הפעולה ליצירה או לעדכון של המשאב נחסמת.

    • DISPLAY_NAME: שם קריא לאנשים של האילוץ. השם הזה מופיע בהודעות שגיאה ויכול לשמש לזיהוי ולניפוי באגים. אל תשתמשו בפרטים אישיים מזהים (PII) או בנתונים רגישים בשמות המוצגים, כי השם הזה עלול להיחשף בהודעות שגיאה. השדה הזה יכול להכיל עד 200 תווים.
    • DESCRIPTION: תיאור ידידותי למשתמש של האילוץ שיוצג כהודעת שגיאה אם המדיניות תופר. השדה הזה יכול להכיל עד 2,000 תווים.
  3. אחרי שיוצרים קובץ YAML לאילוץ חדש בהתאמה אישית, צריך להגדיר אותו כדי שיהיה זמין למדיניות הארגון בארגון שלכם. כדי להגדיר אילוץ בהתאמה אישית, משתמשים בפקודה gcloud org-policies set-custom-constraint:
  4. gcloud org-policies set-custom-constraint CONSTRAINT_PATH

    מחליפים את CONSTRAINT_PATH בנתיב המלא לקובץ האילוצים המותאמים אישית. לדוגמה, /home/user/customconstraint.yaml.

    אחרי שהפעולה הזו תושלם, האילוצים המותאמים אישית יהיו זמינים כמדיניות ארגונית ברשימת Google Cloud מדיניות הארגון.

  5. כדי לוודא שהאילוץ המותאם אישית קיים, משתמשים בפקודה gcloud org-policies list-custom-constraints:
  6. gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID

    מחליפים את ORGANIZATION_ID במזהה של משאב הארגון.

    מידע נוסף זמין במאמר בנושא צפייה במדיניות הארגון.

אכיפה של מדיניות ארגון מותאמת אישית

כדי לאכוף אילוץ, יוצרים מדיניות ארגון שמפנה אליו, ואז מחילים את מדיניות הארגון הזו על משאב Google Cloud .

המסוף

  1. נכנסים לדף Organization policies במסוף Google Cloud .

    מעבר למדיניות הארגון

  2. בתפריט לבחירת פרויקט, בוחרים את הפרויקט שרוצים להגדיר לו את מדיניות הארגון.
  3. מהרשימה בדף מדיניות הארגון, בוחרים את האילוץ כדי לראות את הדף פרטי המדיניות של האילוץ הזה.
  4. כדי להגדיר את מדיניות הארגון עבור המשאב הזה, לוחצים על ניהול מדיניות.
  5. בדף עריכת מדיניות, בוחרים באפשרות במקום המדיניות של המשאב הראשי.
  6. לוחצים על Add a rule.
  7. בקטע Enforcement (אכיפה), בוחרים אם מדיניות הארגון הזו נאכפת או לא.
  8. אופציונלי: כדי להגדיר את מדיניות הארגון כתלויה בתג, לוחצים על הוספת תנאי. הערה: אם מוסיפים כלל מותנה למדיניות ארגון, צריך להוסיף לפחות כלל לא מותנה אחד, אחרת אי אפשר לשמור את המדיניות. מידע נוסף על מדיניות ארגונית עם תגים
  9. לוחצים על בדיקת שינויים כדי לדמות את ההשפעה של מדיניות הארגון. מידע נוסף זמין במאמר בדיקת שינויים במדיניות הארגון באמצעות סימולטור המדיניות.
  10. כדי לאכוף את המדיניות של הארגון במצב הרצת בדיקה, לוחצים על הגדרת מדיניות להרצת בדיקה. מידע נוסף זמין במאמר בנושא בדיקת מדיניות הארגון.
  11. אחרי שמוודאים שמדיניות הארגון במצב הרצה יבשה פועלת כמו שרוצים, לוחצים על הגדרת מדיניות כדי להגדיר את המדיניות הפעילה.

gcloud

  1. כדי ליצור מדיניות ארגונית עם כללים בוליאניים, יוצרים קובץ YAML של מדיניות שמפנה לאילוץ:
  2. name: projects/PROJECT_ID/policies/CONSTRAINT_NAME
    spec:
      rules:
      - enforce: true
    
    dryRunSpec:
      rules:
      - enforce: true

    מחליפים את מה שכתוב בשדות הבאים:

    • PROJECT_ID: הפרויקט שבו רוצים לאכוף את האילוץ.
    • CONSTRAINT_NAME: השם שהגדרתם לאילוץ המותאם אישית. לדוגמה, custom.enableHealthcareCMEK.
  3. כדי לאכוף את מדיניות הארגון במצב הרצה יבשה, מריצים את הפקודה הבאה עם הדגל dryRunSpec:
  4. gcloud org-policies set-policy POLICY_PATH --update-mask=dryRunSpec

    מחליפים את POLICY_PATH בנתיב המלא לקובץ ה-YAML של מדיניות הארגון. יחלפו עד 15 דקות לפני שהמדיניות תיכנס לתוקף.

  5. אחרי שמוודאים שמדיניות הארגון במצב הרצה יבשה פועלת כמו שרוצים, מגדירים את המדיניות הפעילה באמצעות הפקודה org-policies set-policy והדגל spec:
  6. gcloud org-policies set-policy POLICY_PATH --update-mask=spec

    מחליפים את POLICY_PATH בנתיב המלא לקובץ ה-YAML של מדיניות הארגון. יחלפו עד 15 דקות לפני שהמדיניות תיכנס לתוקף.

בדיקה של מדיניות הארגון המותאמת אישית

בדוגמה הבאה נוצרים אילוץ ומדיניות בהתאמה אישית, שמחייבים שכל מערכי הנתונים החדשים בפרויקט מסוים יוצפנו באמצעות מפתח הצפנה בניהול הלקוח (CMEK).

לפני שמתחילים, חשוב לדעת את הפרטים הבאים:

  • מזהה הארגון
  • מזהה פרויקט

יצירת האילוץ

  1. שומרים את הקובץ הבא בשם 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.
    

    ההגדרה הזו מגדירה אילוץ שלפיו לכל מערך נתונים חדש, אם הוא לא מוצפן באמצעות CMEK, הפעולה נדחית.

  2. החלת האילוץ:

    gcloud org-policies set-custom-constraint ~/constraint-enable-healthcare-cmek.yaml
    
  3. מוודאים שהאילוץ קיים:

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

    הפלט אמור להיראות כך:

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

יצירת המדיניות

  1. שומרים את הקובץ הבא בשם policy-enable-healthcare-cmek.yaml:

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

    מחליפים את PROJECT_ID במזהה הפרויקט.

  2. החלת המדיניות:

    gcloud org-policies set-policy ~/policy-enable-healthcare-cmek.yaml
    
  3. מוודאים שהמדיניות קיימת:

    gcloud org-policies list --project=PROJECT_ID
    

    הפלט אמור להיראות כך:

    CONSTRAINT                    LIST_POLICY    BOOLEAN_POLICY    ETAG
    custom.enableHealthcareCMEK   -              SET               COCsm5QGENiXi2E=
    

אחרי שמחילים את המדיניות, צריך להמתין כשתי דקות עד ש-Cloud Healthcare API יתחיל לאכוף את המדיניות.

בדיקת המדיניות

מנסים ליצור מערך נתונים של Cloud Healthcare API בלי לספק מפתח CMEK בפרויקט:

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"

הפלט שיתקבל:

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

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