ניהול משאבים של Integration Connectors באמצעות אילוצים בהתאמה אישית

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

  • connectors.googleapis.com/Connection
  • connectors.googleapis.com/EndpointAttachment
  • connectors.googleapis.com/ManagedZone
  • connectors.googleapis.com/EventSubscription
  • connectors.googleapis.com/RegionalSettings

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

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

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

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

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

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

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

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

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

  3. Install the Google Cloud CLI.

  4. Configure the gcloud CLI to use your federated identity.

    For more information, see Sign in to the gcloud CLI with your federated identity.

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

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

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

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

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

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

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

כדי לנהל את מדיניות הארגון, נדרשות ההרשאות הבאות:

  • orgpolicy.* במשאב הארגון
  • כדי ליצור או לעדכן חיבור של Integration Connectors:
    • ‫connectors.connections.create במשאב הפרויקט
    • ‫connectors.connections.get במשאב הפרויקט
    • ‫connectors.connections.list במשאב הפרויקט
    • ‫connectors.connections.update במשאב הפרויקט

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

המשאבים שנתמכים ב-Integration Connectors

בטבלה הבאה מפורטים המשאבים של Integration Connectors שאפשר להפנות אליהם באילוצים בהתאמה אישית.

משאב שדה
connectors.googleapis.com/Connection resource.asyncOperationsEnabled
resource.authConfig.additionalVariables.boolValue
resource.authConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.authConfig.additionalVariables.encryptionKeyValue.type
resource.authConfig.additionalVariables.intValue
resource.authConfig.additionalVariables.key
resource.authConfig.additionalVariables.secretValue.secretVersion
resource.authConfig.additionalVariables.stringValue
resource.authConfig.authKey
resource.authConfig.authType
resource.authConfig.oauth2AuthCodeFlow.authCode
resource.authConfig.oauth2AuthCodeFlow.authUri
resource.authConfig.oauth2AuthCodeFlow.clientId
resource.authConfig.oauth2AuthCodeFlow.clientSecret.secretVersion
resource.authConfig.oauth2AuthCodeFlow.enablePkce
resource.authConfig.oauth2AuthCodeFlow.pkceVerifier
resource.authConfig.oauth2AuthCodeFlow.redirectUri
resource.authConfig.oauth2AuthCodeFlow.scopes
resource.authConfig.oauth2AuthCodeFlowGoogleManaged.authCode
resource.authConfig.oauth2AuthCodeFlowGoogleManaged.redirectUri
resource.authConfig.oauth2AuthCodeFlowGoogleManaged.scopes
resource.authConfig.oauth2ClientCredentials.clientId
resource.authConfig.oauth2ClientCredentials.clientSecret.secretVersion
resource.authConfig.oauth2JwtBearer.clientKey.secretVersion
resource.authConfig.oauth2JwtBearer.jwtClaims.audience
resource.authConfig.oauth2JwtBearer.jwtClaims.issuer
resource.authConfig.oauth2JwtBearer.jwtClaims.subject
resource.authConfig.sshPublicKey.certType
resource.authConfig.sshPublicKey.sshClientCert.secretVersion
resource.authConfig.sshPublicKey.sshClientCertPass.secretVersion
resource.authConfig.sshPublicKey.username
resource.authConfig.userPassword.password.secretVersion
resource.authConfig.userPassword.username
resource.authOverrideEnabled
resource.configVariables.boolValue
resource.configVariables.encryptionKeyValue.kmsKeyName
resource.configVariables.encryptionKeyValue.type
resource.configVariables.intValue
resource.configVariables.key
resource.configVariables.secretValue.secretVersion
resource.configVariables.stringValue
resource.connectorVersion
resource.description
resource.destinationConfigs.destinations.host
resource.destinationConfigs.destinations.port
resource.destinationConfigs.key
resource.euaOauthAuthConfig.additionalVariables.boolValue
resource.euaOauthAuthConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.euaOauthAuthConfig.additionalVariables.encryptionKeyValue.type
resource.euaOauthAuthConfig.additionalVariables.intValue
resource.euaOauthAuthConfig.additionalVariables.key
resource.euaOauthAuthConfig.additionalVariables.secretValue.secretVersion
resource.euaOauthAuthConfig.additionalVariables.stringValue
resource.euaOauthAuthConfig.authKey
resource.euaOauthAuthConfig.authType
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.authCode
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.authUri
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.clientId
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.clientSecret.secretVersion
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.enablePkce
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.pkceVerifier
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.redirectUri
resource.euaOauthAuthConfig.oauth2AuthCodeFlow.scopes
resource.euaOauthAuthConfig.oauth2AuthCodeFlowGoogleManaged.authCode
resource.euaOauthAuthConfig.oauth2AuthCodeFlowGoogleManaged.redirectUri
resource.euaOauthAuthConfig.oauth2AuthCodeFlowGoogleManaged.scopes
resource.euaOauthAuthConfig.oauth2ClientCredentials.clientId
resource.euaOauthAuthConfig.oauth2ClientCredentials.clientSecret.secretVersion
resource.euaOauthAuthConfig.oauth2JwtBearer.clientKey.secretVersion
resource.euaOauthAuthConfig.oauth2JwtBearer.jwtClaims.audience
resource.euaOauthAuthConfig.oauth2JwtBearer.jwtClaims.issuer
resource.euaOauthAuthConfig.oauth2JwtBearer.jwtClaims.subject
resource.euaOauthAuthConfig.sshPublicKey.certType
resource.euaOauthAuthConfig.sshPublicKey.sshClientCert.secretVersion
resource.euaOauthAuthConfig.sshPublicKey.sshClientCertPass.secretVersion
resource.euaOauthAuthConfig.sshPublicKey.username
resource.euaOauthAuthConfig.userPassword.password.secretVersion
resource.euaOauthAuthConfig.userPassword.username
resource.eventingConfig.additionalVariables.boolValue
resource.eventingConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.eventingConfig.additionalVariables.encryptionKeyValue.type
resource.eventingConfig.additionalVariables.intValue
resource.eventingConfig.additionalVariables.key
resource.eventingConfig.additionalVariables.secretValue.secretVersion
resource.eventingConfig.additionalVariables.stringValue
resource.eventingConfig.allowedEventTypes
resource.eventingConfig.authConfig.additionalVariables.boolValue
resource.eventingConfig.authConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.eventingConfig.authConfig.additionalVariables.encryptionKeyValue.type
resource.eventingConfig.authConfig.additionalVariables.intValue
resource.eventingConfig.authConfig.additionalVariables.key
resource.eventingConfig.authConfig.additionalVariables.secretValue.secretVersion
resource.eventingConfig.authConfig.additionalVariables.stringValue
resource.eventingConfig.authConfig.authKey
resource.eventingConfig.authConfig.authType
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.authCode
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.authUri
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.clientId
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.clientSecret.secretVersion
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.enablePkce
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.pkceVerifier
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.redirectUri
resource.eventingConfig.authConfig.oauth2AuthCodeFlow.scopes
resource.eventingConfig.authConfig.oauth2AuthCodeFlowGoogleManaged.authCode
resource.eventingConfig.authConfig.oauth2AuthCodeFlowGoogleManaged.redirectUri
resource.eventingConfig.authConfig.oauth2AuthCodeFlowGoogleManaged.scopes
resource.eventingConfig.authConfig.oauth2ClientCredentials.clientId
resource.eventingConfig.authConfig.oauth2ClientCredentials.clientSecret.secretVersion
resource.eventingConfig.authConfig.oauth2JwtBearer.clientKey.secretVersion
resource.eventingConfig.authConfig.oauth2JwtBearer.jwtClaims.audience
resource.eventingConfig.authConfig.oauth2JwtBearer.jwtClaims.issuer
resource.eventingConfig.authConfig.oauth2JwtBearer.jwtClaims.subject
resource.eventingConfig.authConfig.sshPublicKey.certType
resource.eventingConfig.authConfig.sshPublicKey.sshClientCert.secretVersion
resource.eventingConfig.authConfig.sshPublicKey.sshClientCertPass.secretVersion
resource.eventingConfig.authConfig.sshPublicKey.username
resource.eventingConfig.authConfig.userPassword.password.secretVersion
resource.eventingConfig.authConfig.userPassword.username
resource.eventingConfig.deadLetterConfig.projectId
resource.eventingConfig.deadLetterConfig.topic
resource.eventingConfig.enrichmentConfig.appendAcl
resource.eventingConfig.enrichmentEnabled
resource.eventingConfig.listenerAuthConfig.additionalVariables.boolValue
resource.eventingConfig.listenerAuthConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.eventingConfig.listenerAuthConfig.additionalVariables.encryptionKeyValue.type
resource.eventingConfig.listenerAuthConfig.additionalVariables.intValue
resource.eventingConfig.listenerAuthConfig.additionalVariables.key
resource.eventingConfig.listenerAuthConfig.additionalVariables.secretValue.secretVersion
resource.eventingConfig.listenerAuthConfig.additionalVariables.stringValue
resource.eventingConfig.listenerAuthConfig.authKey
resource.eventingConfig.listenerAuthConfig.authType
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.authCode
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.authUri
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.clientId
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.clientSecret.secretVersion
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.enablePkce
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.pkceVerifier
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.redirectUri
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlow.scopes
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlowGoogleManaged.authCode
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlowGoogleManaged.redirectUri
resource.eventingConfig.listenerAuthConfig.oauth2AuthCodeFlowGoogleManaged.scopes
resource.eventingConfig.listenerAuthConfig.oauth2ClientCredentials.clientId
resource.eventingConfig.listenerAuthConfig.oauth2ClientCredentials.clientSecret.secretVersion
resource.eventingConfig.listenerAuthConfig.oauth2JwtBearer.clientKey.secretVersion
resource.eventingConfig.listenerAuthConfig.oauth2JwtBearer.jwtClaims.audience
resource.eventingConfig.listenerAuthConfig.oauth2JwtBearer.jwtClaims.issuer
resource.eventingConfig.listenerAuthConfig.oauth2JwtBearer.jwtClaims.subject
resource.eventingConfig.listenerAuthConfig.sshPublicKey.certType
resource.eventingConfig.listenerAuthConfig.sshPublicKey.sshClientCert.secretVersion
resource.eventingConfig.listenerAuthConfig.sshPublicKey.sshClientCertPass.secretVersion
resource.eventingConfig.listenerAuthConfig.sshPublicKey.username
resource.eventingConfig.listenerAuthConfig.userPassword.password.secretVersion
resource.eventingConfig.listenerAuthConfig.userPassword.username
resource.eventingConfig.privateConnectivityAllowlistedProjects
resource.eventingConfig.privateConnectivityEnabled
resource.eventingConfig.proxyDestinationConfig.destinations.host
resource.eventingConfig.proxyDestinationConfig.destinations.port
resource.eventingConfig.proxyDestinationConfig.key
resource.eventingConfig.registrationDestinationConfig.destinations.host
resource.eventingConfig.registrationDestinationConfig.destinations.port
resource.eventingConfig.registrationDestinationConfig.key
resource.eventingConfig.sslConfig.additionalVariables.boolValue
resource.eventingConfig.sslConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.eventingConfig.sslConfig.additionalVariables.encryptionKeyValue.type
resource.eventingConfig.sslConfig.additionalVariables.intValue
resource.eventingConfig.sslConfig.additionalVariables.key
resource.eventingConfig.sslConfig.additionalVariables.secretValue.secretVersion
resource.eventingConfig.sslConfig.additionalVariables.stringValue
resource.eventingConfig.sslConfig.clientCertificate.secretVersion
resource.eventingConfig.sslConfig.clientCertType
resource.eventingConfig.sslConfig.clientPrivateKey.secretVersion
resource.eventingConfig.sslConfig.clientPrivateKeyPass.secretVersion
resource.eventingConfig.sslConfig.privateServerCertificate.secretVersion
resource.eventingConfig.sslConfig.serverCertType
resource.eventingConfig.sslConfig.trustModel
resource.eventingConfig.sslConfig.type
resource.eventingConfig.sslConfig.useSsl
resource.eventingEnablementType
resource.fallbackOnAdminCredentials
resource.lockConfig.locked
resource.lockConfig.reason
resource.logConfig.enabled
resource.logConfig.level
resource.nodeConfig.maxNodeCount
resource.nodeConfig.minNodeCount
resource.serviceAccount
resource.sslConfig.additionalVariables.boolValue
resource.sslConfig.additionalVariables.encryptionKeyValue.kmsKeyName
resource.sslConfig.additionalVariables.encryptionKeyValue.type
resource.sslConfig.additionalVariables.intValue
resource.sslConfig.additionalVariables.key
resource.sslConfig.additionalVariables.secretValue.secretVersion
resource.sslConfig.additionalVariables.stringValue
resource.sslConfig.clientCertificate.secretVersion
resource.sslConfig.clientCertType
resource.sslConfig.clientPrivateKey.secretVersion
resource.sslConfig.clientPrivateKeyPass.secretVersion
resource.sslConfig.privateServerCertificate.secretVersion
resource.sslConfig.serverCertType
resource.sslConfig.trustModel
resource.sslConfig.type
resource.sslConfig.useSsl
resource.suspended
resource.trafficShapingConfigs.duration
resource.trafficShapingConfigs.quotaLimit
connectors.googleapis.com/EndpointAttachment resource.description
resource.endpointGlobalAccess
resource.serviceAttachment
connectors.googleapis.com/EventSubscription resource.destinations.endpoint.endpointUri
resource.destinations.endpoint.headers.key
resource.destinations.endpoint.headers.value
resource.destinations.pubsub.attributes
resource.destinations.pubsub.configVariables.boolValue
resource.destinations.pubsub.configVariables.encryptionKeyValue.kmsKeyName
resource.destinations.pubsub.configVariables.encryptionKeyValue.type
resource.destinations.pubsub.configVariables.intValue
resource.destinations.pubsub.configVariables.key
resource.destinations.pubsub.configVariables.secretValue.secretVersion
resource.destinations.pubsub.configVariables.stringValue
resource.destinations.pubsub.projectId
resource.destinations.pubsub.topicId
resource.destinations.serviceAccount
resource.destinations.type
resource.eventTypeId
resource.filter
resource.jms.name
resource.jms.type
resource.name
resource.subscriber
resource.subscriberLink
resource.triggerConfigVariables.boolValue
resource.triggerConfigVariables.encryptionKeyValue.kmsKeyName
resource.triggerConfigVariables.encryptionKeyValue.type
resource.triggerConfigVariables.intValue
resource.triggerConfigVariables.key
resource.triggerConfigVariables.secretValue.secretVersion
resource.triggerConfigVariables.stringValue
connectors.googleapis.com/ManagedZone resource.description
resource.dns
resource.targetProject
resource.targetVpc
connectors.googleapis.com/RegionalSettings resource.encryptionConfig.encryptionType
resource.encryptionConfig.kmsKeyName
resource.networkConfig.egressMode

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

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

המסוף

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

  1. במסוף Google Cloud , נכנסים לדף מדיניות הארגון.

    כניסה לדף Organization policies

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

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

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

  13. לוחצים על Create constraint.
  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.allowedConnectionLocations. השדה הזה יכול להכיל עד 70 תווים, לא כולל הקידומת (custom.) – לדוגמה, organizations/123456789/customConstraints/custom. אל תכללו פרטים אישיים מזהים או מידע רגיש במזהה האילוץ, כי הם עלולים להיחשף בהודעות שגיאה.
    • ‫RESOURCE_NAME: השם המלא של המשאב ב- Google Cloudשמכיל את האובייקט והשדה שרוצים להגביל. לדוגמה, connectors.googleapis.com/Connection. רוב סוגי המשאבים תומכים בעד 20 אילוצים בהתאמה אישית. אם תנסו ליצור יותר אילוצים בהתאמה אישית, הפעולה תיכשל.
    • ‫methodTypes: השיטות של REST שעליהן נאכף האילוץ. יכול להיות CREATE או גם CREATE וגם UPDATE. אם אוכפים את האילוץ באמצעות השיטה UPDATE במשאב שמפר את האילוץ, השינויים במשאב הזה נחסמים על ידי מדיניות הארגון, אלא אם השינוי פותר את ההפרה.
    • כדי לראות את השיטות הנתמכות לכל שירות, חפשו את השירות במאמר שירותים שתומכים באילוצים בהתאמה אישית.

    • ‫CONDITION: תנאי CEL שנכתב כנגד ייצוג של משאב שירות נתמך. השדה הזה יכול להכיל עד 1,000 תווים. לדוגמה, "!(resource.location == 'us-central1' || resource.location == 'europe-west1')".
    • למידע נוסף על המשאבים הזמינים לכתיבת תנאים, ראו משאבים נתמכים.

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

      פעולת הדחייה פירושה שאם התנאי מקבל את הערך 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. במסוף Google Cloud , נכנסים לדף מדיניות הארגון.

    כניסה לדף Organization policies

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

gcloud

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

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

    • ‫PROJECT_ID: הפרויקט שבו רוצים לאכוף את האילוץ.
    • ‫CONSTRAINT_NAME: השם שהגדרתם לאילוץ המותאם אישית. לדוגמה, custom.allowedConnectionLocations.
  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 דקות לכל היותר.

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

בדוגמה הבאה נוצר אילוץ מותאם אישית ומדיניות שמגבילה את היצירה של חיבורים חדשים של Integration Connectors בפרויקט ספציפי, כך שיוכלו להיווצר רק ב-us-central1 או ב-europe-west1.

לפני שמתחילים, צריך לוודא שיש לכם:

  • מזהה הארגון שלכם
  • מזהה פרויקט

יצירת האילוץ

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

  1. יוצרים את קובץ ה-YAML הבא ושומרים אותו בשם constraint-allowed-locations.yaml:

    name: organizations/ORGANIZATION_ID/customConstraints/custom.allowedConnectionLocations
    resourceTypes:
    - connectors.googleapis.com/Connection
    methodTypes:
    - CREATE
    condition: "!(resource.location == 'us-central1' || resource.location == 'europe-west1')"
    actionType: DENY
    displayName: Restrict connection locations
    description: Connections can only be created in us-central1 or europe-west1.
    

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

    כך מגדירים אילוץ שבו בכל חיבור חדש, אם המיקום הוא לא us-central1 או europe-west1, הפעולה נדחית.

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

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

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

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

    CUSTOM_CONSTRAINT                       ACTION_TYPE  METHOD_TYPES   RESOURCE_TYPES                     DISPLAY_NAME
    custom.allowedConnectionLocations       DENY         CREATE         connectors.googleapis.com/Connection    Restrict connection locations
    ...
    

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

עכשיו יוצרים מדיניות ומחילים אותה על האילוץ המותאם אישית שיצרתם.

  1. שומרים את הקובץ הבא בשם policy-allowed-locations.yaml:

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

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

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

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

    gcloud org-policies list --project=PROJECT_ID
    

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

    CONSTRAINT                         LIST_POLICY    BOOLEAN_POLICY    ETAG
    custom.allowedConnectionLocations  -              SET               COCsm5QGENiXi2E=
    

אחרי שמחילים את המדיניות, ממתינים כשתי דקות עד ש- Google Cloud יתחיל לאכוף את המדיניות.

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

ניסיון ליצור חיבור של Integration Connectors במיקום אסור כמו us-east1. אפשר לעשות את זה באמצעות מסוף Google Cloud , ‏Google Cloud CLI או ה-API בארכיטקטורת REST. לדוגמה, אם משתמשים ב-CLI של gcloud, יוצרים חיבור ב-us-east1:

gcloud connectors connections create test-connection --location=us-east1 --connector-version=<var>CONNECTOR_VERSION</var> ...

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

הפלט שיתקבל:

Operation denied by custom org policies: ["customConstraints/custom.allowedConnectionLocations": "Connections can only be created in us-central1 or europe-west1."]

דוגמאות למדיניות ארגונית בהתאמה אישית לתרחישים נפוצים

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

תיאור תחביר של אילוצים
הגבלת מיקומי החיבור אל us-central1 או europe-west1
    name: organizations/ORGANIZATION_ID/customConstraints/custom.allowedConnectionLocations
    resourceTypes:
    - connectors.googleapis.com/Connection
    methodTypes:
    - CREATE
    condition: "!(resource.location == 'us-central1' || resource.location == 'europe-west1')"
    actionType: DENY
    displayName: Restrict connection locations
    description: Connections can only be created in us-central1 or europe-west1.
    

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