This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

GCP

Protegrity products for GCP.

1 - Cloud API

Protector with a REST API on GCP.

This section describes the high-level architecture of Protegrity Cloud API, installation procedures, and performance guidance. This section focuses on Protegrity specific aspects and should be consumed in conjunction with the corresponding GCP documentation.

This guide may also be used with the Protegrity Enterprise Security Administrator Guide, which explains the mechanism for managing the data security policy.

1.1 - Overview

Solution overview and features.

    Solution Overview

    Cloud API Protector on GCP is a cloud-native, serverless product for fine-grained data protection. This enables the invocation of Protegrity data protection cryptographic methods in cloud-native serverless technology. The benefits of serverless include rapid auto-scaling, performance, low administrative overhead, and reduced infrastructure costs compared to a server-based solution.

    This product provides a data protection API end-point for clients. The product is designed to scale elastically and yield reliable query performance under extremely high concurrent loads. During idle use, the serverless product will scale completely down, providing significant savings in Cloud compute fees.

    Protegrity utilizes a data security policy maintained by an Enterprise Security Administrator (ESA), similar to other Protegrity products. Using a simple REST API interface, authorized users can perform both de-identification (protect) and re-identification (unprotect) operations on data. A user’s individual capabilities are subject to privileges and policies defined by the Enterprise Security Administrator.

    Analytics on Protected Data

    Protegrity’s format and length preserving tokenization scheme make it possible to perform analytics directly on protected data. Tokens are join-preserving so protected data can be joined across datasets. Often statistical analytics and machine learning training can be performed without the need to re-identify protected data. However, a user or service account with authorized security policy privileges may re-identify subsets of data using the Cloud API Protector on GCP service.

    Features

    Cloud API Protector on GCP incorporates Protegrity’s patent-pending vaultless tokenization capabilities into cloud-native serverless technology. Combined with an ESA security policy, the protector provides the following features:

    • Role-based access control (RBAC) to protect and unprotect (re-identify) data depending on the user privileges.
    • Policy enforcement features of other Protegrity application protectors.

    For more information about the available protection options, such as, data types, Tokenization or Encryption types, or length preserving and non-preserving tokens, refer to Protection Methods Reference.

    1.2 - Architecture

    Deployment architecture and connectivity

      Deployment Architecture

      The Protegrity product should be deployed in the customer’s Cloud account. The product incorporates Protegrity’s vaultless tokenization engine within Google Cloud Functions. The encrypted data security policy from an ESA is deployed periodically as a static resource together with Cloud Function binaries. The policy is decrypted in memory at runtime within the Cloud Function. This architecture allows Protegrity to be highly available and scale very quickly without direct dependency on any other Protegrity services.

      The product exposes a remote data protection service. Each network REST request includes a micro-batch of data to process and parameters such as operation and data element. The product applies the ESA security policy including user authorization and returns a corresponding response. Security operations on sensitive data performed by protector can be audited. The product can be configured to send audit logs to ESA via optional component called Log Forwarder.

      The security policy is synchronized through another serverless component called the Protegrity Policy Agent. The agent operates on a configurable schedule, fetches the policy from the ESA, performs envelope encryption using Google Key Management Service, and deploys new version of Cloud Function with updated policy. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. There is no downtime for users during this process. Instances provisioned with the function’s previous policy version may continue running (and processing traffic) for several minutes after a deployment has finished.

      The following diagram illustrates the high-level architecture.

      The following diagram illustrates a reference architecture for synchronizing the security policy from the ESA to the product.

      The Protegrity Policy Agent requires network access from GCP to your ESA. Most organizations install the ESA on-premise. Thus, it is recommended to install the Policy Agent in a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

      The ESA is a soft appliance that must be installed on a separate server. It is used to create and manage security policies.

      For more information about installing the ESA, and creating and managing policies, refer to the Policy Management Guide.

      Audit Log Forwarding Architecture

      Audit logs are by default sent to Cloud Logging. The Protegrity Product can also be configured to send audit logs to ESA. Such configuration requires deploying Log Forwarder component which is available as part of Protegrity Product deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

      The log forwarder component includes Pub/Sub service topic and the audit log forwarder function. Pub/Sub service is used to asynchronously send audit records to forwarder function, where similar audit logs are aggregated before sending to ESA. Aggregation rules are described in the Protegrity Log Forwarding guide. When the protector function is configured to send audit logs to log forwarder, audit logs are aggregated on the protector function before sending to Pub/Sub topic. Protector function exposes configuration to control the time it spends aggregating audit logs which is described in the protector function installation section.

      The security of audit logs is ensured by using HTTPS connection on each link of the communication between protector function and ESA. Integrity and authenticity of audit logs is additionally checked on log forwarder which verifies individual logs signature. The signature verification is done upon arrival from Pub/Sub topic before applying aggregation. If signature cannot be verified, the log is forwarded as is to ESA where additional signature verification can be configured. Log forwarder function uses basic auth and optional certificate verification to authenticate calls to ESA. Basic auth credentials are stored securely in Secret Manager Service.

      To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instruction can be found in the Audit Log Forwarder installation.

      The audit log forwarding requires network access from the cloud to the ESA. Most organizations install the ESA on-premise. Therefore, it is recommended that the Log Forwarder Function is installed into a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

      Access Control

      The Cloud API utilizes access controls provided by the Google Cloud Functions service. The following mechanisms are available for controlling and restricting access to the Cloud API data protection endpoint:

      • Google Cloud Identity and Access Management (IAM) access control.
      • Google Cloud Network-based access control.
      • OpenID Connect. OpenID is a simple identity layer on top of the OAuth 2.0 protocol. Authorization is performed in the Protegrity Cloud Function code.

      For more information on Google Cloud Functions security concepts, refer to Securing Cloud Functions

      REST API Authentication and Authorization

      The Rest API supports built-in authentication and authorization provided by Google Cloud Functions. More information is available in the following Google Cloud Functions documentation.

      https://cloud.google.com/functions/docs/securing/authenticating

      REST API Policy Authorization

      Once the request is authenticated and authorized by the Cloud Function, the Protegrity Cloud API performs the requested security operation based on the policy data element from the payload and the authenticated user.

      1.3 - Installation

      Product Installation Guide.

      1.3.1 - Prerequisites

      Requirements before installing the protector.

        Google Cloud Services

        The following table describes the Google Cloud services that may a part of your Protegrity installation.

        ServiceDescription
        Cloud Run FunctionsProvides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates.
        API GatewayProvides the end-point and access control (Required for Snowflake only).
        Key Management ServiceProvides cryptographic keys for envelope encryption/decryption of the policy.
        Secret Manager ServiceStores secrets required during deployment, e.g., ESA credentials.
        Cloud Storage ServiceStorage location for the encrypted ESA policy package.
        Identity and Access ManagementEnforces access policies for deployed resources.
        Cloud Logging ServiceApplication and audit logs, performance monitoring, and alerts.
        Cloud VPCRequired for securing network access to On-Prem or cloud-based ESA.
        Pub/SubProvides a messaging service when forwarding audit logs to ESA is enabled.

        ESA Version Requirements

        The Protector and Log Forwarder functions require a security policy from a compatible ESA version.

        The table below shows compatibility between different Protector and ESA versions.

        Protector VersionESA Version
        8.x9.09.1 & 9.210.0
        2.xNoYes*No
        3.0.x & 3.1.xNoNoYesNo
        3.2.xNoNoYes*
        4.0.xNoNoNoYes

        Legend

        Yes

        Protector was designed to work with this ESA version

        No

        Protector will not work with this ESA version

        *

        Backward compatible policy download supported:

        • Data elements and features which are common between this and previous ESA versions will be downloaded
        • Data elements and features which are new to this ESA version and do not exist in previous ESA version will not be downloaded

        Prerequisites

        RequirementDetail
        Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
        Protegrity ESA 10.0+The Cloud VNet must be able to obtain network access to the ESA
        Google Cloud AccountRecommend creating a new project for Protegrity Serverless
        Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

        Required Skills and Abilities

        RequirementsDescription
        GCP Cloud AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
        Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
        Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

        1.3.2 - Pre-Configuration

        Configuration steps prior product installation.

          Google Cloud Project

          Identify or create a new Google Cloud Project where the Protegrity solution will be installed. It is recommended to create a new project. This provides greater security controls and avoids conflicts with other applications that might impact regional account limits. An individual with the Owner role will be required for some of the subsequent installations.

          Google Project ID: ___________________

          Google Project Number: ___________________

          Google Cloud Region: ___________________

          Key Management Service

          The Google Cloud Key Management Service (KMS) provides Protegrity Serverless solution the ability to encrypt and decrypt the Protegrity Security Policy.

          To create KMS Key Ring and Asymmetric Encryption Master Key:

          1. Log in to Google Account and select project where Protegrity service will be installed.

          2. Navigate to Security > Key Management.

          3. Select Create key ring.

          4. Specify key ring name. For example, protegrity-policy-keyring.

          5. select Key ring location which corresponds to the region where Protegrity solution will be installed.

          6. Select Create.

          7. Select CREATE KEY to create encryption key.

          8. Specify key name. For example, protegrity-policy-key.

          9. under Purpose selection, select Asymmetric Decrypt .

          10. Select Key Algorithm. For example, 3072-bit RSA with OAEP Padding and SHA256 digest.

          11. Select Create.

          12. Once the key is created, a screen opens on the key. If the screen does not appear, click on the key name.

          13. Then click on the elipses under Actions that is next to the key version.

          14. Select Copy Resource Name and record the value below, e.g., projects/{project-id}/locations/region/keyRings/{key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

            Policy Encryption Key Version Resource Name: ___________________

          Google Cloud Storage

          Cloud Storage buckets are required for the Gen 2 Cloud Function sources, the Terraform backend, and the deployment of the Protegrity installation artifacts. It is recommended that you create 3 separate buckets to separate files used for different purposes. If you cannot create 3 separate buckets, you may reuse a bucket for multiple purposes.

          Create the buckets:

          1. Run the cloud command below to enable the Google Storage Transfer API.

            gcloud services enable storagetransfer.googleapis.com
            
          2. Create the Gen 2 Cloud Function sources bucket. This bucket is not required if you will be deploying to Gen 1 Cloud Functions. The bucket name much match the example below. Replace the <gcp-project-number> and <region> placeholders.

            gcf-v2-sources-<gcp-project-number>-<region>
            

            Use the following gcloud command to obtain project number

            gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
            
          3. Create the deployment bucket or reuse an existing bucket. This bucket is used during the installation process to store the Protegrity installation artifacts.

            Deployment Bucket Name:___________________

          4. Create the Terraform backend bucket or reuse an existing bucket. This bucket is used by Terraform to store information about your Cloud Protect installation, and will be used if you upgrade to a later version of Cloud Protect in the future.

            Terraform Backend Bucket Name:___________________

          Cloud Functions Service Accounts

          Cloud Functions use the service accounts created in this deployment. You can create Service accounts manually or use the Protegrity Terraform installation script to create one. Each service account requires specific permissions, which must be granted through IAM roles. Run the following steps to create service accounts and configure the required IAM access. If you use Terraform scripts, skip these steps.

          Agent Function IAM Role

          To create Agent Function IAM Role:

          1. Log in to Google Account and select project where Protegrity service will be installed.

          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

          3. Specify role name and description.

          4. Select ADD PERMISSIONS.

          5. Select the following permissions:

            • cloudkms.cryptoKeyVersions.useToEncrypt
            • cloudkms.cryptoKeyVersions.viewPublicKey
            • secretmanager.versions.access
            • storage.objects.get
            • storage.objects.create
            • storage.objects.delete
            • storage.objects.list
            • storage.objects.update
            • storage.buckets.get
            • cloudfunctions.functions.get
            • cloudfunctions.functions.update
            • cloudfunctions.functions.sourceCodeGet
            • cloudfunctions.functions.sourceCodeSet
            • iam.serviceAccounts.actAs
          6. Click Add and then Create.

          Alternatively, you can run the following command from the Cloud Shell Terminal.

                gcloud iam roles create role-id \
                --project=project-id \
                --title=role-title \
                --description=role-description \
                --permissions=cloudkms.cryptoKeyVersions.useToEncrypt,\
                cloudkms.cryptoKeyVersions.viewPublicKey,\
                secretmanager.versions.access,\
                storage.objects.get,\
                storage.objects.create,\
                storage.objects.delete,\
                storage.objects.list,\
                storage.objects.update,\
                storage.buckets.get,\
                cloudfunctions.functions.get,\
                cloudfunctions.functions.update,\
                cloudfunctions.functions.sourceCodeGet,\
                cloudfunctions.functions.sourceCodeSet,\
                iam.serviceAccounts.actAs \
                --stage=GA 
                
          
          • role-id

            is the name of the role, such as ptyProtectRole.

          • project-id

            is the name of the project, such as my-project-id.

          • role-description

            is a short description of the role, such as “My custom role description”.

          Sample output:

          
                Created role [role-id]. 
                description: role-description 
                etag: *****************
                includedPermissions: 
                - cloudfunctions.functions.get 
                - cloudfunctions.functions.sourceCodeGet 
                - cloudfunctions.functions.sourceCodeSet 
                - cloudfunctions.functions.update 
                - cloudkms.cryptoKeyVersions.useToEncrypt 
                - cloudkms.cryptoKeyVersions.viewPublicKey 
                - iam.serviceAccounts.actAs 
                - secretmanager.versions.access 
                - storage.buckets.get 
                - storage.objects.create 
                - storage.objects.delete 
                - storage.objects.get 
                - storage.objects.list 
                - storage.objects.update 
                name: projects/{project-id}/roles/{role-id} 
                stage: GA 
                title: role-title
                
          

          Agent Service Account

          To create Agent Service Account:

          1. Log in to Google Account and select project where Protegrity service will be installed.

          2. Navigate to IAM & Admin > Service Accounts.

          3. Select CREATE SERVICE ACCOUNT.

          4. Specify service account name and description.

          5. Select Create and Continue.

          6. In the next step, click Select Role.

          7. Select Custom and select the role created above .

          8. Click Done.

          9. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

          10. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com

            Agent Function Service Account Email: ___________________

          Protect Function IAM role

          To create Protect Function IAM role:

          1. Log in to Google Account and select project where Protegrity service will be installed.

          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

          3. Specify role name and description.

          4. Select ADD PERMISSIONS.

          5. Select the cloudkms.cryptoKeyVersions.useToDecrypt permission.

          6. Click Add and then Create.

          Protect Service Account

          To create Protect Service Account:

          1. Log in to Google Account and select the project where Protegrity service will be installed.

          2. Navigate to IAM & Admin > Service Accounts.

          3. Select CREATE SERVICE ACCOUNT.

          4. Specify service account name and description.

          5. Select Create and Continue.

          6. In the next step, click Select Role. Then select Custom and select the role created above .

          7. Click Done.

          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

            Protect Function Service Account Email: ___________________

          1.3.3 - Protect Service Installation

          Product Installation Guide.

            Preparation

            1. Ensure that all the steps in pre-configuration are performed.

            2. Log in to the Google Cloud account where Protegrity will be installed.

            3. Select the project.

            4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

            5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

            Install Protect Function via Terraform Scripts

            Resources created with Terraform scripts include Protect Cloud Functions Service and other required resources depending on Terraform parameters. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

            To install using Terraform:

            1. From the command shell move to directory where you downloaded Protegrity installation bundle.

            2. Unzip the bundle. Verify that the following files are available:

              • pty-protect-gcp/
              • main.tf
              • outputs.tf
              • protegrity-cloud-api-gcp-{version}.zip
              • README.md
            3. Unzip the protegrity-cloud-protect-gcp-{version}.zip file. Verify that the following files are available:

              • pty-protect-gcp/
              • main.tf
              • outputs.tf
              • protegrity-cloud-protect-gcp-{version}.zip
              • README.md
            4. Open the main.tf file and update Terraform backend information at the top of the file:

              
              terraform {
                backend "gcs" {
                  bucket  = ""
                  prefix  = "protegrity/terraform/pty-protect-gcp/state"
                }
              }
              
            5. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

            Parameter

            Description

            project_id

            The project id recorded in the pre-configuration step

            region

            The Region recorded in the pre-configuration step.

            deployment_id

            Specify short name to identify deployment. This id will be added to all resources deployed with Terraform.

            deployment_bucket

            Use Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.

            create_service_account

            Leave this as false if you created service account in pre-configuration. Otherwise set to true.

            protect_function_service_account_email

            Use Protect Function Service account recorded in pre-configuration or leave empty.

            username_regex

            If username_regex is set, the effective policy user will be extracted from the user in the request.

            max_instance_count

            GCP Cloud Functions advanced configuration

            available_memory_mb

            GCP Cloud Functions advanced configuration

            timeout_seconds

            GCP Cloud Functions advanced configuration

            gen2_available_cpu

            2nd Gen Cloud Function advanced configuration

            gen2_container_concurrency

            2nd Gen Cloud Function advanced configuration

            upgrade_step

            Set this variable when upgrading to the latest version.

            deploy_api_gateway

            Deploys GCP API Gateway proxy for Protect Cloud Function service.

            api_gateway_jwt_issuer

            Applicable when deploy_api_gateway = true. Allows setting issuer of JSON Web Token credential used to authenticate calls to API Gateway. Accepts email or URI.

            api_gateway_jwks_uri

            Applicable when deploy_api_gateway = true. Allows setting URI of the authentication provider’s public key set to validate the signature of the JSON Web Token.

            labels

            You can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

            openid_enabled

            When set to true, every request is required to have an Authorization header with the bearer token set to a valid OAuth access token. The following configuration attributes will also be required: OPENID_AUDIENCES, OPENID_ISSUERS, OPENID_METADATA_URL.

            openid_audiences

            Applicable when OPENID_ENABLED= “true”. The JWT token must have the “aud” claim and it must match one of the values in this attribute. Can be either one value or comma separated list.

            openid_issuers

            Applicable when OPENID_ENABLED= “true”. The JWT token must have the “iss” claim and it must match one of the values in this attribute. Can be either one value or comma separated list.

            openid_metadata_url

            Applicable when OPENID_ENABLED= “true”. A URL that points to an OpenID Connect identity provider configuration document, which is also known as OpenID well-known configuration endpoint.

            openid_appid

            Applicable when OPENID_ENABLED= “true”. Validates the provided open_appid is listed in the appid claim. If value is empty, appid claim is ignored.

            Supported Values: ["<appid>", “”]

            authorization

            When equals “jwt”, Authorization Header JWT will be required in the Rest API Protect payload.

            Supported Values: [“jwt”, “”].

            When set to “jwt”, any request without Valid JWT in the Authorization header will result in an error from API Gateway: 502 Bad Gateway.

            *Applies for all configurations of jwt_verify and openid_enabled.

            allow_assume_user

            Applicable when authorization = “jwt”. If set to 0, The user from the payload will not be used, and the policy user is the JWT user.

            Supported Values: [0, 1]. Default Value: 0.

            *Applies for all configurations of jwt_verify and openid_enabled.

            jwt_user_claim

            Applicable when authorization = “jwt”. The JWT payload claim with username. Common claims: name, preferred_username, cognito:username. Default Value: cognito:username.

            *Applies for all configurations of jwt_verify and openid_enabled.

            service_user

            If service_user is set the protect request will use it for the policy user. service_user should be used when the Cloud API should always run as one service_user no matter what user is in the request. service_user will always take priority over any other user in the payload or in the JWT header.

            *Applies for all configurations of jwt_verify and openid_enabled.

            pty_gcp_jwt_header

            When set to true, both Google Cloud access control and Protegrity openid will be supported in two separate headers. This is useful when having access control with GCP IAM (In Authorization header) and the OPENID verification and policy user from JWT in the X-PTY-Authorization header.

            jwt_verify

            When set to 1, jwt_secret_base64 is required. Only applicable when authorization is jwt. Supported JWT Algorithm RS256, RS384, RS512. (HS256, HS384, HS512 are supported but not recommended for use).

            Only applicable when authorization = “jwt”

            Supported Values: [1, “”]

            *Applies for all configurations of openid_enabled.

            jwt_secret_base64

            Required when jwt_verify = 1 and Authorization = JWT. The secret must be provided in base64 encoding. It is recommended to only use public key (asymmetric algorithm).

            applicable when authorization = “jwt” and jwt_verify=1

            Supported Values: [<base64 encoded secret key>, “”]

            min_log_level

            Minimum log level for log forwarder function. One of off|severe|warning|info|config|all. Defaults to ‘severe’

            pty_log_output

            Audit log output. Accepted values: “”(empty string), “pub_sub”.

            audit_log_flush_interval

            Time interval in seconds used to accumulate audit logs before sending to Pub/Sub topic. Default value: 30
                            Min value: 1
                            Max value: 900
                            

            pty_pub_sub_topic

            Pub/Sub topic where audit logs will be sent.

            6. Run the following command.
            ```
            terraform init
            ```
            
            1. Terraform will download necessary providers.

            2. Run the following command to verify configuration and print out deployment plan.

              terraform plan
              
            3. Run the following command to deploy resources to your account.

              terraform apply
              
            4. Once deployment is complete Terraform will print output variables.

            5. Record the following values:

              • protect_function_name: ________________________________
              • protect_function_url: __________________________
              • api_gateway_managed_service: _____________________________
              • api_gateway_protect_service_url: ____________________
              • protect_function_resource_name: _______________________

            Deploy API Gateway (Optional)

            Terraform module provided by Protegrity allows deploying Google API Gateway proxy for the Cloud Protect Service.

            To deploy API Gateway:

            1. In the main.tf file set the following Terraform variables.

              deploy_api_gateway = true
              api_gateway_jwt_issuer = "<service-account>@<google-cloud-project-id>.iam.gserviceaccount.com"
              api_gateway_jwks_uri = "https://www.googleapis.com/robot/v1/metadata/x509/<service-account>@<google-cloud-project-id>.iam.gserviceaccount.com"
              

              Below is the brief description of each Terraform variable. You can find more information in the Terraform README file.

            2. Run terraform plan.

            3. Run terraform apply.

            4. Wait for the Terraform apply command to complete.

            5. Once Terraform apply completes, it prints out deployment resources information. Record the following information from the Terraform output.

              api_gateway_managed_service: ___________________

              api_gateway_protect_service_url: ___________________

            6. Follow instructions in the link below to generate JWT token which you can use to authorize request to Protegrity API Gateway endpoint. Use the same service account you configured in section above for api_gateway_jwks_uri.

              https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#create-jwt

              Record identity token returned in step above:

              gcloud_auth_token: ___________________

            7. Run the following CURL command to test API Gateway deployment.

              curl -X POST "{api_gateway_protect_service_url}/api/v1/unprotect" \
                      -H 'Authorization:Bearer {gcloud_auth_token}' \
                      -d '{ 
                        "user": "test",
                        "data_element":"alpha",
                        "data": ["UtfVk UHgcD!"] 
                      }'
              
            8. Verify the following output:

              {"encoding":"utf8","results":["hello world!"],"success":true}
              

            Test the Protect Function Installation

            Before continuing with next steps, you can verify whether Cloud Functions are installed correctly. This step is optional and can be skipped.

            1. Below you can find example CURL command to test your function.

            2. Before you can execute it, you need to obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the cloudfunctions.functions.invoke permission. Record the output of print identity token command.

              gcloud_auth_token: _________________

            3. Replace {protect_function_url}; with value recorded in previous step.

            4. Replace {gcloud_auth_token} with value recorded in above step.

            5. Run the following CURL command to test Function deployment.

              curl -X POST "{protect_function_url}/pty/v1/unprotect" \
                      -H 'Authorization:Bearer {gcloud_auth_token}' \
                      -d '{ 
                        "user": "test",
                        "data_element":"alpha",
                        "data": ["UtfVk UHgcD!"] 
                      }'
              
            6. Verify the following output:

              {"encoding":"utf8","results":["hello world!"],"success":true}
              

            1.3.4 - Policy Agent Installation

            Install the policy agent.

              Policy Agent Function installation is done via Terraform scripts provided by Protegrity. Before running the template, some resources must be created manually.

              ESA Server

              Policy Agent function requires ESA server running and accessible from Agent Cloud Function on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted.

              Note down ESA IP address:

              ESA IP Address (EsaIpAddress): ___________________

              Certificates on ESA

              By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Cloud Function Environment variables configuration.

              In case ESA is configured with publicly signed certificates, this section can be skipped since the Cloud Function will use public CA to validate ESA certificates.

              To obtain self-signed CA certificate from ESA:

              1. Log in to ESA Web UI.

              2. Select Settings > Network > Manage Certificates.

              3. Hover over Server Certificate and click on download icon to download the CA certificate.

              4. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                To escape new lines from command line, use one of the following commands depending on your operating system:

                Linux Bash:

                awk 'NF {printf "%s\\n",$0;}' ProtegrityCA.pem > output.txt
                

                Windows PowerShell:

                (Get-Content '.\ProtegrityCA.pem') -join '\n' | Set-Content 'output.txt'
                
              5. Record the certificate content with new lines escaped.

                ESA CA Server Certificate (EsaCaCert): ___________________

                This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section.

              For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

              Identify or Create a new VPC

              Google Cloud VPC is used to route traffic from Policy Agent Cloud Function to ESA. If your ESA is in a Google Cloud VPC, it is recommended to create a serverless VPC access and record its name:

              google_vpc_access_connector_name: ___________________

              If ESA is not on Google Cloud VPC, you can either create one or choose to let Terraform script to create one. The Terraform script will create the following elements:

              • NAT gateway

                To connect to ESA outside the Google Cloud Network

              • External IP address

                Can add it to the allowlist by the firewall in the network environment where ESA is hosted.

              • Serverless VPC access

                Allows connectivity from the Cloud function to the VPC.

              Creating ESA Credentials

              Policy Agent Function requires ESA credentials to be provided as one of the two options:

              Secret Manager

              Secret Manager is the recommended option for storing ESA credentials.

              Create ESA credentials secrets:

              1. Log in to Google Account and select project where Protegrity service will be installed.

              2. Go to Security > Secret Manager.

              3. Select CREATE SECRET.

              4. Specify the Secret Value:

                {
                  "username": "{esa_username}", 
                  "password": "{esa_password}"
                }
                
              5. Select Create Secret.

              6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

              7. Click on Actions, next to the secret version you just created.

              8. Select Copy Resource ID and record the full secret version path, For example, projects/{project-id}/secrets/{secret name}/versions/2.

                Secret resource id: ___________________

              Custom Cloud Function

              If you have the skills to write code, you may provide a custom Cloud Function that returns the ESA credentials to the Policy Agent. One use case is when reading the ESA credentials from a third-party password vault.

              Create the Cloud Function:

              1. Create a new 2nd gen Cloud Function using any runtime.

                1. The Policy Agent does not provide an input payload.

                2. The Cloud Function must return a response according to the following schema:

                  response: 
                    type: object 
                      properties: 
                        username: string 
                        password: string
                  

                  For example,

                  example output: {"username": "admin", "password": "Password1234"} 
                  
                3. Sample GCP Function in Python:

                  def handler(request): 
                      return {"username": "admin", "password": "password1234"} 
                  
              2. Grant the Cloud Run Invoker role to the Policy Agent function service account.

              3. Grant the cloudfunctions.functions.get permission to the Policy Agent function service account role.

              4. Record the Function name:

                ESA CREDENTIALS FUNCTION NAME: _______________

              Install Policy Agent Function through Terraform Scripts

              Agent Terraform scripts provided by Protegrity create a Cloud Function in your Google account. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can also create the following optional resources by specifying the corresponding parameters:

              • Service account with IAM role
              • VPC with NAT external IP
              • VPC access connector

              To install Policy Agent Function through Terraform:

              1. From command shell, move to the directory where you downloaded Protegrity installation bundle.

              2. Unzip the bundle, then unzip the protegrity-agent-gcp-{version}.zip. Verify that the following files are available:

                • pty-agent-gcp/
                • main.tf
                • outputs.tf
                • README.md
              3. Open the main.tf file and update Terraform backend information at the top of the file:

                
                terraform {
                  backend "gcs" {
                    bucket  = ""
                    prefix  = "protegrity/terraform/pty-protect-gcp/state"
                  }
                }
                
              4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

              5. Set the prefix property with value unique to your deployment.

              6. In the same main.tf file, specify the following Terraform variables.

                ParameterDescription
                project_idThe Project ID recorded in the pre-configuration step
                regionThe Region recorded in the pre-configuration step, for example, us-central1.
                deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                deployment_bucket_locationGeographical location of deployment bucket, e.g., US, EU, ASIA.
                deployment_file_directory_pathPath to directory where deployment zip file is located. By default the deployment file should be in the same directory as this main.tf file.
                policy_download_cron_expressionCron expression determining how often policy agent function will run to synchronize security policy from ESA.
                create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                agent_function_service_account_emailUse Agent Function Service account recorded in pre-configuration or leave empty.
                create_vpcSet this to true, if you would like to create VPC with NAT, external IP and vpc access connector, otherwise leave empty. This will be ignored if google_vpc_access_connector_name is specified.
                google_vpc_access_connector_nameSpecify the existing VPC access connector name you identified in earlier step, otherwise leave empty. This setting will disable create_vpc = true.
                google_vpc_access_connector_full_resource_nameAlternative configuration for VPC access connector. If this parameter is set the google_vpc_access_connector_name will be ignored. Use this parameter, if vpc connector is in different region/project that the one specified for the deployment.
                labelsYou can set this map to include labels for deployed resources. Pay attention to gcp label requirements. More information in: https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

                All the values were recorded in Pre-Configuration and this section’s previous steps.

              7. Provide Policy update Terraform variables. In the same main.tf file, you can specify configuration related to policy update. Any of these variables can be updated at any given time by running the terraform again or directly in the GCP Console. Most of the values were recorded in previous installation steps.

                Parameter

                Description

                Notes

                pty_esa_ip

                ESA IP address or hostname

                ESA Server

                pty_esa_ca_server_cert

                ESA self-signed CA certificate used by policy Agent Function to ensure ESA is the trusted server.

                Recorded in step Certificates on ESA

                In case ESA is configured with publicly signed certificates, the pty_esa_ca_server_cert configuration will be ignored.

                gcp_esa_credentials_secret_resource_id

                ESA username and password (encrypted value by Google Cloud Secrets Manager). For example, projects/{project-id}/secrets/{secret name}/versions/{version}

                Creating ESA Credentials

                pty_esa_credentials_function

                ESA credentials GCP function resource name. For example, projects/{project-name}/locations/{region}/functions/{esa-credentials-function-name}.

                Recorded in step Option 2: Custom Cloud Function ESA CREDENTIALS FUNCTION NAME. Presence of gcp_esa_credentials_secret_resource_id will cause this value to be ignored. The Policy Agent Function must have network access and IAM permissions to call the ESA Credentials function you have created in Option 2: Custom Cloud Function.

                gcp_kms_key_resource_name

                The Key full resource name. For Example, projects/{project-id}/locations/region/keyRings/ {key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                Key Management Service

                gcp_protect_function_resource_name

                List of comma separated Protect function resource names. For Example, projects/{project-id}/ locations/{region}/functions/{function-name1},projects/{project-id}/ locations/{region}/functions/{function-name2}

                Use protect_function_resource_name recorded in Protect Service Installation section.

                gcp_policy_retention_storage_bucket

                Deployment Bucket Name where the encrypted policy will be written.

                You can use deployment bucket recorded in Google Cloud Storage section, or you can specify other existing bucket.

                gcp_policy_version_object_key

                Filename of the encrypted policy stored in the Deployment Bucket Name

                Default: policy.zip

                retain_policy_versions

                Number of policy versions to retain as backup. (e.g. 2 will retain the latest 2 policies and remove older ones). -1 retains all.

                Default: 10

                disable_deploy

                This flag can be either 1 or 0. If set to 1, then the agent will not update protector function with the newest policy. Else, the policy will be saved in the cloud storage bucket and deployed to the protector function.

                Default: 0

                log_level

                Application and audit logs verbiage level

                Default: INFO. Allowed values: DEBUG – the most verbose INFO, WARNING, ERROR – the least verbose

                policy_pull_timeout

                Time in seconds to wait for the ESA to send the full policy

                Default: 20

                pty_core_casesensitive

                Specifies whether policy usernames should be case sensitive

                Default: no. Allowed values: yes, no

                pty_core_emptystring

                Override default behavior. Empty string response values are returned as null values. For instance, (un)protect(’’) -> null (un)protect(’’) -> ''

                Default: empty. Allowed values: null, empty

                esa_connection_timeout

                Time in seconds to wait for the ESA response

                Default: 5s

                pty_addipaddressheader

                When enabled, agent will send its source IP address in the request header. This configuration works in conjunction with ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP (default=false). See Associating ESA Data Store With Cloud Protect Agent for more information.

                Default: yes. Allowed values: yes, no

                pty_datastore_key

                ESA policy datastore public key fingerprint (64 char long) e.g. 123bff642f621123d845f006c6bfff27737b21299e8a2ef6380aa642e76e89e5.

                The export key is the public part of an asymmetric key pair created in a Create KMS Key. A user with Security Officer permissions adds the public key to the data store in ESA via Policy Management > Data Stores > Export Keys. The fingerprint can then be copied using the Copy Fingerprint icon next to the key. Refer to Exporting Keys to Datastore for details.

                pty_sync_datastore

                Optional name of the policy datastore to sync with ESA. Refer to ESA documentation for more information on policy datastore sync.

                Default: ""
              8. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                protegrity-agent-gcp-{version}/pty-agent-gcp/
                
              9. Run terraform init.

                Terraform will download necessary providers.

              10. Run terraform plan to verify configuration and print out deployment plan.

              11. Run terraform apply to deploy resources to your account. Once deployment is complete, Terraform will print output variables.

              12. Below is the sample output from successful deployment.

                
                        Apply complete! Resources: 1 added, 0 changed, 0 destroyed. 
                        Outputs: 
                        agent_function_service_account_email = "pty-agent-test@test.iam.gserviceaccount.com" 
                        deployment_bucket_name = "test-bucket" 
                        nat_ip = 0 
                        policy_agent_function_deployment_object = "pty-agent-test-1.0.1.zip" 
                        policy_agent_function_name = "pty-agent-test" 
                

              Test Agent Function Installation

              After configuration is complete, you can test the function.

              To test and run the Policy Agent Function:

              1. From the Google Cloud console, go to Cloud Run Functions or Cloud Run.

              2. Click on the function you just deployed: pty_agent_{deployment_id}.

              3. Click Test button at the top right section of the screen.

              4. Scroll down to CLI test command.

              5. Copy and run the curl command to trigger the agent. Alternatively, use the option Test in Cloud Shell.

              6. Wait for the function to complete.

              7. Navigate to the LOGS tab to view agent execution logs.

              8. Alternatively, you may review the logs by navigating to Logging from your Google Console. In the Log Explorer select the All resources dropdown, then Cloud Run Revision > pty-agent-{deployment-id} and apply.

                
                Function execution took 23892 ms, finished with status: 'ok'
                iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_21-00-00.zip]
                iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_19-03-23.zip]
                iap.policy_deployer:INFO:Removing old function versions in [test-artifacts]. Will retain [1] versions.
                iap.policy_deployer:INFO:Updating function [projects/cloud-engineering-315519/locations/us-central1/functions/pty-protect-test] with new deployment artifact [test-artifacts/policy_v07-26-2021_21-00-01.zip] ...
                iap.imp_creator:INFO:Uploading encrypted policy data to: [test-artifacts/policy_v07-26-2021_19-03-23.zip]
                iap.imp_creator:INFO:Preparing deployment package ...
                iap_agent_gcp.cloud_functions_util:INFO:Downloading function deployment package ...
                iap.imp_creator:INFO:Encrypting policy package ...
                iap.policy_agent:INFO:Preparing new policy deployment ...
                iap.policy_agent:WARNING:Current policy deployment has no checksum_mapping metadata:
                iap.imp_creator:INFO:Checking current policy version ...
                iap.policy_agent:INFO:Current deployment package version: [policy_v07-26-2021_18-51-43.zip].
                iap.policy_agent:INFO:Getting current policy metadata ...
                iap.imp_creator:INFO:Policy downloaded successfully ...
                iap.imp_creator:INFO:PepServer started ...
                iap.imp_creator:INFO:Starting PepServer ...
                iap.imp_creator:INFO:PepServer configured successfully
                iap.imp_creator:INFO:Downloading certificates from ESA ...
                iap.imp_creator:INFO:Configuring PepServer ...
                iap.policy_agent:INFO:Starting policy agent ...
                iap.policy_agent:INFO:Using Secret Manager [GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID] to retreive ESA credentials.
                iap.policy_agent:INFO:PTY_CORE_CASESENSITIVE [no]
                iap.policy_agent:INFO:PTY_CORE_EMPTYSTRING [empty]
                iap.policy_agent:INFO:RETAIN_POLICY_VERSIONS [1]
                iap.policy_agent:INFO:GCP_PROTECT_FUNCTION_RESOURCE_NAME [projects/test/locations/us-central1/functions/pty-protect-test]
                iap.policy_agent:INFO:GCP_POLICY_VERSION_OBJECT_KEY [policy.zip]
                iap.policy_agent:INFO:GCP_POLICY_RETENTION_STORAGE_BUCKET [test-artifacts]
                iap.policy_agent:INFO:GCP_KMS_KEY_RESOURCE_NAME [projects/test/locations/us-central1/keyRings/test-key-ring/cryptoKeys/test-protect-asymmetric/cryptoKeyVersions/1]
                iap.policy_agent:INFO:GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID [projects/1234/secrets/ESA_ADMIN_CREDENTIALS/versions/2]
                iap.policy_agent:INFO:PTY_ESA_IP [54.236.107.39]
                iap.policy_agent:INFO:POLICY_PULL_TIMEOUT [20]
                iap.policy_agent:INFO:DISABLE_DEPLOY [0]
                Function execution started
                

              Troubleshooting

              Configure additional logging:

              1. Set log_level Terraform variable on the Agent function to DEBUG.

              2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                resource.type="cloud_run_revision"
                resource.labels.service_name=~"pty-agent-<deploymentd-id>"
                severity=ERROR OR textPayload=~"\[error\]"
                -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                
              3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

              Error message

              Details

              iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Resource 'projects/<account>/locations/<region>/functions/protegrity-protect-<deployment-id>' was not found
              
              This error may indicate the following configuration issues:
              1. The function name indicated in setting gcp_protect_function_resource_name has been provided incorrectly, and thus cannot be found.
              2. disable_deploy has been set, and a dummy function has been entered to work around the gcp_protect_function_resource_name requirement. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate.
              [ERROR] policy_agent:Invalid GCP_PROTECT_FUNCTION_RESOURCE_NAME parameter value. Must be a comma separated list of Lambda Function names or ARNs.
              
              This error may indicate the following configuration issues:
              1. The setting gcp_protect_function_resource_name is empty. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate, this setting may not be left empty.
              2. The list of function names provided to gcp_protect_function_resource_name contains invalid function name or is not valid csv format.
              [ERROR] iap_agent_gcp.cloud_functions_util:<HttpError 403 when requesting https://cloudfunctions.googleapis.com/v2/projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>:generateDo
              wnloadUrl?alt=json returned "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/<deployment-id>'". Details: "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'">
              [ERROR] policy_agent:Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'
              ...
              iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>' 
              

              Indicates the Agent Cloud Run function’s identity does not have permissions to sourceCodeGet for Protect/Log Forwarder function(s) provided to the gcp_protect_function_resource_name configuration.

              1.3.5 - Audit Log Forwarder Installation

              Install the audit log forwarder.

                  Audit Log Forwarder installation is done via Terraform scripts provided by Protegrity in the installation bundle.

                  ESA Audit Store Configuration

                  ESA server is required as the recipient of audit logs. Verify the information below to ensure ESA is accessible and configured properly.

                  1. ESA server running and accessible on TCP port 9200.

                  2. Audit Store service is configured and running on ESA. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                  Certificates on ESA

                  By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Log Forwarder configuration.

                  In case ESA is configured with publicly signed certificates, this section can be skipped since the Log Forwarder will use public CA to validate ESA certificates.

                  To obtain self-signed CA certificate from ESA:

                  1. Download ESA CA certificate from the /etc/ksa/certificates/plug directory of the ESA

                  2. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                    To escape new lines from command line, use one of the following commands depending on your operating system:

                    Linux Bash:

                    awk 'NF {printf "%s\\n",$0;}' CA.pem > output.txt
                    

                    Windows PowerShell:

                    (Get-Content '.\CA.pem') -join '\n' | Set-Content 'output.txt'
                    
                  3. Record the certificate content with new lines escaped.

                    ESA CA Server Certificate (EsaCaCert): ___________________

                    This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section. Install Log Forwarder via Terraform

                  For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                  VPC configuration

                  Similar to Policy Agent Function, log forwarder function requires Google Cloud VPC to route traffic from the function to ESA. Review the VPC configuration steps for agent in section Identify or Create a new VPC. Same VPC connector as the policy agent can be used. Note down VPC connector name:

                  google_vpc_access_connector_name: ___________________

                  ESA Authentication

                  Audit Log Forwarder must authenticate with ESA using certificate-based authentication with client certificate and certificate key. Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                  File NameDescription
                  client.keyClient certificate key
                  client.pemClient certificate (PEM)

                  Both certificate and certificate key must be converted to single-line values using code similar to the following examples.

                  Client certificate (client.pem):

                  $folder = 'C:\Temp'
                  cd $folder
                  (Get-Content "$folder\client.pem") -join '\n' | Set-Content "$folder\one-liner-client.pem"
                  cat "$folder\one-liner-client.pem"
                  
                  folder="/tmp"
                  cd "$folder"
                  awk 'NF {printf "%s\\n",$0}' "client.pem" > "one-liner-client.pem"
                  cat "one-liner-client.pem"
                  

                  Client certificate key (client.key):

                  $folder = 'C:\Temp'
                  cd $folder
                  (Get-Content "$folder\client.key") -join '\n' | Set-Content "$folder\one-liner-client.key"
                  cat "$folder\one-liner-client.key"
                  
                  folder="/tmp"
                  cd "$folder"
                  awk 'NF {printf "%s\\n",$0}' "client.key" > "one-liner-client.key"
                  cat "one-liner-client.key"
                  

                  While installing using Terraform template:

                  1. Provide single-line client certificate for pty_esa_client_cert
                  2. Provide ID of the GCP secret containing the single-line certificate key for pty_esa_client_cert_key_secret_id Secret is created in a later step

                  Configure ESA Secrets In GCP Secret Manager

                  Audit Log Forwarder Function uses GCP Secret Manager to store ESA Audit Store credentials used during authentication.

                  For information on how to configure basic and certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                  1. Log in to Google Account and select project where Protegrity service will be installed.

                  2. Go to Security > Secret Manager.

                  3. Select CREATE SECRET.

                  4. Specify the Secret Value:

                    {
                      "username": "admin", 
                      "password": "{esa_password}"
                    }
                    
                  5. Select Create Secret.

                  6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                  7. Click on Actions, next to the secret version you just created.

                  8. Select Copy Resource ID and record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/2.

                    ESA Log Forwarder Credentials Secret Name: _________________

                  9. Create another secret with single-line contents of ESA client certificate key file

                    See Certificate Authentication for details on client certificate key

                  10. Record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/1.

                    ESA Log Forwarder Client Certificate Key Secret Name: _________________

                  Create Log Forwarder Service Account

                  To create Log Forwarder Service Account:

                  1. Log in to Google Account and select the project where Protegrity service will be installed.

                  2. Navigate to IAM & Admin > Service Accounts.

                  3. Select CREATE SERVICE ACCOUNT.

                  4. Specify service account name and description.

                  5. Select Create and Continue.

                  6. In the next step, click Select Role. Then select the following roles:

                    • Cloud KMS CryptoKey Decrypter
                    • Pub/Sub Publisher
                    • Secret Manager Secret Accessor
                  7. Click Done.

                  8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                  9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                    Log Forwarder Function Service Account Email: ___________________

                  Create Service Account For Forwarder Pub/Sub

                  Pub/Sub service requires Cloud Run Invoker permissions in order to be able to send messages to the Forwarder function.

                  1. Log in to Google Account and select the project where Protegrity forwarder will be installed.

                  2. Navigate to IAM & Admin > Service Accounts.

                  3. Select CREATE SERVICE ACCOUNT.

                  4. Specify service account name and description.

                  5. Select Create and Continue.

                  6. In the next step, click Select Role. Then select Cloud Run Invoker.

                  7. Click Done.

                  8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                  9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                    Pub/Sub Log Forwarder Service Account Email: ___________________

                  Preparation

                  1. Ensure that all the steps in Google Cloud Project are performed.

                  2. Log in to the Google Cloud account where Protegrity will be installed.

                  3. Select the project.

                  4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                  5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                  Install Log Forwarder Function via Terraform Scripts

                  Resources created with Terraform scripts include Audit Log Forwarder Cloud Functions Service and Pub/Sub topic. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                  To install using Terraform:

                  1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                  2. Unzip the bundle, then unzip the protegrity-gcp-bigquery-{version}.zip. Navigate to pty-log-forwarder-gcp/. Verify that the following files are available:

                    • pty-log-forwarder-gcp/
                    • main.tf
                    • outputs.tf
                    • protegrity-cloud-api-gcp-{version}.zip
                    • README.md
                  3. Open the main.tf file and update Terraform backend information at the top of the file:

                    terraform {
                      backend "gcs" {
                        bucket  = ""
                        # The bucket/prefix combination must be unique for different deployments 
                        # to avoid conflicting Terraform states and accidental resources destruction.
                        # prefix = "protegrity-gcp-bigquery/forwarder/<deployment_id>/tf-state"
                      }
                    }
                    
                  4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                  5. Set the prefix property with value unique to your deployment.

                  6. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                    ParameterDescription
                    project_idThe project id recorded in the pre-configuration step
                    regionThe Region recorded in the pre-configuration step.
                    deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                    deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                    create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                    forwarder_function_service_account_emailUse Forwarder Function Service account recorded in pre-configuration or leave empty.
                    pub_sub_log_forwarder_service_account_emailService account of the audit log Pub/Sub trigger. The service account must be assigned Cloud Run Invoker (roles/run.invoker) role.
                    create_vpcIf create_vpc flag is set, new vpc will be created together with vpc connector, NAT and external IP Use this flag if you have VPC admin permissions in your Google Account. If you set it to false, you can specify the existing VPC in the google_vpc_access_connector_name parameter.
                    google_vpc_access_connector_nameUse existing VPC connector to associate with Log Forwarder Function. You can specify either the VPC connector name or the full resource name if vpc connector is in different region/project that the one specified for the deployment. You can alternatively set the use google_vpc_access_connector_full_resource_name. Both parameters are optional. Full resource name takes precedence over connector name.
                    log_destination_esa_ipIp address of the ESA where Protector logs will be sent to.
                    pty_esa_ca_server_certESA self-signed CA certificate used by log forwarder function to ensure ESA is the trusted server. See documentation for more details.
                    esa_credentials_secret_resource_idGCP Secret Manager secret id where ESA Fluent Bit logger credentials are stored.
                    pty_esa_client_certSingle-line ESA client certificate content. See Certificate Authentication for details on client certificate
                    pty_esa_client_cert_key_secret_idGCP Secret Manager secret id where single-line ESA client certificate key content is stored. See Configure ESA Secrets In GCP Secret Manager for details on client certificate key secret
                    min_log_levelMinimum log level for log forwarder function. Must be one of the following: [off,severe,warning,info,config,all].
                    esa_tls_disable_cert_verifyDisable certificate verification when connecting to ESA. This is only for dev purposes, should not be used in production environment.
                    esa_connect_timeoutEsa connection timeout in seconds.
                    esa_virtual_hostESA Virtual Host.
                    audit_log_flush_intervalTime interval in seconds used to accumulate audit logs before sending to ESA. Default value: 10
                    Min value: 1
                    Max value: 900
                    dlq_topic_message_retention_durationIndicates the minimum duration to retain a message in dead letter queue topic in case log destination server is not available. Value must be decimal number, followed by the letter s (seconds). Cannot be more than 31 days or less than 10 minutes. Default value is 1 day
                    audit_log_dead_letter_topicThis parameter is expected to be used in a separate deployment to replay dead letter queue messages.
                    max_instance_countGCP Cloud Functions advanced configuration
                    available_memory_mbGCP Cloud Functions advanced configuration
                    timeout_secondsGCP Cloud Functions advanced configuration
                    gen2_available_cpu2nd Gen Cloud Function advanced configuration
                    gen2_container_concurrency2nd Gen Cloud Function advanced configuration
                    upgrade_stepSet this variable when upgrading to the latest version.
                    labelsYou can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.
                  7. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                    pty-log-forwarder-gcp-{version}/pty-log-forwarder-gcp/
                    
                  8. Run the following command.

                    terraform init
                    
                  9. Terraform will download necessary providers.

                  10. Run the following command to verify configuration and print out deployment plan.

                    terraform plan
                    
                  11. Run the following command to deploy resources to your account.

                    terraform apply
                    
                  12. Once deployment is complete Terraform will print output variables.

                  13. Record the following values:

                    • forwarder_function_name: ____________________________
                    • forwarder_function_url: ____________________________
                    • forwarder_function_resource_name: __________________

                  Turn on Instance-based billing.

                  Both Protect and Log Forwarder functions must run for a short period of time after all requests are handled. In order for the GCP Cloud Run service to allow that, the Instance-based billing feature must be enabled for both function deployments.

                  To enable Instance-based billing:

                  1. Log in to Google Account and select the project where Protegrity Cloud Run Function was installed.

                  2. Navigate to Cloud Run.

                  3. Click on the Cloud Function name.

                  4. In Cloud Run revision view, select Edit & deploy new revision.

                  5. Scroll down to Billing.

                  6. Select Instance-based.

                  7. Click DEPLOY.

                  8. Repeat the steps for Log Forwarder function.

                  Test Log Forwarder Function Installation

                  Before continuing with next steps, you can verify whether Log Forwarder Function is installed correctly. This step is optional and can be skipped.

                  1. Below you can find example CURL command to test your function.

                  2. Before you can execute it, test if you can obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the Cloud Run Invoker permissions. Continue to the next step if the command succeeds and prints the token.

                  3. Replace {forwarder_function_url}; with value recorded in previous step.

                  4. Run the following CURL command to test Function deployment.

                    curl {forwarder_function_url} \
                    -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
                    -H "Content-Type: application/json" \
                    -H "ce-id: 123451234512345" \
                    -H "ce-specversion: 1.0" \
                    -H "ce-time: 2020-01-02T12:34:56.789Z" \
                    -H "ce-type: google.cloud.pubsub.topic.v1.messagePublished" \
                    -H "ce-source: //pubsub.googleapis.com/projects/MY-PROJECT/topics/MY-TOPIC" \
                    -d '{
                        "message": { 
                            "data": "'"$(echo '{"additional_info":{"description":"Data unprotect operation was successful.","query_id":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23"},"client":{},"cnt":4000,"correlationid":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23","level":"SUCCESS","logtype":"Protection","origin":{"hostname":"localhost","time_utc":1725558586},"process":{"id":1},"protection":{"audit_code":8,"dataelement":"alpha","datastore":"SAMPLE_POLICY","mask_setting":"","operation":"Unprotect","policy_user":"master_user"},"protector":{"core_version":"1.2.2+42.g01eb3.HEAD","family":"cp","pcc_version":"3.4.0.20","vendor":"gcp.snowflake","version":"3.1.0.158"},"signature":{"checksum":"7CE5FFCE9DBE570AAA72D1BB20CD083532EF8FAD3E96E38629EB92E837272D8E","key_id":"676c5178-756d-4363-9"}}' | base64 -w 0)"'",
                            "attributes": {},  
                            "messageId": "",  
                            "publishTime": "2014-10-02T15:01:23Z",
                            "orderingKey": ""
                       }
                    }'
                    
                  5. In GCP Logs Explorer console verify that the following output appears in the logs:

                    Request finished HTTP/1.1 POST http://pty-forwarder-31-smoke-jf-pfadh7riaq-uc.a.run.app/ - 200 0 - 75.6570ms
                    
                  6. .

                  Grant Pub/Sub Publisher Permission to the Protect Function Service Account

                  Protect function requires permissions to publish audit log messages to Pub/Sub.

                  1. Log in to Google Account and select the project where Protegrity service will be installed.

                  2. Navigate to IAM & Admin.

                  3. Search for protector function service account email recorded in protect service installation step.

                  4. Select Edit principal pencil icon.

                  5. Select ADD ANOTHER ROLE.

                  6. Select Pub/Sub Publisher.

                  7. Click Save.

                  Protect Function Pub/Sub Log Output

                  Protect function must be configured to output audit logs to Pub/Sub topic.

                  To configure Protect function audit log output:

                  1. Go to Protect function Terraform deployment.

                  2. Navigate to pty-protect-gcp/main.tf.

                  3. Set Terraform variable pty_log_output=“pub_sub”.

                  4. Set Terraform variable pty_pub_sub_topic to log forwarder Pub/Sub topic.

                  5. Run terraform apply.

                  Troubleshooting

                  Configure additional logging:

                  1. Set min_log_level Terraform variable on both Protect function and Log Forwarder function to config.

                  2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                    resource.type="cloud_run_revision"
                    resource.labels.service_name=~"pty-(protect|forwarder)-<deploymentd-id>"
                    severity=ERROR OR textPayload=~"\[error\]"
                    -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                    
                  3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                  Error message

                  Details

                  Pub/Sub configuration error.
                  
                  1. Indicates problems with Pub/Sub service configuration/availability.

                  2. Expand error log entry and check exception details. For instance:

                    exception: "Grpc.Core.RpcException: Status(StatusCode="InvalidArgument", Detail="Invalid resource name given (name=projects/<todo>/topics/pty-forwarder-<todo>). 
                    
                  3. Verify that pty_pub_sub_topic Terraform variable is set to correct pub/sub resource name.

                  4. Verify that Pub/Sub topic exists.

                  Failed to send x/y audit logs to GCP Pub/Sub.   
                  
                  1. This error may be shown as a consequence of Pub/Sub configuration/availability errors.
                  2. Check for pub/sub configuration errors.
                  3. If pub/sub configuration looks correct, this may indicate that cloud function can’t process audit logs fast enough.
                  4. From Protector Function Terraform configuration, try increasing CPU and concurrency.
                  Audit log sink error: Unable to deliver all logs. 
                  
                  opensearch.0: Dropped records: 1/1
                  
                  [error] [output:opensearch:opensearch.0] HTTP status=401 URI=/_bulk
                  
                  1. Indicates problems with ESA Audit Store availability/configuration.
                  2. Those errors will usually be displayed together. The third error will have details on what is the status or response from ESA.
                  3. In this example, the HTTP status 401 indicates authentication issue.

                  1.3.6 -

                  Prerequisites

                  RequirementDetail
                  Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
                  Protegrity ESA 10.0+The Cloud VNet must be able to obtain network access to the ESA
                  Google Cloud AccountRecommend creating a new project for Protegrity Serverless
                  Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

                  1.3.7 -

                  Required Skills and Abilities

                  RequirementsDescription
                  GCP Cloud AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
                  Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                  Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

                  1.4 - REST API

                  Reference for Cloud API authorization and specification

                  The following sections describe key concepts for understanding the REST API.

                  Base URL: https://{YOUR_REGION}-{YOUR_PROJECT_ID}.cloudfunctions.net/{FUNCTION_NAME}

                  Substitute:

                  • YOUR_REGION - is the region where your function is deployed.
                  • YOUR_PROJECT_ID - is your Google Cloud Platform project ID.
                  • FUNCTION_NAME - recorded during the Protect function installation name.

                  1.4.1 - Policy Users

                  Protegrity Policy roles defines the unique data access privileges for every member.

                  Policy Users

                  Protegrity Policy roles defines the unique data access privileges for every member. The protector function protects the data with the username sent in either the JWT-formatted authorization header, the request body or service user in the environment variables.

                  The protector function behavior can be set in the cloud function environment variables as described in Install Protect Function via Terraform Scripts

                  Authorization/allow_assume_user01
                  EmptyUser from the request body. / (Throw an error).User from the request body.
                  JWTUser from JWT payloadUser from request body. If not found user from JWT payload.

                  1.4.2 - JWT Verification

                  Cloud Protect function can authenticate JWTs with an OpenID endpoint or a stored certificate/secret.

                  JWT Verification

                  Cloud Protect function can authenticate JWTs with an OpenID endpoint or a stored certificate/secret.

                  The protector must be able to reach specified OpenID endpoint to obtain the public key when OpenID settings are enabled. The retrieved key is used to verify the signature. Several additional claims are verified against the configuration provided to the protect function when OpenID is enabled: issuer, audience, appid (optional).

                  Availability of an OpenID endpoint from the protector may not be feasible or a non-OpenID issuer may be in use. In those cases, a stored certificate/secret may be used to validate the jwt signature by enabling jwt_verify and including a base64 encoded certificate/secret in jwt_secret_base64 configuration. Additional claims are not verified.

                  Secret

                  Stored secret verification example using jwt_verify and jwt_secret_base64 configurations:

                  1. Navigate to the cloud function main.tf configuration file, and find the section Parameters applicable when authorization = jwt
                  2. Edit/replace the entries as indicated below, then save and apply the configuration:

                  Parameter

                  Value

                  Notes

                  authorization

                  JWT

                  jwt_verify

                  1

                   

                  jwt_secret_base64

                  Secret in base64 encoding. For example, the value of the public key is as follows.

                  -----BEGIN PUBLIC KEY-----
                  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4fkg/JYyN3Skr6RYLiAd/Yhl0
                  2TE3/HzHSNPnCaRdUakGp9og7oXBMcoadFDjnoSq1sz+gUHnpoO7s2fwkD5Q4OnC
                  BGD3oKP2A4PlOOWD2B2cVmMqX/vf1nAA/343496jsbfgkh1Q7LTzR0IXfdii0o1U
                  CbvrVCuaBoyiv4TxWQIDAQAB
                  -----END PUBLIC KEY-----
                  

                  This public key will be stored as follows.

                  LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tL
                  S0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUV
                  VBQTRHTkFEQ0JpUUtCZ1FDNGZrZy9KWXl
                  OM1NrcjZSWUxpQWQvWWhsMAoyVEUzL0h6
                  SFNOUG5DYVJkVWFrR3A5b2c3b1hCTWNvY
                  WRGRGpub1NxMXN6K2dVSG5wb083czJmd2
                  tENVE0T25DCkJHRDNvS1AyQTRQbE9PV0Q
                  yQjJjVm1NcVgvdmYxbkFBLzM0MzQ5Nmpz
                  YmZna2gxUTdMVHpSMElYZmRpaTBvMVUKQ
                  2J2clZDdWFCb3lpdjRUeFdRSURBUUFCCi
                  0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==
                  

                  The secret must be in base64. We recommend using RSA public certificates, it is not recommended to keep Hash (symmetric) secrets in the clear.

                  OpenID

                  Verification example using openid_* configuration parameters:

                  1. Navigate to the cloud function main.tf configuration file, and find the section Parameters applicable when openid_enabled = true
                  2. Edit/replace the entries as indicated below, then save and apply the configuration:
                  ParameterValueNotes
                  openid_enabledtrue
                  openid_audiencesAudience as it would appear in the aud claim, for example “https://management.azure.com/"Can be either one value or comma separated list.
                  openid_issuersIssuer as it would appear in the iss claim, for example “https://sts.windows.net/bca3157d-b8d9-4ca8-a724-1c7e2b96e1ef"Can be either one value or comma separated list.
                  openid_appidAppid as it would appear in the appid claim, for example “9ada3e7d-4ec4-48da-9d69-5379b7984fe1”Optional. If value is “”, appid claim is ignored. When openid_appid is provided, it must match the appid claim of the token.

                  1.4.3 - Authorization Header

                  Authorization Header

                  Authorization Header

                  Allowing unauthenticated HTTP function invocation on Google Cloud protector function.

                  The Protect function will validate the JWT in the Authorization header.

                  Authenticating for invocation on Google Cloud protector function. All requests to the protector function will need to send the Google JWT in the Authorization header.

                  When PTY_GCP_JWT_HEADER is not set or it is false the Protect function will validate the JWT in the Authorization header.

                  When PTY_GCP_JWT_HEADER = true the Protect function will validate the JWT in the X-PTY-Authorization header.

                  1.4.4 - Export an OpenAPI Spec

                  Exporting OpenAPI Spec from GCP

                  Export an OpenAPI Spec

                  Once the Cloud API on GCP is installed, you can export the OpenAPI documentation file from:

                  {base url}/pty/v1/openapi

                  Authentication and Authorization configurations are enforced on the openapi endpoint URL.

                  1.4.5 - v1 Specification

                  Describes the v1 REST API specification

                  Request

                  AWS Lambda service limits maximum size of payload to 6 MB. Client applications of Protegrity Cloud API must ensure their payload size is within this limit. This applies to all types of requests described below.

                  Performs a policy operation such as protect, unprotect, or reprotect.

                  • URI

                    /v1/protect or /v1/unprotect or /v1/reprotect

                  • Method

                    POST

                  • Parameters

                    data: Input data to the policy operation.

                    data_element: Data element to use for the policy operation.

                    encoding: Optional, encoding of the data. One of: base64, base64_mime, base64_pem, base64_url, hex, or utf8. Defaults to hex for binary data elements, otherwise defaults to utf8.

                    external_iv: Optional, external initialization vector.

                    old_data_element: (reprotect) Data element for unprotecting the input.

                    old_external_iv: (reprotect) Optional, external initialization vector for the input.

                    query_id: Optional, identifier for the request.

                    user: User performing the operation.

                  • Result

                    Returns the output of the policy operation.

                  Example 1 - without external IV

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "Alphanum",
                    "data":[<data1>,<data2>]
                  }
                  

                  Example 2 - with external IV

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "Alphanum",
                    "external_iv": "abc123",
                    "data":[<data1>,<data2>]
                  }
                  

                  Example 3 - reprotect

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "deName",
                    "old_data_element": "Alphanum",
                    "data":[<data1>,<data2>]
                  }
                  

                  Performs policy operations using different data elements for each data set.

                  • URI

                    /v1/protect or /v1/unprotect or /v1/reprotect

                  • Method

                    POST

                  • Parameters

                    encoding: Optional, encoding of the data. One of: base64, base64_mime, base64_pem, base64_url, hex, or utf8. Defaults to hex for binary data elements, otherwise defaults to utf8.

                    query_id: Optional, prefix for the request identifier.

                    user: User performing the operation.

                    arguments[].data: Input data to the policy operation.

                    arguments[].data_element: Data element to use for the policy operation.

                    arguments[].external_iv: Optional, external initialization vector.

                    arguments[].id: Optional, request identifier.

                    arguments[].old_data_element: (reprotect) Data element for unprotecting the input.

                    arguments[].old_external_iv: (reprotect) Optional, external initialization vector for the input.

                  Example 4 - multiple data elements support payload

                  {
                    "encoding": "utf8",
                    "query_id": "query1234", 
                    "user": <policy_user>, 
                    "arguments": [
                      {
                        "id": "1", 
                        "external_iv": "<external iv>", 
                        "data_element": "<data element name>", 
                        "data":["<data1>","<data2>"]
                      }, 
                      {
                        "data_element": <data element name>, 
                        "data":["<data1>","<data2>"]
                      }
                    ]
                  }
                  
                  • External IV

                    The External IV feature provides an additional level of security by allowing different tokenized results across protectors for the same input data and token element, depending on the External IV set on each protector. External IVs must adhere to certain guardrails and not all data elements support External IV. To read more about the Tokenization model with External IV, refer to the External Initialization Vector (IV) chapter in the Protection Methods Reference.

                  Response

                  responsePayloadV1:
                  type: object
                    properties:
                      success:
                        type: bool
                      error_msg:
                        type: string
                        description: When success is false, error_msg is included
                      results:
                        type: array
                        items:
                          type: string
                  

                  Example success:

                  {
                    "encoding": "utf8", 
                    "results":["str1","str2"], 
                    "success": true
                  }
                  

                  If the request was successful, the success flag will always be true.

                  Example failure:

                  {
                    "error_msg": "token expired", 
                    "success": false
                  }
                  

                  If the request fails, the success flag will always be false.

                  Multi Data Elements Support Payload

                  responsePayloadV2:
                  type: object
                    properties:
                      success:
                        type: boolean
                      results:
                        type: array
                          items:
                            type: object
                            properties:
                              success:
                                type: bool
                              error_msg:
                                type: string
                                description: When success is false, error_msg is included
                              id:
                                type: string
                                description: When id is sent in the request payload, id is included in the response
                              results:
                                type: array
                                items:
                                  type: string
                  

                  Example success:

                  {
                    "encoding": "utf8", 
                    "results":[
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }, 
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }
                    ], 
                    "success": true
                  }
                  

                  If the all the subrequests were successful, the success flag will be true.

                  Example failure:

                  {
                    "results": [
                      {
                        "error_msg": 
                        "Protect failed. Data element not found. Refer to audit log for details", 
                        "success": false
                      }, 
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }
                    ], 
                    "success": false
                  }
                  

                  It is possible to have a mix of successful and unsuccessful results. In this case, the global success flag will be false.

                  1.4.6 - Legacy Specification

                  Describes the Legacy REST API specification

                  Protegrity has multiple products with REST API capabilities, such as Protection Server (out of support), DSG, and the latest product - IAP REST. Each one has its use case. To help you move to cloud-native implementation, Cloud Product REST API supports legacy payload.

                  Request

                  Performs a policy operation such as protect, unprotect, or reprotect.

                  • Method

                    POST

                  • Parameters

                    dataelementname: (protect/unprotect) Data element to use for the policy operation.

                    externaliv: (protect/unprotect) Optional, external initialization vector.

                    newdataelementname: (reprotect) Data element to use for the output.

                    newexternaliv: (reprotect) Optional, external initialization vector for the output.

                    olddataelementname: (reprotect) Data element to use for the input.

                    oldexternaliv: (reprotect) Optional, external initialization vector for the input.

                    policyusername: User performing the operation.

                    bulk.id: Optional, identifier for the request.

                    bulk.data[].content: Input data to the policy operation.

                  • Result

                    Returns the output of the policy operation.

                  Example 1 - protect without external IV

                  {
                    "protect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 2 - protect with external IV

                  {
                    "protect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "externaliv": "abc123",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 3 - unprotect

                  {
                    "unprotect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 4 - reprotect

                  {
                    "reprotect": {
                      "policyusername": "user1",
                      "newdataelementname": "deName",
                      "olddataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Response

                  Example:

                  {"protect":{"bulk":{"returntype":"success","data":[{"returntype":"success","message":"Data
                   protection was successful.","content":"RGZBUFR4ODAzejFwNjQ5TWg0TEFpcFNqbA=="},{"returntype":"success",
                  "message":"Data protection was successful.","content":"aHNnVVB5QWFDYw=="}]}}}
                  

                  1.4.7 - HTTP Status Codes

                  Explains about the HTTP Status Codes.

                  HTTP Status Codes

                  The following table explains the different HTTP Status Codes with their corresponding response.

                  Status Codes

                  Response

                  Description

                  200

                  {"results":["<string>","<string>"],
                   "success": true, "encoding":[hex|utf8]}
                  

                  Success protected data is in results and success attribute is true

                  400

                  {
                      "error_msg": "<string>",
                      "success": false
                  }
                  

                  There was an issue in the request, success is false, check error_msg attribute. For more information check the logs

                  500

                  {"error_msg": "", "success": false }
                  

                  Configuration error in the Google Cloud function configuration variables.

                  1.4.8 - SSL Certificates

                  Reference for SSL Certificate resources in GCP Cloud Run Functions

                  SSL Certificates

                  By default, the Google Cloud Functions support HTTPS.

                  Google Cloud Function HTTPS endpoint have TLS 1.0, TLS 1.1, TLS 1.2 and TLS1.3 enabled.

                  For more information on HTTPS setting on Google Cloud HTTP Functions, refer to Security levels

                  1.4.9 -

                  OpenID

                  Verification example using openid_* configuration parameters:

                  1. Navigate to the cloud function main.tf configuration file, and find the section Parameters applicable when openid_enabled = true
                  2. Edit/replace the entries as indicated below, then save and apply the configuration:
                  ParameterValueNotes
                  openid_enabledtrue
                  openid_audiencesAudience as it would appear in the aud claim, for example “https://management.azure.com/"Can be either one value or comma separated list.
                  openid_issuersIssuer as it would appear in the iss claim, for example “https://sts.windows.net/bca3157d-b8d9-4ca8-a724-1c7e2b96e1ef"Can be either one value or comma separated list.
                  openid_appidAppid as it would appear in the appid claim, for example “9ada3e7d-4ec4-48da-9d69-5379b7984fe1”Optional. If value is “”, appid claim is ignored. When openid_appid is provided, it must match the appid claim of the token.

                  1.4.10 -

                  Request

                  Performs a policy operation such as protect, unprotect, or reprotect.

                  • URI

                    /v1/protect or /v1/unprotect or /v1/reprotect

                  • Method

                    POST

                  • Parameters

                    data: Input data to the policy operation.

                    data_element: Data element to use for the policy operation.

                    encoding: Optional, encoding of the data. One of: base64, hex, or utf8. Defaults to hex for binary data elements, otherwise defaults to utf8.

                    external_iv: Optional, external initialization vector.

                    old_data_element: (reprotect) Data element for unprotecting the input.

                    old_external_iv: (reprotect) Optional, external initialization vector for the input.

                    query_id: Optional, identifier for the request.

                    user: User performing the operation.

                  • Result

                    Returns the output of the policy operation.

                  Example 1 - without external IV

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "Alphanum",
                    "data":[<data1>,<data2>]
                  }
                  

                  Example 2 - with external IV

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "Alphanum",
                    "external_iv": "abc123",
                    "data":[<data1>,<data2>]
                  }
                  

                  Example 3 - reprotect

                  {
                    "encoding": "utf8",
                    "query_id": "1",
                    "user": "user1",
                    "data_element": "deName",
                    "old_data_element": "Alphanum",
                    "data":[<data1>,<data2>]
                  }
                  

                  Performs policy operations using different data elements for each data set.

                  • URI

                    /v1/protect or /v1/unprotect or /v1/reprotect

                  • Method

                    POST

                  • Parameters

                    encoding: Optional, encoding of the data. One of: base64, hex, or utf8. Defaults to hex for binary data elements, otherwise defaults to utf8.

                    query_id: Optional, prefix for the request identifier.

                    user: User performing the operation.

                    arguments[].data: Input data to the policy operation.

                    arguments[].data_element: Data element to use for the policy operation.

                    arguments[].external_iv: Optional, external initialization vector.

                    arguments[].id: Optional, request identifier.

                    arguments[].old_data_element: (reprotect) Data element for unprotecting the input.

                    arguments[].old_external_iv: (reprotect) Optional, external initialization vector for the input.

                  Note: When multiple data elements are sent in the payload, the Cloud API generates an audit log per argument. The Cloud API appends the argument id, if it exists, to the query_id. For example: query_id.id:{id}. If an argument id is not provided then the index in the argument array is appended to the query_id. For example: query_id.index:{index}.

                  Example 4 - multiple data elements support payload

                  {
                    "encoding": "utf8",
                    "query_id": "query1234", 
                    "user": <policy_user>, 
                    "arguments": [
                      {
                        "id": "1", 
                        "external_iv": "<external iv>", 
                        "data_element": "<data element name>", 
                        "data":["<data1>","<data2>"]
                      }, 
                      {
                        "data_element": <data element name>, 
                        "data":["<data1>","<data2>"]
                      }
                    ]
                  }
                  
                  • External IV

                    The External IV feature provides an additional level of security by allowing different tokenized results across protectors for the same input data and token element, depending on the External IV set on each protector. To read more about the Tokenization model with External IV, refer to the External Initialization Vector (IV) in the Protection Methods Reference guide.

                  1.4.11 -

                  Request

                  Performs a policy operation such as protect, unprotect, or reprotect.

                  • Method

                    POST

                  • Parameters

                    dataelementname: (protect/unprotect) Data element to use for the policy operation.

                    externaliv: (protect/unprotect) Optional, external initialization vector.

                    newdataelementname: (reprotect) Data element to use for the output.

                    newexternaliv: (reprotect) Optional, external initialization vector for the output.

                    olddataelementname: (reprotect) Data element to use for the input.

                    oldexternaliv: (reprotect) Optional, external initialization vector for the input.

                    policyusername: User performing the operation.

                    bulk.id: Optional, identifier for the request.

                    bulk.data[].content: Input data to the policy operation.

                  • Result

                    Returns the output of the policy operation.

                  Example 1 - protect without external IV

                  {
                    "protect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 2 - protect with external IV

                  {
                    "protect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "externaliv": "abc123",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 3 - unprotect

                  {
                    "unprotect": {
                      "policyusername": "user1",
                      "dataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  Example 4 - reprotect

                  {
                    "reprotect": {
                      "policyusername": "user1",
                      "newdataelementname": "deName",
                      "olddataelementname": "Alphanum",
                      "bulk": {
                        "id": "1",
                        "data": [
                          {
                            "content": <Data encoded in base64>
                          }
                        ]
                      }
                    }
                  }
                  

                  1.4.12 -

                  Response

                  responsePayloadV1:
                  type: object
                    properties:
                      success:
                        type: bool
                      error_msg:
                        type: string
                        description: When success is false, error_msg is included
                      results:
                        type: array
                        items:
                          type: string
                  

                  Example success:

                  {
                    "encoding": "utf8", 
                    "results":["str1","str2"], 
                    "success": true
                  }
                  

                  If the request was successful, the success flag will always be true.

                  Example failure:

                  {
                    "error_msg": "token expired", 
                    "success": false
                  }
                  

                  If the request fails, the success flag will always be false.

                  Multi Data Elements Support Payload

                  responsePayloadV2:
                  type: object
                    properties:
                      success:
                        type: boolean
                      results:
                        type: array
                          items:
                            type: object
                            properties:
                              success:
                                type: bool
                              error_msg:
                                type: string
                                description: When success is false, error_msg is included
                              id:
                                type: string
                                description: When id is sent in the request payload, id is included in the response
                              results:
                                type: array
                                items:
                                  type: string
                  

                  Example success:

                  {
                    "encoding": "utf8", 
                    "results":[
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }, 
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }
                    ], 
                    "success": true
                  }
                  

                  If the all the subrequests were successful, the success flag will be true.

                  Example failure:

                  {
                    "results": [
                      {
                        "error_msg": 
                        "Protect failed. Data element not found. Refer to audit log for details", 
                        "success": false
                      }, 
                      {
                        "encoding": "utf8", 
                        "results":["str1","str2"], 
                        "success": true
                      }
                    ], 
                    "success": false
                  }
                  

                  It is possible to have a mix of successful and unsuccessful results. In this case, the global success flag will be false.

                  1.4.13 -

                  Response

                  Example:

                  {"protect":{"bulk":{"returntype":"success","data":[{"returntype":"success","message":"Data
                   protection was successful.","content":"RGZBUFR4ODAzejFwNjQ5TWg0TEFpcFNqbA=="},{"returntype":"success",
                  "message":"Data protection was successful.","content":"aHNnVVB5QWFDYw=="}]}}}
                  

                  1.4.14 -

                  Secret

                  Stored secret verification example using jwt_verify and jwt_secret_base64 configurations:

                  1. Navigate to the cloud function main.tf configuration file, and find the section Parameters applicable when authorization = jwt
                  2. Edit/replace the entries as indicated below, then save and apply the configuration:

                  Parameter

                  Value

                  Notes

                  authorization

                  JWT

                  jwt_verify

                  1

                   

                  jwt_secret_base64

                  Secret in base64 encoding. For example, the value of the public key is as follows.

                  -----BEGIN PUBLIC KEY-----
                  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC4fkg/JYyN3Skr6RYLiAd/Yhl0
                  2TE3/HzHSNPnCaRdUakGp9og7oXBMcoadFDjnoSq1sz+gUHnpoO7s2fwkD5Q4OnC
                  BGD3oKP2A4PlOOWD2B2cVmMqX/vf1nAA/343496jsbfgkh1Q7LTzR0IXfdii0o1U
                  CbvrVCuaBoyiv4TxWQIDAQAB
                  -----END PUBLIC KEY-----
                  

                  This public key will be stored as follows.

                  LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tL
                  S0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUV
                  VBQTRHTkFEQ0JpUUtCZ1FDNGZrZy9KWXl
                  OM1NrcjZSWUxpQWQvWWhsMAoyVEUzL0h6
                  SFNOUG5DYVJkVWFrR3A5b2c3b1hCTWNvY
                  WRGRGpub1NxMXN6K2dVSG5wb083czJmd2
                  tENVE0T25DCkJHRDNvS1AyQTRQbE9PV0Q
                  yQjJjVm1NcVgvdmYxbkFBLzM0MzQ5Nmpz
                  YmZna2gxUTdMVHpSMElYZmRpaTBvMVUKQ
                  2J2clZDdWFCb3lpdjRUeFdRSURBUUFCCi
                  0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQ==
                  

                  The secret must be in base64. We recommend using RSA public certificates, it is not recommended to keep Hash (symmetric) secrets in the clear.

                  1.5 - Performance

                  Performance benchmarks and considerations.

                  1.5.1 - Performance Considerations

                  The following factors may affect performance benchmarks

                  Performance Considerations

                  The following factors may affect performance benchmarks:

                  • Cold startup: Cloud Function spends additional time on the initial invocation to decrypt and load the policy into memory. This time can vary depending on the policy size. Once the Function is initialized, subsequent “warm executions” should process quickly.
                  • Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                  • Cloud Function memory: GCP provides more virtual cores based on the memory configuration. The initial configuration of 2048 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                  • Number of security operations (protect or unprotect).
                  • Cloud Function max instances and concurrency quota: The instance limit affects how functions are scaled. By default the limit is not set to allow handling any traffic pattern. The instance limit can be set to prevent abnormally high request levels. Cloud Functions are also subject to maximum quota for concurrent invocations and request rate.
                  • Size of data element: Operations on larger text consume time.

                  1.5.2 - Log Forwarder Performance

                  Guidance on Log Forwarder Performance settings and considerations.

                    Log Forwarder Performance

                    Log forwarder architecture is optimized to minimize the amount of connections and reduce the overall network bandwidth required to send audit logs to ESA. This is achieved with batching and aggregation taking place on two levels. The first level is in protector function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching and aggregation takes place in the log forwarder function before audit logs are forwarded to ESA. This section shows how to configure the deployment to accommodate different patterns of anticipated audit log stream. It also shows how to monitor deployment resources to detect problems before audit records are lost.

                                

                    • Protector Function Terraform configuration:

                      • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to Pub/Sub topic. Default value is 30 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The protector function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to Pub/Sub. The protector function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to Pub/Sub. This can be avoided by lowering the interval value.

                                              

                    • Log Forwarder Function Terraform configuration

                      • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to ESA audit log store. Default value is 10 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The forwarder function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to ESA. The forwarder function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to ESA. This can be avoided by lowering the interval value. On the other hand if the interval is too short, forwarder function might end up sending to many requests to ESA, which in some extreme cases may result in messages being sent to dead letter queue.
                      • gen2_available_cpu: Increasing the Function CPU count allows setting higher concurrency, which in turn allows processing more messages from the Pub/Sub in parallel. The high CPU count will effectively lower the number of forwarder function instances which will lower number of connections to ESA.
                      • gen2_container_concurrency: See bullet point above.
                      • audit_log_dead_letter_topic: Dead-letter Pub/Sub topic name. This topic will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ topic can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                              

                    • Monitoring Log Forwarder Resources

                      • Protector Function Logs: If protector function is unable to send logs to Pub/Sub, it will log the following message:

                        Failed to send x/y audit logs to GCP Pub/Sub.
                        

                        See the description of ‘audit_log_flush_interval’ in the protector function configuration section above to learn about potential mitigation.

                      • Pub/Sub DLQ Topic Metrics: Any positive value in count aggregator on ’topic/message_sizes’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Install Log Forwarder Function via Terraform Scripts

                      • Log Forwarder Function Logs: If log forwarder function is unable to send logs to ESA, it will log the following message:

                        [/jenkins/workspace/iaplambda_release_3.1/src/iap/logging/fluent-bit-external-sink.cpp:225] opensearch.0: Dropped records: x/y.
                        

                        See the description of ‘audit_log_flush_interval’ in the log forwarder configuration section above to learn about potential mitigation.

                    1.6 - Audit Logging

                    Audit log description/formatting

                      Audit Logging

                      Audit records and application logs stream to Google Cloud Logging. Cloud Protect uses a JSON format for audit records that is described in the following sections.

                      You can analyze and alert on audit records using Protegrity ESA or Google Cloud Logging. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Google Cloud Logging, refer to the Google Cloud Logging overview.

                      For more information about audit records, refer to the Protegrity Analytics Guide.

                      Audit record fields

                      The audit record format has been altered in version 3.1 of the protector to provide more information.

                      FieldDescription
                      additional_info.deployment_idThe deployment_id contains the name of the Protect Function. It is automatically set based on the cloud-specific environment variables assigned to the Protect Function. This allows identifying the Cloud Protect deployment responsible for generating audit log.
                      additional_info.cluster(Optional) Redshift cluster ARN
                      additional_info.descriptionA human-readable message describing the operation
                      additional_info.query_id(Optional) Identifies the query that triggered the operation
                      additional_info.request_id(Optional) AWS Lambda request identifier
                      cntNumber of operations, may be aggregated
                      correlationid(Deprecated) Use additional_info instead
                      levelLog severity, one of: SUCCESS, WARNING, ERROR, EXCEPTION
                      logtypeAlways “Protection”
                      origin.ipThe private IP address of the compute resource that operates the Protect Function and is responsible for generating the log entry.
                      origin.hostnameHostname of the system that generated the log entry
                      origin.time_utcUTC timestamp when the log entry was generated
                      protection.audit_codeAudit code of the protect operation; see the log return codes table in the Protegrity Troubleshooting Guide
                      protection.dataelementData element used for the policy operation
                      protection.datastoreName of the data store corresponding to the deployed policy
                      protection.mask_setting(Optional) Mask setting from policy management
                      protection.operationOperation type, one of: Protect, Unprotect, Reprotect
                      protection.policy_userUser that performed the operation
                      protector.core_versionInternal core component version
                      protector.familyAlways “cp” for Cloud Protect
                      protector.lambda_versionProtector Lambda application version.
                      protector.pcc_versionInternal pcc component version
                      protector.vendorIdentifies the cloud vendor and the database vendor
                      protector.versionProtector version number
                      signature.checksumHash value of the signature key ID used to sign the log message when the log is generated
                      signature.key_idKey used to sign the log message when the log is generated

                      The following are sample audit messages:

                      Protect Success:

                      {
                            "additional_info": {
                              "description": "Data protect operation was successful.",
                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "SUCESS",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 6,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            "client": {},
                            "protector": {
                              "family": "cp",
                              "lambda_version": "3.2.10",
                              "version": "3.2.0",
                              "vendor": "aws.snowflake",
                              "pcc_version": "3.4.0.14",
                              "core_version": "1.2.1+55.g590fe.HEAD"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      User permission denied:

                      {
                            "additional_info": {
                              "description": "The user does not have the appropriate permissions to perform the requested operation."
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "ERROR",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 3,
                              "policy_user": "test_user"
                            },
                            "process": {
                              "id": "1",
                              "thread_id": "849348352"
                            },
                            "client": {},
                            "protector": {
                              "family": "IAP Lambda",
                              "lambda_version": "3.2.10",
                              "version": "3.2.0",
                              "vendor": "Cloud Protect",
                              "pcc_version": "3.3.0.5",
                              "core_version": "1.1.0"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      Data element not found:

                      {
                            "additional_info": {
                              "description": "The data element could not be found in the policy in shared memory."
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "ERROR",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 2,
                              "policy_user": "test_user"
                            },
                            "process": {
                              "id": "1",
                              "thread_id": "849348352"
                            },
                            "client": {},
                            "protector": {
                              "family": "IAP Lambda",
                              "lambda_version": "3.2.10",
                              "version": "3.2.0",
                              "vendor": "Cloud Protect",
                              "pcc_version": "3.3.0.5",
                              "core_version": "1.1.0"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      Example Audit Records

                      The following are sample audit messages:

                      Protect Success:

                      {
                            "additional_info": {
                              "description": "Data protect operation was successful.",
                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "SUCESS",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 6,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            "client": {},
                            "protector": {
                              "family": "cp",
                              "version": "3.1.0",
                              "vendor": "aws.snowflake",
                              "pcc_version": "3.4.0.14",
                              "core_version": "1.2.1+55.g590fe.HEAD"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      Reprotect Success:

                      {
                            "additional_info": {
                              "description": "Data reprotect operation was successful.",
                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "SUCCESS",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "old_dataelement": "deAddress1",
                              "dataelement": "deAddress2",
                              "operation": "Reprotect",
                              "audit_code": 50,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            "client": {},
                            "protector": {
                              "family": "cp",
                              "version": "3.1.0",
                              "vendor": "aws.snowflake",
                              "pcc_version": "3.4.0.14",
                              "core_version": "1.2.1+55.g590fe.HEAD"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      User permission denied:

                      {
                            "additional_info": {
                              "description": "The user does not have the appropriate permissions to perform the requested operation.",
                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "ERROR",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 3,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            "client": {},
                            "protector": {
                              "family": "cp",
                              "version": "3.1.0",
                              "vendor": "aws.snowflake",
                              "pcc_version": "3.4.0.14",
                              "core_version": "1.2.1+55.g590fe.HEAD"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      Data element not found:

                      {
                            "additional_info": {
                              "description": "The data element could not be found in the policy in shared memory.",
                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                            },
                            "cnt": 4000,
                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                            "logtype": "Protection",
                            "level": "ERROR",
                            "origin": {
                              "hostname": "localhost",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 2,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            "client": {},
                            "protector": {
                              "family": "cp",
                              "version": "3.1.0",
                              "vendor": "aws.snowflake",
                              "pcc_version": "3.4.0.14",
                              "core_version": "1.2.1+55.g590fe.HEAD"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      1.7 - No Access Behavior

                      Unauthorized unprotect requests behaviour.

                      No Access Behavior

                      The security policy maintains a No Access Operation, configured in an ESA, which determines the response for unauthorized unprotect requests.

                      The following table describes the result returned in the response for the various no access unprotect permissions.

                      No Access OperationData Returned
                      Nullnull
                      Protected(protected value)
                      ExceptionQuery will fail with an exception

                      1.8 - Upgrading To The Latest Version

                      Instructions for upgrading the protector.

                      1.9 - Known Limitations

                      Known product limitations.
                      • Only protect and unprotect operations are supported. The re-protect operation is not supported.

                      • The Semi-structured (JSON) data type is not supported in the product.

                      • Cloud Function (Gen2) labels must not be updated from the Cloud Run Services console. When updating labels for a GCP Cloud Function (Gen2) through the Cloud Run Services console, GCP creates a new Cloud Run revision with the updated labels, but the underlying Cloud Function retains the old labels. Because the policy agent reads labels from the Cloud Function definition (not the Cloud Run revision), it will not detect the label change and will not trigger a policy update.

                        Cloud Run labels vs Cloud Function labels

                        To avoid this issue, always update labels using one of the following methods:

                        • Cloud Run Functions console — Navigate to Cloud Run Functions, select the function, and update labels there. This ensures both the Cloud Function and its underlying Cloud Run revision are updated consistently.
                        • Terraform — Update the labels variable in your Terraform configuration and run terraform apply.
                        • gcloud CLI — Use gcloud functions deploy with the updated --update-labels flag.

                        If labels were already updated incorrectly through the Cloud Run Services console, redeploy the function using one of the methods above to synchronize the labels and trigger a policy update.

                      1.10 - Appendices

                      Additional references for the protector.

                      1.10.1 - Integrating Cloud Protect with PPC (Protegrity Provisioned Cluster)

                      Concepts for integrating with PPC (Protegrity Provisioned Cluster)

                        This guide describes how to configure the Protegrity Policy Agent and Log Forwarder to connect to a Protegrity Provisioned Cluster (PPC), highlighting the differences from connecting to ESA.

                        Key Differences: PPC vs ESA

                        FeatureESA 10.2PPC (this guide)
                        Datastore Key FingerprintOptional/RecommendedRequired
                        CA Certificate on AgentOptional/RecommendedOptional/Recommended
                        CA Certificate on Log ForwarderOptional/RecommendedNot supported
                        Client Certificate Authentication from Log ForwarderOptional/RecommendedNot supported
                        IP AddressESA IP addressPPC address

                        Prerequisites

                        • Access to PPC and required credentials.
                        • Tools: curl, kubectl installed.

                        Policy Agent Setup with PPC

                        Follow these instructions as a guide for understanding specific inputs for Policy Agent integrating with PPC:

                        1. Obtain the Datastore Key Fingerprint

                          To retrieve the fingerprint for your Policy Agent:

                          1. Retrieve public key from the Cloud Provider Key Management service for the policy encryption key created in pre-configuration:

                            1. Navigate to the Key Management Service in AWS console and open Customer Managed Keys
                            2. Select the desired key
                            3. Select the Public Key tab
                            4. Select Download
                            1. Navigate to the Key Vault in Azure console and open Objects>Keys
                            2. Select the desired key
                            3. Select the key indicated as CURRENT VERSION
                            4. Select Download public key
                            1. Navigate to Key Management in GCP console
                            2. Select the desired key and open the Versions tab
                            3. Select Get public key from the Actions column menu
                            4. Select Download

                          2. Escape the new line characters in the downloaded public key for use in the next step - for example:

                            awk 'NF {printf "%s\\n",$0}' "<public_key_file>" > "new-line-escaped-public-key.pem"
                            cat new-line-escaped-public-key.pem
                            
                          3. Export key fingerprint using the PPC API as indicated in the curl example below:

                            curl -k -H "Authorization: Bearer ${TOKEN}" -X POST https://${HOST}/pty/v2/pim/datastores/1/export/keys  -H "Content-Type: application/json" --data '{
                              "algorithm": "RSA-OAEP-256",
                              "description": "example-key-from-key-management",
                              "pem": "<value of new-line-escaped-public-key>"
                            }'
                            

                            Sample Output:

                            {"uid":"1","algorithm":"RSA-OAEP-256","fingerprint":"4c:46:d8:05:35:2e:eb:39:4d:39:8e:6f:28:c3:ab:d3:bc:9e:7a:cb:95:cb:b1:8e:b5:90:21:0f:d3:2c:0b:27","description":"example-key-from-kms"}
                            
                          4. Record the value for fingerprint and configure the Policy Agent:

                            Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Lambda function to the fingerprint value.

                            Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Function App to the fingerprint value.

                            Set the variable in Policy Agent main.tf pty_datastore_key to the fingerprint value and apply the changes.

                        2. Retrieve the PPC CA Certificate

                          To obtain the CA certificate from PPC:

                          kubectl -n api-gateway get secret ingress-certificate-secret -o jsonpath='{.data.ca\.crt}' | base64 -d > CA.pem
                          

                          Use the ProtegrityCA.pem that was returned as described in Policy Agent Installation.

                        3. Configure the PPC Address

                          Use the PPC address in place of the ESA IP address wherever required in your configuration.

                        Log Forwarder Setup with PPC

                        • The Log Forwarder will proceed without certificates and will print a warning if PTY_ESA_CA_SERVER_CERT is not provided.
                        • No additional certificate or CA configuration is needed for PPC.

                        1.10.2 - Protection Methods

                        Cloud API supported protection methods

                        Protection Methods

                        For more information about the protection methods supported by Protegrity, refer to the Protection Methods Reference.

                        Tokenization Type

                        Supported Input Data Types

                        Notes

                        Numeric

                        Credit Card

                        Alpha

                        Upper-case Alpha

                        Alpha-Numeric

                        Upper Alpha-Numeric

                        Lower ASCII

                        Printable

                        Decimal

                        Unicode

                        Unicode Base64

                        Unicode Gen2

                        Email

                        STRING

                        NULL

                        Integer

                        NUMBER

                        NULL

                        Date

                        Datetime

                        STRING

                        NULL

                        For information about supported formats, refer to the Protection Methods Reference.

                        Binary

                        STRING

                        NULL

                        Must be hex encoded unless a different encoding is specified. Another supported encoding is base64.

                        Protection Method

                        Supported Input Data Types

                        Notes

                        No Encryption

                        STRING

                        NUMBER

                        NULL

                        Encryption Algorithm

                        Supported Input Data Types

                        Notes

                        3DES

                        AES-128

                        AES-256

                        CUSP 3DES

                        CUSP AES-128

                        CUSP AES-256

                        STRING

                        Must be hex encoded unless a different encoding is specified. Another supported encoding is base64.

                        1.10.3 - Configuring Regular Expression to Extract Policy Username

                        Example configurations for user extraction with regular expressions

                        Configuring Regular Expression to Extract Policy Username

                        Cloud Protect Cloud Function exposes USERNAME_REGEX configuration to allow extraction of policy username from user in the request.

                        • USERNAME_REGEX Cloud Function Environment configuration

                          The USERNAME_REGEX environment variable can be set to contain regular expression with one capturing group. This group is used to extract the username. Examples below show different regular expression values and the resulting policy user.

                        USERNAME_REGEX

                        User in the request

                        Effective Policy User

                        Not Set

                        user@domain.com

                        user@domain.com

                        service-account-user@project-id.iam.gserviceaccount.com

                        service-account-user@project-id.iam.gserviceaccount.com

                        ^(.*)@.*$
                        

                        service-account-user@project-id.iam.gserviceaccount.com

                        service-account-user

                        user@domain.com

                        user

                        1.10.4 - Associating ESA Data Store With Cloud Protect Agent

                        ESA controls policy access by mapping server IPs to data stores, registering a node when an agent requests a policy and its IP is identified.

                        Associating ESA Data Store With Cloud Protect Agent

                        ESA controls which policy is deployed to protector using concept of data store. A data store may contain a list of IP addresses identifying servers allowed to pull the policy associated with that specific data store. Data store may also be defined as default data store, which allows any server to pull the policy, provided it does not belong to any other data stores. Node registration occurs when the policy server (in this case the policy agent) makes a policy request to ESA, where the agent’s IP address is identified by ESA.

                        Policy agent function source IP address used for node registration on ESA depends on ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP and the PTY_ADDIPADDRESSHEADER configuration exposed by the agent function.

                        The function service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range described in Function app outbound IP addresses section under function configuration. By default, when agent function is contacting ESA to register node for policy download, ESA uses agent function outbound IP address. This default behavior is caused by the default ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP=false and agent default configuration PTY_ADDIPADDRESSHEADER=yes.

                        In some cases, when there is a proxy server between the ESA and agent function, the desirable ESA configuration is ASSIGN_DATASTORE_USING_NODE_IP=true. and PTY_ADDIPADDRESSHEADER=no which will cause the ESA to use proxy server IP address.

                        The table below shows how the hubcontroller and agent settings will affect node IP registration on ESA.

                        Agent source IPAgent Function Outbound IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent function config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                        169.254.144.8120.75.43.207No Proxytrueyes169.254.144.81
                        trueno20.75.43.207
                        falseyes
                        falseno
                        169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                        trueno34.230.42.110
                        falseyes
                        falseno

                        1.10.5 - Undeliverable Audit Log Recovery

                        Cloudapi Audit log Recovery

                          Protegrity Cloud Protect Log Forwarder installation provides a solution to recover undelivered audit logs. Reasons for undeliverable logs may include:

                          • Changes to network configuration in ESA or cloud provider (VPC, firewall, certificate rotation, service user credentials)
                          • Log Forwarder IAM Service Account permissions
                          • Log Forwarder Cloud Run Function configuration
                          • Disruption in cloud provider service

                          Log Forwarder Dead Letter Pub/Sub Architecture

                          Log Forwarder is triggered by pub/sub events generated by Protect Functions. If Log Forwarder is unable to reach ESA to deliver the logs, they are pushed to a dead letter pub/sub topic. Dead letter pub/sub topic is created when installing the Log Forwarder with the service installation script. See Install Log Forwarder Function via Terraform Scripts for dead letter topic configuration options and naming conventions.

                          Logs are not delivered to ESA. Undelivered audit logs are sent to a dead letter pub/sub topic.

                          Monitoring Undelivered Logs

                          Logs pushed to the dead letter pub/sub topic will be purged and no longer recoverable when specified dlq_topic_message_retention_duration has been reached. Monitoring the dead letter topic is recommended to ensure timely recovery of audit messages before they are permanently lost. Consult the GCP monitoring alerts documentation for setting up alerts based on pub/sub topic metrics.

                          Protegrity recommends creation of an additional Log Forwarder installation in the case where logs are not delivered to ESA, as described in Log Forwarder Dead Letter Pub/Sub Architecture.

                          Audit log recovery using new log forwarder installation

                          Steps to recover audit logs using new Log Forwarder installation:

                          1. Create a second Log Forwarder installation (Log Forwarder 2 in the above diagram) for processing undelivered logs. Value for audit_log_dead_letter_topic in the terraform script should be set to null during installation.

                          2. Configure and test newly installed Log Forwarder to verify ESA connectivity. See Install Log Forwarder Function via Terraform Scripts for installation instructions.

                          3. Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                            terraform output
                            

                            for the Log Forwarder which failed to deliver logs (Log Forwarder as described in Log Forwarder Dead Letter Pub/Sub Architecture). Note the value for audit_log_dlq_topic.

                          4. Set audit_log_dead_letter_topic in the new Log Forwarder (Log Forwarder 2 in the above diagram) terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with terraform apply.

                          5. Monitor the new Log Forwarder function logs for any failures.

                          Recovering Logs in Dead Letter Topic (Alternative)

                          When the recommended method of for recovery described in Recovering Logs in Dead Letter Topic (Recommended) is not an option, you may use the existing Log Forwarder to reprocess undelivered logs.

                          Audit log recovery using existing log forwarder installation

                          Steps to recover audit logs using existing Log Forwarder installation:

                          • Fix any configuration errors causing the Log Forwarder to fail. Verify audit logs are being transmitted successfully to ESA.

                          • Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                            terraform output
                            

                            for the Log Forwarder. Note the value for audit_log_dlq_topic.

                          • Set audit_log_dead_letter_topic in the terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with

                            terraform apply
                            
                          • When audit logs have been transmitted to ESA, revert setting audit_log_dead_letter_topic to null Apply the changes with

                            terraform apply
                            

                          2 - BigQuery

                          Protector for Google BigQuery.

                          This section describes the high-level architecture of the Protegrity BigQuery Protector on Google Cloud Platform (GCP), and the installation procedures. This section focuses on Protegrity specific aspects and should be consumed in conjunction with corresponding Google Cloud documentation.

                          This guide may also be used with the Protegrity Enterprise Security Administrator Guide, which explains the mechanism for managing the data security policy.

                          2.1 - Overview

                          Solution overview and features.

                            Solution Overview

                            The GCP (Google Cloud Platform) BigQuery Protector is a cloud-native, serverless product for fine-grained data protection. This enables the invocation of Protegrity data protection cryptographic methods in cloud-native serverless technology. The benefits of serverless include rapid auto-scaling, performance, low administrative overhead, and reduced infrastructure costs compared to a server-based solution.

                            This product provides integration with Google BigQuery Remote Function. The product is designed to scale elastically and yield reliable query performance under extremely high concurrent loads. During idle use, the serverless product will scale completely down, providing significant savings in Cloud compute fees.

                            Protegrity utilizes a data security policy maintained by an Enterprise Security Administrator (ESA), similar to other Protegrity products. Using a simple REST API interface, authorized users can perform both de-identification (protect) and re-identification (unprotect) operations on data. A user’s individual capabilities are subject to privileges and policies defined by the Enterprise Security Administrator.

                            Analytics on Protected Data

                            Protegrity’s format and length preserving tokenization scheme make it possible to perform analytics directly on protected data. Tokens are join-preserving so protected data can be joined across datasets. Often statistical analytics and machine learning training can be performed without the need to re-identify protected data. However, a user or service account with authorized security policy privileges may re-identify subsets of data using the BigQuery Protector on GCP service.

                            Features

                            BigQuery Protector on GCP incorporates Protegrity’s patent-pending vaultless tokenization capabilities into cloud-native serverless technology. Combined with an ESA security policy, the protector provides the following features:

                            • Role-based access control (RBAC) to protect and unprotect (re-identify) data depending on the user privileges.
                            • Policy enforcement features of other Protegrity application protectors.

                            For more information about the available protection options, such as, data types, Tokenization or Encryption types, or length preserving and non-preserving tokens, refer to Protection Methods Reference.

                            2.2 - Architecture

                            Deployment architecture and connectivity

                              Deployment Architecture

                              The Protegrity product should be deployed in the customer’s Cloud account within the same Google Cloud region as the BigQuery dataset. The product incorporates Protegrity’s vaultless tokenization engine within Google Cloud Functions. The encrypted data security policy from an ESA is deployed periodically as a static resource together with Cloud Function binaries. The policy is decrypted in memory at runtime within the Cloud Function. This architecture allows Protegrity to be highly available and scale very quickly without direct dependency on any other Protegrity services.

                              The product exposes a remote data protection service invoked from external User Defined Functions (UDFs), a native feature of specific Cloud databases. The UDFs can be invoked through direct SQL queries or database views. The external UDF makes parallel API calls to the serverless Protegrity Cloud function to perform protect and unprotect data operations. Each network REST request includes a micro-batch of data to process and a secure context header generated by the database with the username and a Protegrity context header with the data element type, and operation to perform. The product applies the ESA security policy including user authorization and returns a corresponding response. Security operations on sensitive data performed by protector can be audited. The product can be configured to send audit logs to ESA via optional component called Log Forwarder.

                              The security policy is synchronized through another serverless component called the Protegrity Policy Agent. The agent operates on a configurable schedule, fetches the policy from the ESA, performs envelope encryption using Google Key Management Service, and deploys new version of Cloud Function with updated policy. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. There is no downtime for users during this process. Instances provisioned with the function’s previous policy version may continue running (and processing traffic) for several minutes after a deployment has finished.

                              The following diagram illustrates the high-level architecture.

                              The following diagram illustrates a reference architecture for synchronizing the security policy from the ESA to the product.

                              The Protegrity Policy Agent requires network access from GCP to your ESA. Most organizations install the ESA on-premise. Thus, it is recommended to install the Policy Agent in a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

                              The ESA is a soft appliance that must be installed on a separate server. It is used to create and manage security policies.

                              For more information about installing the ESA, and creating and managing policies, refer the Policy Management Section.

                              Audit Log Forwarding Architecture

                              Audit logs are by default sent to Cloud Logging. The Protegrity Product can also be configured to send audit logs to ESA. Such configuration requires deploying Log Forwarder component which is available as part of Protegrity Product deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

                              The log forwarder component includes Pub/Sub service topic and the audit log forwarder function. Pub/Sub service is used to asynchronously send audit records to forwarder function, where similar audit logs are aggregated before sending to ESA. Aggregation rules are described in the Protegrity Log Forwarding guide. When the protector function is configured to send audit logs to log forwarder, audit logs are aggregated on the protector function before sending to Pub/Sub topic. Protector function exposes configuration to control the time it spends aggregating audit logs which is described in the protector function installation section.

                              The security of audit logs is ensured by using HTTPS connection on each link of the communication between protector function and ESA. Integrity and authenticity of audit logs is additionally checked on log forwarder which verifies individual logs signature. The signature verification is done upon arrival from Pub/Sub topic before applying aggregation. If signature cannot be verified, the log is forwarded as is to ESA where additional signature verification can be configured. Log forwarder function uses basic auth and optional certificate verification to authenticate calls to ESA. Basic auth credentials are stored securely in Secret Manager Service.

                              To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instruction can be found in the Audit Log Forwarder Installation.

                              The audit log forwarding requires network access from the cloud to the ESA. Most organizations install the ESA on-premise. Therefore, it is recommended that the Log Forwarder Function is installed into a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

                              BigQuery Connectivity

                              BigQuery invokes Protegrity Cloud Function deployed as an HTTP trigger. Requests are authenticated/authorized using GCP role-based access control. BigQuery uses cloud resource connection to create unique system service account. The service account is used to authenticate/authorize requests to Protect Cloud Function. The following figure illustrates the integration architecture between BigQuery and the Protegrity Cloud Function.

                              BigQuery Cloud Resource Connection

                              The BigQuery Connection API enables users to set up a connection from BigQuery to an external data source. Creating connection requires completing an initial one-time setup to create a connection resource in BigQuery. These steps are provided in the installation.

                              2.3 - Installation

                              Product Installation Guide.

                              2.3.1 - Prerequisites

                              Requirements before installing the protector.

                                Google Cloud Services

                                The following table describes the Google Cloud services that may a part of your Protegrity installation.

                                ServiceDescription
                                Cloud Run FunctionsProvides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates.
                                Key Management ServiceProvides cryptographic keys for envelope encryption/decryption of the policy.
                                Secret Manager ServiceStores secrets required during deployment, e.g., ESA credentials.
                                Cloud Storage ServiceStorage location for the encrypted ESA policy package.
                                Identity and Access ManagementEnforces access policies for deployed resources.
                                Cloud Logging ServiceApplication and audit logs, performance monitoring, and alerts.
                                Cloud VPCRequired for securing network access to On-Prem or cloud-based ESA.
                                Pub/SubProvides a messaging service when forwarding audit logs to ESA is enabled.
                                BIgQuery Connection APIAllows creating connection from BigQuery to Protect Cloud Function.

                                ESA Version Requirements

                                The Protector and Log Forwarder functions require a security policy from a compatible ESA version.

                                The table below shows compatibility between different Protector and ESA versions.

                                Protector VersionESA Version
                                8.x9.09.1 & 9.210.0
                                2.xNoYes*No
                                3.0.x & 3.1.xNoNoYesNo
                                3.2.xNoNoYes*
                                4.0.xNoNoNoYes

                                Legend

                                Yes

                                Protector was designed to work with this ESA version

                                No

                                Protector will not work with this ESA version

                                *

                                Backward compatible policy download supported:

                                • Data elements and features which are common between this and previous ESA versions will be downloaded
                                • Data elements and features which are new to this ESA version and do not exist in previous ESA version will not be downloaded

                                Prerequisites

                                RequirementDetail
                                Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
                                Protegrity ESA 10.0+The Cloud VNet must be able to obtain network access to the ESA
                                Google Cloud AccountRecommend creating a new project for Protegrity Serverless
                                Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

                                Required Skills and Abilities

                                RequirementsDescription
                                GCP Cloud AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
                                Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

                                2.3.2 - Pre-Configuration

                                Configuration steps prior product installation.

                                  Google Cloud Project

                                  Identify or create a new Google Cloud Project where the Protegrity solution will be installed. It is recommended to create a new project. This provides greater security controls and avoids conflicts with other applications that might impact regional account limits. An individual with the Owner role will be required for some of the subsequent installations.

                                  Google Project ID: ___________________

                                  Google Project Number: ___________________

                                  Google Cloud Region: ___________________

                                  Key Management Service

                                  The Google Cloud Key Management Service (KMS) provides Protegrity Serverless solution the ability to encrypt and decrypt the Protegrity Security Policy.

                                  To create KMS Key Ring and Asymmetric Encryption Master Key:

                                  1. Log in to Google Account and select project where Protegrity service will be installed.

                                  2. Navigate to Security > Key Management.

                                  3. Select Create key ring.

                                  4. Specify key ring name. For example, protegrity-policy-keyring.

                                  5. select Key ring location which corresponds to the region where Protegrity solution will be installed.

                                  6. Select Create.

                                  7. Select CREATE KEY to create encryption key.

                                  8. Specify key name. For example, protegrity-policy-key.

                                  9. under Purpose selection, select Asymmetric Decrypt .

                                  10. Select Key Algorithm. For example, 3072-bit RSA with OAEP Padding and SHA256 digest.

                                  11. Select Create.

                                  12. Once the key is created, a screen opens on the key. If the screen does not appear, click on the key name.

                                  13. Then click on the elipses under Actions that is next to the key version.

                                  14. Select Copy Resource Name and record the value below, e.g., projects/{project-id}/locations/region/keyRings/{key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                    Policy Encryption Key Version Resource Name: ___________________

                                  Google Cloud Storage

                                  Cloud Storage buckets are required for the Gen 2 Cloud Function sources, the Terraform backend, and the deployment of the Protegrity installation artifacts. It is recommended that you create 3 separate buckets to separate files used for different purposes. If you cannot create 3 separate buckets, you may reuse a bucket for multiple purposes.

                                  Create the buckets:

                                  1. Run the cloud command below to enable the Google Storage Transfer API.

                                    gcloud services enable storagetransfer.googleapis.com
                                    
                                  2. Create the Gen 2 Cloud Function sources bucket. This bucket is not required if you will be deploying to Gen 1 Cloud Functions. The bucket name much match the example below. Replace the <gcp-project-number> and <region> placeholders.

                                    gcf-v2-sources-<gcp-project-number>-<region>
                                    

                                    Use the following gcloud command to obtain project number

                                    gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
                                    
                                  3. Create the deployment bucket or reuse an existing bucket. This bucket is used during the installation process to store the Protegrity installation artifacts.

                                    Deployment Bucket Name:___________________

                                  4. Create the Terraform backend bucket or reuse an existing bucket. This bucket is used by Terraform to store information about your Cloud Protect installation, and will be used if you upgrade to a later version of Cloud Protect in the future.

                                    Terraform Backend Bucket Name:___________________

                                  Cloud Functions Service Accounts

                                  Cloud Functions use the service accounts created in this deployment. You can create Service accounts manually or use the Protegrity Terraform installation script to create one. Each service account requires specific permissions, which must be granted through IAM roles. Run the following steps to create service accounts and configure the required IAM access. If you use Terraform scripts, skip these steps.

                                  Agent Function IAM Role

                                  To create Agent Function IAM Role:

                                  1. Log in to Google Account and select project where Protegrity service will be installed.

                                  2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                  3. Specify role name and description.

                                  4. Select ADD PERMISSIONS.

                                  5. Select the following permissions:

                                    • cloudkms.cryptoKeyVersions.useToEncrypt
                                    • cloudkms.cryptoKeyVersions.viewPublicKey
                                    • secretmanager.versions.access
                                    • storage.objects.get
                                    • storage.objects.create
                                    • storage.objects.delete
                                    • storage.objects.list
                                    • storage.objects.update
                                    • storage.buckets.get
                                    • cloudfunctions.functions.get
                                    • cloudfunctions.functions.update
                                    • cloudfunctions.functions.sourceCodeGet
                                    • cloudfunctions.functions.sourceCodeSet
                                    • iam.serviceAccounts.actAs
                                  6. Click Add and then Create.

                                  Alternatively, you can run the following command from the Cloud Shell Terminal.

                                        gcloud iam roles create role-id \
                                        --project=project-id \
                                        --title=role-title \
                                        --description=role-description \
                                        --permissions=cloudkms.cryptoKeyVersions.useToEncrypt,\
                                        cloudkms.cryptoKeyVersions.viewPublicKey,\
                                        secretmanager.versions.access,\
                                        storage.objects.get,\
                                        storage.objects.create,\
                                        storage.objects.delete,\
                                        storage.objects.list,\
                                        storage.objects.update,\
                                        storage.buckets.get,\
                                        cloudfunctions.functions.get,\
                                        cloudfunctions.functions.update,\
                                        cloudfunctions.functions.sourceCodeGet,\
                                        cloudfunctions.functions.sourceCodeSet,\
                                        iam.serviceAccounts.actAs \
                                        --stage=GA 
                                        
                                  
                                  • role-id

                                    is the name of the role, such as ptyProtectRole.

                                  • project-id

                                    is the name of the project, such as my-project-id.

                                  • role-description

                                    is a short description of the role, such as “My custom role description”.

                                  Sample output:

                                  
                                        Created role [role-id]. 
                                        description: role-description 
                                        etag: *****************
                                        includedPermissions: 
                                        - cloudfunctions.functions.get 
                                        - cloudfunctions.functions.sourceCodeGet 
                                        - cloudfunctions.functions.sourceCodeSet 
                                        - cloudfunctions.functions.update 
                                        - cloudkms.cryptoKeyVersions.useToEncrypt 
                                        - cloudkms.cryptoKeyVersions.viewPublicKey 
                                        - iam.serviceAccounts.actAs 
                                        - secretmanager.versions.access 
                                        - storage.buckets.get 
                                        - storage.objects.create 
                                        - storage.objects.delete 
                                        - storage.objects.get 
                                        - storage.objects.list 
                                        - storage.objects.update 
                                        name: projects/{project-id}/roles/{role-id} 
                                        stage: GA 
                                        title: role-title
                                        
                                  

                                  Agent Service Account

                                  To create Agent Service Account:

                                  1. Log in to Google Account and select project where Protegrity service will be installed.

                                  2. Navigate to IAM & Admin > Service Accounts.

                                  3. Select CREATE SERVICE ACCOUNT.

                                  4. Specify service account name and description.

                                  5. Select Create and Continue.

                                  6. In the next step, click Select Role.

                                  7. Select Custom and select the role created above .

                                  8. Click Done.

                                  9. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                  10. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com

                                    Agent Function Service Account Email: ___________________

                                  Protect Function IAM role

                                  To create Protect Function IAM role:

                                  1. Log in to Google Account and select project where Protegrity service will be installed.

                                  2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                  3. Specify role name and description.

                                  4. Select ADD PERMISSIONS.

                                  5. Select the cloudkms.cryptoKeyVersions.useToDecrypt permission.

                                  6. Click Add and then Create.

                                  Protect Service Account

                                  To create Protect Service Account:

                                  1. Log in to Google Account and select the project where Protegrity service will be installed.

                                  2. Navigate to IAM & Admin > Service Accounts.

                                  3. Select CREATE SERVICE ACCOUNT.

                                  4. Specify service account name and description.

                                  5. Select Create and Continue.

                                  6. In the next step, click Select Role. Then select Custom and select the role created above .

                                  7. Click Done.

                                  8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                  9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                    Protect Function Service Account Email: ___________________

                                  2.3.3 - Protect Service Installation

                                  Product Installation Guide.

                                    Preparation

                                    1. Ensure that all the steps in pre-configuration are performed.

                                    2. Log in to the Google Cloud account where Protegrity will be installed.

                                    3. Select the project.

                                    4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                    5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                    Install Protect Function via Terraform Scripts

                                    Resources created with Terraform scripts include Protect Cloud Functions Service and other required resources depending on Terraform parameters. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                                    To install using Terraform:

                                    1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                                    2. Unzip the bundle. Verify that the following files are available:

                                      • pty-protect-gcp/
                                      • main.tf
                                      • outputs.tf
                                      • protegrity-cloud-api-gcp-{version}.zip
                                      • README.md
                                    3. Unzip the protegrity-cloud-protect-gcp-{version}.zip file. Verify that the following files are available:

                                      • pty-protect-gcp/
                                      • main.tf
                                      • outputs.tf
                                      • protegrity-cloud-protect-gcp-{version}.zip
                                      • README.md
                                    4. Open the main.tf file and update Terraform backend information at the top of the file:

                                      
                                      terraform {
                                        backend "gcs" {
                                          bucket  = ""
                                          prefix  = "protegrity/terraform/pty-protect-gcp/state"
                                        }
                                      }
                                      
                                    5. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                                      ParameterDescription
                                      project_idThe project id recorded in the pre-configuration step
                                      regionThe Region recorded in the pre-configuration step.
                                      deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                      deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                      deployment_bucket_locationGeographical location of deployment bucket, e.g., US, EU, ASIA.
                                      deployment_file_directory_pathPath to directory where deployment zip file is located. By default the deployment file should be in the same directory as this main.tf file.
                                      create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                      protect_function_service_account_emailUse Protect Function Service account recorded in pre-configuration or leave empty.
                                      min_log_levelMinimum log level for log forwarder function. One of off|severe|warning|info|config|all. Defaults to ‘severe’
                                      pty_log_outputAudit log output. Accepted values: “"(empty string), “pub_sub”.
                                      audit_log_flush_intervalTime interval in seconds used to accumulate audit logs before sending to Pub/Sub topic. Default value: 30, Min value: 1, Max value: 900
                                      pty_pub_sub_topicPub/Sub topic where audit logs will be sent.
                                      username_regexIf username_regex is set, the effective policy user will be extracted from the user in the request.
                                      max_instance_countGCP Cloud Functions advanced configuration
                                      available_memory_mbGCP Cloud Functions advanced configuration
                                      timeout_secondsGCP Cloud Functions advanced configuration
                                      gen2_available_cpu2nd Gen Cloud Function advanced configuration
                                      gen2_container_concurrency2nd Gen Cloud Function advanced configuration
                                      upgrade_stepSet this variable when upgrading to the latest version.
                                      labelsYou can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to Labeling Resources. For example, only use lowercase and maximum length of 63 characters.
                                    6. From local command line or Cloud Shell, change directory to location of the main.tf, for example: protegrity-gcp-bigquery-{version}/pty-protect-gcp/

                                    7. Run the following command.

                                      terraform init
                                      
                                    8. Terraform will download necessary providers.

                                    9. Run the following command to verify configuration and print out deployment plan.

                                      terraform plan
                                      
                                    10. Run the following command to deploy resources to your account.

                                      terraform apply
                                      
                                    11. Once deployment is complete Terraform will print output variables.

                                    12. Record the following values:

                                    • protect_function_name: ________________________________
                                    • protect_function_url: __________________________
                                    • api_gateway_managed_service: _____________________________
                                    • api_gateway_protect_service_url: ____________________
                                    • protect_function_resource_name: _______________________

                                    Test Protect Function Installation

                                    Before continuing with next steps, you can verify whether Cloud Functions are installed correctly. This step is optional and can be skipped.

                                    1. Below you can find example Linux curl command to test your function.

                                    2. Before you can execute it, you need to obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the Cloud Run Invoker Role (roles/run.invoker) role. Record the output of print identity token command.

                                      gcloud_auth_token: _________________

                                    3. Replace {protect_function_url} with value recorded in previous step.

                                    4. Replace {gcloud_auth_token} with value recorded in above step.

                                    5. Run the following CURL command to test Function deployment.

                                      curl -X POST "{protect_function_url}" \
                                        -H 'Authorization:Bearer {gcloud_auth_token}' \
                                        -d '{
                                          "caller": "bigquery.googleapis.com/projects/my-project-id/jobs/123456",
                                          "requestId": "124ab1c",
                                          "sessionUser": "test-user@test-company.com",
                                          "userDefinedContext": {
                                            "data_element": "alpha",
                                            "op_type": "unprotect"
                                          },
                                          "calls": [
                                            [
                                              "UtfVk UHgcD!"
                                            ]
                                          ]
                                        }'
                                      
                                    6. Verify the following output:

                                      {"replies":["hello world!"]}
                                      

                                    2.3.4 - Policy Agent Installation

                                    Install the policy agent.

                                      Policy Agent Function installation is done via Terraform scripts provided by Protegrity. Before running the template, some resources must be created manually.

                                      ESA Server

                                      Policy Agent function requires ESA server running and accessible from Agent Cloud Function on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted.

                                      Note down ESA IP address:

                                      ESA IP Address (EsaIpAddress): ___________________

                                      Certificates on ESA

                                      By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Cloud Function Environment variables configuration.

                                      In case ESA is configured with publicly signed certificates, this section can be skipped since the Cloud Function will use public CA to validate ESA certificates.

                                      To obtain self-signed CA certificate from ESA:

                                      1. Log in to ESA Web UI.

                                      2. Select Settings > Network > Manage Certificates.

                                      3. Hover over Server Certificate and click on download icon to download the CA certificate.

                                      4. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                        To escape new lines from command line, use one of the following commands depending on your operating system:

                                        Linux Bash:

                                        awk 'NF {printf "%s\\n",$0;}' ProtegrityCA.pem > output.txt
                                        

                                        Windows PowerShell:

                                        (Get-Content '.\ProtegrityCA.pem') -join '\n' | Set-Content 'output.txt'
                                        
                                      5. Record the certificate content with new lines escaped.

                                        ESA CA Server Certificate (EsaCaCert): ___________________

                                        This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section.

                                      For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                      Identify or Create a new VPC

                                      Google Cloud VPC is used to route traffic from Policy Agent Cloud Function to ESA. If your ESA is in a Google Cloud VPC, it is recommended to create a serverless VPC access and record its name:

                                      google_vpc_access_connector_name: ___________________

                                      If ESA is not on Google Cloud VPC, you can either create one or choose to let Terraform script to create one. The Terraform script will create the following elements:

                                      • NAT gateway

                                        To connect to ESA outside the Google Cloud Network

                                      • External IP address

                                        Can add it to the allowlist by the firewall in the network environment where ESA is hosted.

                                      • Serverless VPC access

                                        Allows connectivity from the Cloud function to the VPC.

                                      Creating ESA Credentials

                                      Policy Agent Function requires ESA credentials to be provided as one of the two options:

                                      Secret Manager

                                      Secret Manager is the recommended option for storing ESA credentials.

                                      Create ESA credentials secrets:

                                      1. Log in to Google Account and select project where Protegrity service will be installed.

                                      2. Go to Security > Secret Manager.

                                      3. Select CREATE SECRET.

                                      4. Specify the Secret Value:

                                        {
                                          "username": "{esa_username}", 
                                          "password": "{esa_password}"
                                        }
                                        
                                      5. Select Create Secret.

                                      6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                      7. Click on Actions, next to the secret version you just created.

                                      8. Select Copy Resource ID and record the full secret version path, For example, projects/{project-id}/secrets/{secret name}/versions/2.

                                        Secret resource id: ___________________

                                      Custom Cloud Function

                                      If you have the skills to write code, you may provide a custom Cloud Function that returns the ESA credentials to the Policy Agent. One use case is when reading the ESA credentials from a third-party password vault.

                                      Create the Cloud Function:

                                      1. Create a new 2nd gen Cloud Function using any runtime.

                                        1. The Policy Agent does not provide an input payload.

                                        2. The Cloud Function must return a response according to the following schema:

                                          response: 
                                            type: object 
                                              properties: 
                                                username: string 
                                                password: string
                                          

                                          For example,

                                          example output: {"username": "admin", "password": "Password1234"} 
                                          
                                        3. Sample GCP Function in Python:

                                          def handler(request): 
                                              return {"username": "admin", "password": "password1234"} 
                                          
                                      2. Grant the Cloud Run Invoker role to the Policy Agent function service account.

                                      3. Grant the cloudfunctions.functions.get permission to the Policy Agent function service account role.

                                      4. Record the Function name:

                                        ESA CREDENTIALS FUNCTION NAME: _______________

                                      Install Policy Agent Function through Terraform Scripts

                                      Agent Terraform scripts provided by Protegrity create a Cloud Function in your Google account. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can also create the following optional resources by specifying the corresponding parameters:

                                      • Service account with IAM role
                                      • VPC with NAT external IP
                                      • VPC access connector

                                      To install Policy Agent Function through Terraform:

                                      1. From command shell, move to the directory where you downloaded Protegrity installation bundle.

                                      2. Unzip the bundle, then unzip the protegrity-agent-gcp-{version}.zip. Verify that the following files are available:

                                        • pty-agent-gcp/
                                        • main.tf
                                        • outputs.tf
                                        • README.md
                                      3. Open the main.tf file and update Terraform backend information at the top of the file:

                                        
                                        terraform {
                                          backend "gcs" {
                                            bucket  = ""
                                            prefix  = "protegrity/terraform/pty-protect-gcp/state"
                                          }
                                        }
                                        
                                      4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                      5. Set the prefix property with value unique to your deployment.

                                      6. In the same main.tf file, specify the following Terraform variables.

                                        ParameterDescription
                                        project_idThe Project ID recorded in the pre-configuration step
                                        regionThe Region recorded in the pre-configuration step, for example, us-central1.
                                        deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                        deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                        deployment_bucket_locationGeographical location of deployment bucket, e.g., US, EU, ASIA.
                                        deployment_file_directory_pathPath to directory where deployment zip file is located. By default the deployment file should be in the same directory as this main.tf file.
                                        policy_download_cron_expressionCron expression determining how often policy agent function will run to synchronize security policy from ESA.
                                        create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                        agent_function_service_account_emailUse Agent Function Service account recorded in pre-configuration or leave empty.
                                        create_vpcSet this to true, if you would like to create VPC with NAT, external IP and vpc access connector, otherwise leave empty. This will be ignored if google_vpc_access_connector_name is specified.
                                        google_vpc_access_connector_nameSpecify the existing VPC access connector name you identified in earlier step, otherwise leave empty. This setting will disable create_vpc = true.
                                        google_vpc_access_connector_full_resource_nameAlternative configuration for VPC access connector. If this parameter is set the google_vpc_access_connector_name will be ignored. Use this parameter, if vpc connector is in different region/project that the one specified for the deployment.
                                        labelsYou can set this map to include labels for deployed resources. Pay attention to gcp label requirements. More information in: https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

                                        All the values were recorded in Pre-Configuration and this section’s previous steps.

                                      7. Provide Policy update Terraform variables. In the same main.tf file, you can specify configuration related to policy update. Any of these variables can be updated at any given time by running the terraform again or directly in the GCP Console. Most of the values were recorded in previous installation steps.

                                        Parameter

                                        Description

                                        Notes

                                        pty_esa_ip

                                        ESA IP address or hostname

                                        ESA Server

                                        pty_esa_ca_server_cert

                                        ESA self-signed CA certificate used by policy Agent Function to ensure ESA is the trusted server.

                                        Recorded in step Certificates on ESA

                                        In case ESA is configured with publicly signed certificates, the pty_esa_ca_server_cert configuration will be ignored.

                                        gcp_esa_credentials_secret_resource_id

                                        ESA username and password (encrypted value by Google Cloud Secrets Manager). For example, projects/{project-id}/secrets/{secret name}/versions/{version}

                                        Creating ESA Credentials

                                        pty_esa_credentials_function

                                        ESA credentials GCP function resource name. For example, projects/{project-name}/locations/{region}/functions/{esa-credentials-function-name}.

                                        Recorded in step Option 2: Custom Cloud Function ESA CREDENTIALS FUNCTION NAME. Presence of gcp_esa_credentials_secret_resource_id will cause this value to be ignored. The Policy Agent Function must have network access and IAM permissions to call the ESA Credentials function you have created in Option 2: Custom Cloud Function.

                                        gcp_kms_key_resource_name

                                        The Key full resource name. For Example, projects/{project-id}/locations/region/keyRings/ {key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                        Key Management Service

                                        gcp_protect_function_resource_name

                                        List of comma separated Protect function resource names. For Example, projects/{project-id}/ locations/{region}/functions/{function-name1},projects/{project-id}/ locations/{region}/functions/{function-name2}

                                        Use protect_function_resource_name recorded in Protect Service Installation section.

                                        gcp_policy_retention_storage_bucket

                                        Deployment Bucket Name where the encrypted policy will be written.

                                        You can use deployment bucket recorded in Google Cloud Storage section, or you can specify other existing bucket.

                                        gcp_policy_version_object_key

                                        Filename of the encrypted policy stored in the Deployment Bucket Name

                                        Default: policy.zip

                                        retain_policy_versions

                                        Number of policy versions to retain as backup. (e.g. 2 will retain the latest 2 policies and remove older ones). -1 retains all.

                                        Default: 10

                                        disable_deploy

                                        This flag can be either 1 or 0. If set to 1, then the agent will not update protector function with the newest policy. Else, the policy will be saved in the cloud storage bucket and deployed to the protector function.

                                        Default: 0

                                        log_level

                                        Application and audit logs verbiage level

                                        Default: INFO. Allowed values: DEBUG – the most verbose INFO, WARNING, ERROR – the least verbose

                                        policy_pull_timeout

                                        Time in seconds to wait for the ESA to send the full policy

                                        Default: 20

                                        pty_core_casesensitive

                                        Specifies whether policy usernames should be case sensitive

                                        Default: no. Allowed values: yes, no

                                        pty_core_emptystring

                                        Override default behavior. Empty string response values are returned as null values. For instance, (un)protect(’’) -> null (un)protect(’’) -> ''

                                        Default: empty. Allowed values: null, empty

                                        esa_connection_timeout

                                        Time in seconds to wait for the ESA response

                                        Default: 5s

                                        pty_addipaddressheader

                                        When enabled, agent will send its source IP address in the request header. This configuration works in conjunction with ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP (default=false). See Associating ESA Data Store With Cloud Protect Agent for more information.

                                        Default: yes. Allowed values: yes, no

                                        pty_datastore_key

                                        ESA policy datastore public key fingerprint (64 char long) e.g. 123bff642f621123d845f006c6bfff27737b21299e8a2ef6380aa642e76e89e5.

                                        The export key is the public part of an asymmetric key pair created in a Create KMS Key. A user with Security Officer permissions adds the public key to the data store in ESA via Policy Management > Data Stores > Export Keys. The fingerprint can then be copied using the Copy Fingerprint icon next to the key. Refer to Exporting Keys to Datastore for details.

                                        pty_sync_datastore

                                        Optional name of the policy datastore to sync with ESA. Refer to ESA documentation for more information on policy datastore sync.

                                        Default: ""
                                      8. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                        protegrity-agent-gcp-{version}/pty-agent-gcp/
                                        
                                      9. Run terraform init.

                                        Terraform will download necessary providers.

                                      10. Run terraform plan to verify configuration and print out deployment plan.

                                      11. Run terraform apply to deploy resources to your account. Once deployment is complete, Terraform will print output variables.

                                      12. Below is the sample output from successful deployment.

                                        
                                                Apply complete! Resources: 1 added, 0 changed, 0 destroyed. 
                                                Outputs: 
                                                agent_function_service_account_email = "pty-agent-test@test.iam.gserviceaccount.com" 
                                                deployment_bucket_name = "test-bucket" 
                                                nat_ip = 0 
                                                policy_agent_function_deployment_object = "pty-agent-test-1.0.1.zip" 
                                                policy_agent_function_name = "pty-agent-test" 
                                        

                                      Test Agent Function Installation

                                      After configuration is complete, you can test the function.

                                      To test and run the Policy Agent Function:

                                      1. From the Google Cloud console, go to Cloud Run Functions or Cloud Run.

                                      2. Click on the function you just deployed: pty_agent_{deployment_id}.

                                      3. Click Test button at the top right section of the screen.

                                      4. Scroll down to CLI test command.

                                      5. Copy and run the curl command to trigger the agent. Alternatively, use the option Test in Cloud Shell.

                                      6. Wait for the function to complete.

                                      7. Navigate to the LOGS tab to view agent execution logs.

                                      8. Alternatively, you may review the logs by navigating to Logging from your Google Console. In the Log Explorer select the All resources dropdown, then Cloud Run Revision > pty-agent-{deployment-id} and apply.

                                        
                                        Function execution took 23892 ms, finished with status: 'ok'
                                        iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_21-00-00.zip]
                                        iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_19-03-23.zip]
                                        iap.policy_deployer:INFO:Removing old function versions in [test-artifacts]. Will retain [1] versions.
                                        iap.policy_deployer:INFO:Updating function [projects/cloud-engineering-315519/locations/us-central1/functions/pty-protect-test] with new deployment artifact [test-artifacts/policy_v07-26-2021_21-00-01.zip] ...
                                        iap.imp_creator:INFO:Uploading encrypted policy data to: [test-artifacts/policy_v07-26-2021_19-03-23.zip]
                                        iap.imp_creator:INFO:Preparing deployment package ...
                                        iap_agent_gcp.cloud_functions_util:INFO:Downloading function deployment package ...
                                        iap.imp_creator:INFO:Encrypting policy package ...
                                        iap.policy_agent:INFO:Preparing new policy deployment ...
                                        iap.policy_agent:WARNING:Current policy deployment has no checksum_mapping metadata:
                                        iap.imp_creator:INFO:Checking current policy version ...
                                        iap.policy_agent:INFO:Current deployment package version: [policy_v07-26-2021_18-51-43.zip].
                                        iap.policy_agent:INFO:Getting current policy metadata ...
                                        iap.imp_creator:INFO:Policy downloaded successfully ...
                                        iap.imp_creator:INFO:PepServer started ...
                                        iap.imp_creator:INFO:Starting PepServer ...
                                        iap.imp_creator:INFO:PepServer configured successfully
                                        iap.imp_creator:INFO:Downloading certificates from ESA ...
                                        iap.imp_creator:INFO:Configuring PepServer ...
                                        iap.policy_agent:INFO:Starting policy agent ...
                                        iap.policy_agent:INFO:Using Secret Manager [GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID] to retreive ESA credentials.
                                        iap.policy_agent:INFO:PTY_CORE_CASESENSITIVE [no]
                                        iap.policy_agent:INFO:PTY_CORE_EMPTYSTRING [empty]
                                        iap.policy_agent:INFO:RETAIN_POLICY_VERSIONS [1]
                                        iap.policy_agent:INFO:GCP_PROTECT_FUNCTION_RESOURCE_NAME [projects/test/locations/us-central1/functions/pty-protect-test]
                                        iap.policy_agent:INFO:GCP_POLICY_VERSION_OBJECT_KEY [policy.zip]
                                        iap.policy_agent:INFO:GCP_POLICY_RETENTION_STORAGE_BUCKET [test-artifacts]
                                        iap.policy_agent:INFO:GCP_KMS_KEY_RESOURCE_NAME [projects/test/locations/us-central1/keyRings/test-key-ring/cryptoKeys/test-protect-asymmetric/cryptoKeyVersions/1]
                                        iap.policy_agent:INFO:GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID [projects/1234/secrets/ESA_ADMIN_CREDENTIALS/versions/2]
                                        iap.policy_agent:INFO:PTY_ESA_IP [54.236.107.39]
                                        iap.policy_agent:INFO:POLICY_PULL_TIMEOUT [20]
                                        iap.policy_agent:INFO:DISABLE_DEPLOY [0]
                                        Function execution started
                                        

                                      Troubleshooting

                                      Configure additional logging:

                                      1. Set log_level Terraform variable on the Agent function to DEBUG.

                                      2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                        resource.type="cloud_run_revision"
                                        resource.labels.service_name=~"pty-agent-<deploymentd-id>"
                                        severity=ERROR OR textPayload=~"\[error\]"
                                        -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                        
                                      3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                      Error message

                                      Details

                                      iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Resource 'projects/<account>/locations/<region>/functions/protegrity-protect-<deployment-id>' was not found
                                      
                                      This error may indicate the following configuration issues:
                                      1. The function name indicated in setting gcp_protect_function_resource_name has been provided incorrectly, and thus cannot be found.
                                      2. disable_deploy has been set, and a dummy function has been entered to work around the gcp_protect_function_resource_name requirement. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate.
                                      [ERROR] policy_agent:Invalid GCP_PROTECT_FUNCTION_RESOURCE_NAME parameter value. Must be a comma separated list of Lambda Function names or ARNs.
                                      
                                      This error may indicate the following configuration issues:
                                      1. The setting gcp_protect_function_resource_name is empty. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate, this setting may not be left empty.
                                      2. The list of function names provided to gcp_protect_function_resource_name contains invalid function name or is not valid csv format.
                                      [ERROR] iap_agent_gcp.cloud_functions_util:<HttpError 403 when requesting https://cloudfunctions.googleapis.com/v2/projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>:generateDo
                                      wnloadUrl?alt=json returned "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/<deployment-id>'". Details: "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'">
                                      [ERROR] policy_agent:Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'
                                      ...
                                      iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>' 
                                      

                                      Indicates the Agent Cloud Run function’s identity does not have permissions to sourceCodeGet for Protect/Log Forwarder function(s) provided to the gcp_protect_function_resource_name configuration.

                                      2.3.5 - Audit Log Forwarder Installation

                                      Install the audit log forwarder.

                                          Audit Log Forwarder installation is done via Terraform scripts provided by Protegrity in the installation bundle.

                                          ESA Audit Store Configuration

                                          ESA server is required as the recipient of audit logs. Verify the information below to ensure ESA is accessible and configured properly.

                                          1. ESA server running and accessible on TCP port 9200.

                                          2. Audit Store service is configured and running on ESA. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                          Certificates on ESA

                                          By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Log Forwarder configuration.

                                          In case ESA is configured with publicly signed certificates, this section can be skipped since the Log Forwarder will use public CA to validate ESA certificates.

                                          To obtain self-signed CA certificate from ESA:

                                          1. Download ESA CA certificate from the /etc/ksa/certificates/plug directory of the ESA

                                          2. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                            To escape new lines from command line, use one of the following commands depending on your operating system:

                                            Linux Bash:

                                            awk 'NF {printf "%s\\n",$0;}' CA.pem > output.txt
                                            

                                            Windows PowerShell:

                                            (Get-Content '.\CA.pem') -join '\n' | Set-Content 'output.txt'
                                            
                                          3. Record the certificate content with new lines escaped.

                                            ESA CA Server Certificate (EsaCaCert): ___________________

                                            This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section. Install Log Forwarder via Terraform

                                          For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                          VPC configuration

                                          Similar to Policy Agent Function, log forwarder function requires Google Cloud VPC to route traffic from the function to ESA. Review the VPC configuration steps for agent in section Identify or Create a new VPC. Same VPC connector as the policy agent can be used. Note down VPC connector name:

                                          google_vpc_access_connector_name: ___________________

                                          ESA Authentication

                                          Audit Log Forwarder must authenticate with ESA using certificate-based authentication with client certificate and certificate key. Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                          File NameDescription
                                          client.keyClient certificate key
                                          client.pemClient certificate (PEM)

                                          Both certificate and certificate key must be converted to single-line values using code similar to the following examples.

                                          Client certificate (client.pem):

                                          $folder = 'C:\Temp'
                                          cd $folder
                                          (Get-Content "$folder\client.pem") -join '\n' | Set-Content "$folder\one-liner-client.pem"
                                          cat "$folder\one-liner-client.pem"
                                          
                                          folder="/tmp"
                                          cd "$folder"
                                          awk 'NF {printf "%s\\n",$0}' "client.pem" > "one-liner-client.pem"
                                          cat "one-liner-client.pem"
                                          

                                          Client certificate key (client.key):

                                          $folder = 'C:\Temp'
                                          cd $folder
                                          (Get-Content "$folder\client.key") -join '\n' | Set-Content "$folder\one-liner-client.key"
                                          cat "$folder\one-liner-client.key"
                                          
                                          folder="/tmp"
                                          cd "$folder"
                                          awk 'NF {printf "%s\\n",$0}' "client.key" > "one-liner-client.key"
                                          cat "one-liner-client.key"
                                          

                                          While installing using Terraform template:

                                          1. Provide single-line client certificate for pty_esa_client_cert
                                          2. Provide ID of the GCP secret containing the single-line certificate key for pty_esa_client_cert_key_secret_id Secret is created in a later step

                                          Configure ESA Secrets In GCP Secret Manager

                                          Audit Log Forwarder Function uses GCP Secret Manager to store ESA Audit Store credentials used during authentication.

                                          For information on how to configure basic and certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                          2. Go to Security > Secret Manager.

                                          3. Select CREATE SECRET.

                                          4. Specify the Secret Value:

                                            {
                                              "username": "admin", 
                                              "password": "{esa_password}"
                                            }
                                            
                                          5. Select Create Secret.

                                          6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                          7. Click on Actions, next to the secret version you just created.

                                          8. Select Copy Resource ID and record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/2.

                                            ESA Log Forwarder Credentials Secret Name: _________________

                                          9. Create another secret with single-line contents of ESA client certificate key file

                                            See Certificate Authentication for details on client certificate key

                                          10. Record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/1.

                                            ESA Log Forwarder Client Certificate Key Secret Name: _________________

                                          Create Log Forwarder Service Account

                                          To create Log Forwarder Service Account:

                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                          2. Navigate to IAM & Admin > Service Accounts.

                                          3. Select CREATE SERVICE ACCOUNT.

                                          4. Specify service account name and description.

                                          5. Select Create and Continue.

                                          6. In the next step, click Select Role. Then select the following roles:

                                            • Cloud KMS CryptoKey Decrypter
                                            • Pub/Sub Publisher
                                            • Secret Manager Secret Accessor
                                          7. Click Done.

                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                            Log Forwarder Function Service Account Email: ___________________

                                          Create Service Account For Forwarder Pub/Sub

                                          Pub/Sub service requires Cloud Run Invoker permissions in order to be able to send messages to the Forwarder function.

                                          1. Log in to Google Account and select the project where Protegrity forwarder will be installed.

                                          2. Navigate to IAM & Admin > Service Accounts.

                                          3. Select CREATE SERVICE ACCOUNT.

                                          4. Specify service account name and description.

                                          5. Select Create and Continue.

                                          6. In the next step, click Select Role. Then select Cloud Run Invoker.

                                          7. Click Done.

                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                            Pub/Sub Log Forwarder Service Account Email: ___________________

                                          Preparation

                                          1. Ensure that all the steps in Google Cloud Project are performed.

                                          2. Log in to the Google Cloud account where Protegrity will be installed.

                                          3. Select the project.

                                          4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                          5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                          Install Log Forwarder Function via Terraform Scripts

                                          Resources created with Terraform scripts include Audit Log Forwarder Cloud Functions Service and Pub/Sub topic. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                                          To install using Terraform:

                                          1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                                          2. Unzip the bundle, then unzip the protegrity-gcp-bigquery-{version}.zip. Navigate to pty-log-forwarder-gcp/. Verify that the following files are available:

                                            • pty-log-forwarder-gcp/
                                            • main.tf
                                            • outputs.tf
                                            • protegrity-cloud-api-gcp-{version}.zip
                                            • README.md
                                          3. Open the main.tf file and update Terraform backend information at the top of the file:

                                            terraform {
                                              backend "gcs" {
                                                bucket  = ""
                                                # The bucket/prefix combination must be unique for different deployments 
                                                # to avoid conflicting Terraform states and accidental resources destruction.
                                                # prefix = "protegrity-gcp-bigquery/forwarder/<deployment_id>/tf-state"
                                              }
                                            }
                                            
                                          4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                          5. Set the prefix property with value unique to your deployment.

                                          6. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                                            ParameterDescription
                                            project_idThe project id recorded in the pre-configuration step
                                            regionThe Region recorded in the pre-configuration step.
                                            deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                            deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                            create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                            forwarder_function_service_account_emailUse Forwarder Function Service account recorded in pre-configuration or leave empty.
                                            pub_sub_log_forwarder_service_account_emailService account of the audit log Pub/Sub trigger. The service account must be assigned Cloud Run Invoker (roles/run.invoker) role.
                                            create_vpcIf create_vpc flag is set, new vpc will be created together with vpc connector, NAT and external IP Use this flag if you have VPC admin permissions in your Google Account. If you set it to false, you can specify the existing VPC in the google_vpc_access_connector_name parameter.
                                            google_vpc_access_connector_nameUse existing VPC connector to associate with Log Forwarder Function. You can specify either the VPC connector name or the full resource name if vpc connector is in different region/project that the one specified for the deployment. You can alternatively set the use google_vpc_access_connector_full_resource_name. Both parameters are optional. Full resource name takes precedence over connector name.
                                            log_destination_esa_ipIp address of the ESA where Protector logs will be sent to.
                                            pty_esa_ca_server_certESA self-signed CA certificate used by log forwarder function to ensure ESA is the trusted server. See documentation for more details.
                                            esa_credentials_secret_resource_idGCP Secret Manager secret id where ESA Fluent Bit logger credentials are stored.
                                            pty_esa_client_certSingle-line ESA client certificate content. See Certificate Authentication for details on client certificate
                                            pty_esa_client_cert_key_secret_idGCP Secret Manager secret id where single-line ESA client certificate key content is stored. See Configure ESA Secrets In GCP Secret Manager for details on client certificate key secret
                                            min_log_levelMinimum log level for log forwarder function. Must be one of the following: [off,severe,warning,info,config,all].
                                            esa_tls_disable_cert_verifyDisable certificate verification when connecting to ESA. This is only for dev purposes, should not be used in production environment.
                                            esa_connect_timeoutEsa connection timeout in seconds.
                                            esa_virtual_hostESA Virtual Host.
                                            audit_log_flush_intervalTime interval in seconds used to accumulate audit logs before sending to ESA. Default value: 10
                                            Min value: 1
                                            Max value: 900
                                            dlq_topic_message_retention_durationIndicates the minimum duration to retain a message in dead letter queue topic in case log destination server is not available. Value must be decimal number, followed by the letter s (seconds). Cannot be more than 31 days or less than 10 minutes. Default value is 1 day
                                            audit_log_dead_letter_topicThis parameter is expected to be used in a separate deployment to replay dead letter queue messages.
                                            max_instance_countGCP Cloud Functions advanced configuration
                                            available_memory_mbGCP Cloud Functions advanced configuration
                                            timeout_secondsGCP Cloud Functions advanced configuration
                                            gen2_available_cpu2nd Gen Cloud Function advanced configuration
                                            gen2_container_concurrency2nd Gen Cloud Function advanced configuration
                                            upgrade_stepSet this variable when upgrading to the latest version.
                                            labelsYou can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.
                                          7. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                            pty-log-forwarder-gcp-{version}/pty-log-forwarder-gcp/
                                            
                                          8. Run the following command.

                                            terraform init
                                            
                                          9. Terraform will download necessary providers.

                                          10. Run the following command to verify configuration and print out deployment plan.

                                            terraform plan
                                            
                                          11. Run the following command to deploy resources to your account.

                                            terraform apply
                                            
                                          12. Once deployment is complete Terraform will print output variables.

                                          13. Record the following values:

                                            • forwarder_function_name: ____________________________
                                            • forwarder_function_url: ____________________________
                                            • forwarder_function_resource_name: __________________

                                          Turn on Instance-based billing.

                                          Both Protect and Log Forwarder functions must run for a short period of time after all requests are handled. In order for the GCP Cloud Run service to allow that, the Instance-based billing feature must be enabled for both function deployments.

                                          To enable Instance-based billing:

                                          1. Log in to Google Account and select the project where Protegrity Cloud Run Function was installed.

                                          2. Navigate to Cloud Run.

                                          3. Click on the Cloud Function name.

                                          4. In Cloud Run revision view, select Edit & deploy new revision.

                                          5. Scroll down to Billing.

                                          6. Select Instance-based.

                                          7. Click DEPLOY.

                                          8. Repeat the steps for Log Forwarder function.

                                          Test Log Forwarder Function Installation

                                          Before continuing with next steps, you can verify whether Log Forwarder Function is installed correctly. This step is optional and can be skipped.

                                          1. Below you can find example CURL command to test your function.

                                          2. Before you can execute it, test if you can obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the Cloud Run Invoker permissions. Continue to the next step if the command succeeds and prints the token.

                                          3. Replace {forwarder_function_url}; with value recorded in previous step.

                                          4. Run the following CURL command to test Function deployment.

                                            curl {forwarder_function_url} \
                                            -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
                                            -H "Content-Type: application/json" \
                                            -H "ce-id: 123451234512345" \
                                            -H "ce-specversion: 1.0" \
                                            -H "ce-time: 2020-01-02T12:34:56.789Z" \
                                            -H "ce-type: google.cloud.pubsub.topic.v1.messagePublished" \
                                            -H "ce-source: //pubsub.googleapis.com/projects/MY-PROJECT/topics/MY-TOPIC" \
                                            -d '{
                                                "message": { 
                                                    "data": "'"$(echo '{"additional_info":{"description":"Data unprotect operation was successful.","query_id":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23"},"client":{},"cnt":4000,"correlationid":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23","level":"SUCCESS","logtype":"Protection","origin":{"hostname":"localhost","time_utc":1725558586},"process":{"id":1},"protection":{"audit_code":8,"dataelement":"alpha","datastore":"SAMPLE_POLICY","mask_setting":"","operation":"Unprotect","policy_user":"master_user"},"protector":{"core_version":"1.2.2+42.g01eb3.HEAD","family":"cp","pcc_version":"3.4.0.20","vendor":"gcp.snowflake","version":"3.1.0.158"},"signature":{"checksum":"7CE5FFCE9DBE570AAA72D1BB20CD083532EF8FAD3E96E38629EB92E837272D8E","key_id":"676c5178-756d-4363-9"}}' | base64 -w 0)"'",
                                                    "attributes": {},  
                                                    "messageId": "",  
                                                    "publishTime": "2014-10-02T15:01:23Z",
                                                    "orderingKey": ""
                                               }
                                            }'
                                            
                                          5. In GCP Logs Explorer console verify that the following output appears in the logs:

                                            Request finished HTTP/1.1 POST http://pty-forwarder-31-smoke-jf-pfadh7riaq-uc.a.run.app/ - 200 0 - 75.6570ms
                                            
                                          6. .

                                          Grant Pub/Sub Publisher Permission to the Protect Function Service Account

                                          Protect function requires permissions to publish audit log messages to Pub/Sub.

                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                          2. Navigate to IAM & Admin.

                                          3. Search for protector function service account email recorded in protect service installation step.

                                          4. Select Edit principal pencil icon.

                                          5. Select ADD ANOTHER ROLE.

                                          6. Select Pub/Sub Publisher.

                                          7. Click Save.

                                          Protect Function Pub/Sub Log Output

                                          Protect function must be configured to output audit logs to Pub/Sub topic.

                                          To configure Protect function audit log output:

                                          1. Go to Protect function Terraform deployment.

                                          2. Navigate to pty-protect-gcp/main.tf.

                                          3. Set Terraform variable pty_log_output=“pub_sub”.

                                          4. Set Terraform variable pty_pub_sub_topic to log forwarder Pub/Sub topic.

                                          5. Run terraform apply.

                                          Troubleshooting

                                          Configure additional logging:

                                          1. Set min_log_level Terraform variable on both Protect function and Log Forwarder function to config.

                                          2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                            resource.type="cloud_run_revision"
                                            resource.labels.service_name=~"pty-(protect|forwarder)-<deploymentd-id>"
                                            severity=ERROR OR textPayload=~"\[error\]"
                                            -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                            
                                          3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                          Error message

                                          Details

                                          Pub/Sub configuration error.
                                          
                                          1. Indicates problems with Pub/Sub service configuration/availability.

                                          2. Expand error log entry and check exception details. For instance:

                                            exception: "Grpc.Core.RpcException: Status(StatusCode="InvalidArgument", Detail="Invalid resource name given (name=projects/<todo>/topics/pty-forwarder-<todo>). 
                                            
                                          3. Verify that pty_pub_sub_topic Terraform variable is set to correct pub/sub resource name.

                                          4. Verify that Pub/Sub topic exists.

                                          Failed to send x/y audit logs to GCP Pub/Sub.   
                                          
                                          1. This error may be shown as a consequence of Pub/Sub configuration/availability errors.
                                          2. Check for pub/sub configuration errors.
                                          3. If pub/sub configuration looks correct, this may indicate that cloud function can’t process audit logs fast enough.
                                          4. From Protector Function Terraform configuration, try increasing CPU and concurrency.
                                          Audit log sink error: Unable to deliver all logs. 
                                          
                                          opensearch.0: Dropped records: 1/1
                                          
                                          [error] [output:opensearch:opensearch.0] HTTP status=401 URI=/_bulk
                                          
                                          1. Indicates problems with ESA Audit Store availability/configuration.
                                          2. Those errors will usually be displayed together. The third error will have details on what is the status or response from ESA.
                                          3. In this example, the HTTP status 401 indicates authentication issue.

                                          2.3.6 -

                                          Prerequisites

                                          RequirementDetail
                                          Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
                                          Protegrity ESA 10.0+The Cloud VNet must be able to obtain network access to the ESA
                                          Google Cloud AccountRecommend creating a new project for Protegrity Serverless
                                          Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

                                          2.3.7 -

                                          Required Skills and Abilities

                                          RequirementsDescription
                                          GCP Cloud AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
                                          Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                          Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

                                          2.4 - BigQuery Configuration

                                          BigQuery configuration guide.

                                            GCP Project BigQuery required permissions

                                            Configuring BigQuery connection requires permissions included in the following predefined IAM roles:

                                            • roles/bigquery.connectionAdmin
                                            • roles/resourcemanager.projectIamAdmin

                                            Additionally the following permissions on the data set are required to configure remote function:

                                            • bigquery.connections.delegate
                                            • bigquery.routines.create
                                            • bigquery.routines.delete
                                            • bigquery.routines.get
                                            • bigquery.routines.list
                                            • bigquery.routines.update
                                            • bigquery.routines.updateTag

                                            Setup the BigQuery Connection

                                            1. Open Cloud Shell Terminal in your GCP Project.

                                            2. Run the following command, replacing <my-project-id>, <location> and <my-connection> with your project id, location of your BigQuery dataset and the id of the connection you are about to create.

                                              bq mk --connection --display_name='Protegrity Cloud Protect' --connection_type=CLOUD_RESOURCE 
                                              --project_id=<my-project-id> --location=<location> <my-connection>
                                              
                                            3. Record the connection id. You will use it in the next steps.

                                              Cloud Resource Connection ID: ___________________

                                            4. Run the command below to display information about BigQuery connection you created in the previous step.

                                              bq show --location=<location> --connection  <my-connection>
                                              
                                            5. Record the serviceAccountId value. This service account was generated for the connection your created in the previous step. It will be used to authenticate BigQuery requests to Cloud Function.

                                              Cloud Resource Connection Service Account: ___________________

                                            6. Run the following command to associate cloud function/run invoker role to the BigQuery connection created earlier. Replace <cloud-resource-connection-service-account> with service account recorded in the previous step. If protector is deployed in Cloud Functions Gen 2, role should be set to roles/run.invoker. For Cloud Functions Gen 1 use roles/cloudfunctions.invoker.

                                              gcloud projects add-iam-policy-binding <my-project-id> --member='serviceAccount:<cloud-resource-connection-service-account>' --role='<role>'
                                              

                                            Test Connectivity

                                            Perform the following steps to verify whether BigQuery is working correctly with the Protegrity product.

                                            1. Access the GCP BigQuery console.

                                            2. Copy and paste the following snippet into a BiqQuery SQL editor.

                                              CREATE OR REPLACE FUNCTION <dataset>.PTY_UNPROTECT_SAMPLE_POLICY(val STRING) RETURNS
                                                STRING
                                                REMOTE WITH CONNECTION `<region>.<cloud-resource-connection-id>`
                                                OPTIONS (
                                                    endpoint ='https://<region>-<project-id>.cloudfunctions.net/<protect-function-name>',
                                                    user_defined_context = [("data_element", "alpha"),("op_type", "unprotect")]
                                                );
                                              
                                            3. Replace the placeholder values with your dataset, project-id, region and cloud-resource-connection-id recorded in previous section.

                                            4. Run the following protect in the console:

                                              SELECT PTY.PTY_UNPROTECT_SAMPLE_POLICY('UtfVk UHgcD!');
                                              
                                            5. Verify that the string hello world! is returned.

                                            Troubleshooting

                                            Use Cloud Logging to To troubleshoot errors.

                                            From your Google Console, navigate to Logging > Logs Explorer

                                            Use the Log Fields panel to filter results by resource type, name, severity, and other criteria. For instance to see the last Cloud Protect Function logs, make the following selections:

                                            RESOURCE TYPE = Cloud Function 
                                                FUNCTION NAME = pty-protect-{deployment-id}
                                            

                                            You can also use the Log Filter Query and run the following query:

                                            resource.type="cloud_function" 
                                                resource.labels.function_name="pty-protect-"
                                            

                                            You can change the time range in the top right corner. If Protegrity policy is configured to generate audit logs, you can use the following query to only view the audit logs:

                                            resource.type="cloud_function" 
                                              resource.labels.function_name="pty-protect-" 
                                              jsonPayload.message=~"\"type\":\"audit\""
                                            

                                            2.5 - Performance

                                            Performance benchmarks and considerations.

                                            2.5.1 - Performance Considerations

                                            The following factors may affect performance benchmarks

                                            Performance Considerations

                                            The following factors may affect performance benchmarks:

                                            • Cold startup: Cloud Function spends additional time on the initial invocation to decrypt and load the policy into memory. This time can vary depending on the policy size. Once the Function is initialized, subsequent “warm executions” should process quickly.
                                            • Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                                            • Cloud Function memory: GCP provides more virtual cores based on the memory configuration. The initial configuration of 2048 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                            • Number of security operations (protect or unprotect).
                                            • Cloud Function max instances and concurrency quota: The instance limit affects how functions are scaled. By default the limit is not set to allow handling any traffic pattern. The instance limit can be set to prevent abnormally high request levels. Cloud Functions are also subject to maximum quota for concurrent invocations and request rate.
                                            • Size of data element: Operations on larger text consume time.

                                            2.5.2 - Sample Benchmarks

                                            Sample benchmarks for BigQuery performance with Cloud Protect.

                                            The following benchmarks were performed using BigQuery on-demand pricing model. These are median times of ten runs each. The query unprotected six columns per row (first_name, last_name, email, street, city, birthday):

                                            Rows x Cols# OpsQuery duration
                                            100K x 6 cols600K8.5
                                            1M x 6 cols6M18
                                            10M x 6 cols60M29
                                            100M x 6 cols600M57

                                            2.5.3 - Log Forwarder Performance

                                            Guidance on Log Forwarder Performance settings and considerations.

                                            Log Forwarder Performance

                                            Log forwarder architecture is optimized to minimize the amount of connections and reduce the overall network bandwidth required to send audit logs to ESA. This is achieved with batching and aggregation taking place on two levels. The first level is in protector function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching and aggregation takes place in the log forwarder function before audit logs are forwarded to ESA. This section shows how to configure the deployment to accommodate different patterns of anticipated audit log stream. It also shows how to monitor deployment resources to detect problems before audit records are lost.

                                                        

                                            • Protector Function Terraform configuration:

                                              • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to Pub/Sub topic. Default value is 30 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The protector function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to Pub/Sub. The protector function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to Pub/Sub. This can be avoided by lowering the interval value.

                                                                      

                                            • Log Forwarder Function Terraform configuration

                                              • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to ESA audit log store. Default value is 10 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The forwarder function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to ESA. The forwarder function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to ESA. This can be avoided by lowering the interval value. On the other hand if the interval is too short, forwarder function might end up sending to many requests to ESA, which in some extreme cases may result in messages being sent to dead letter queue.
                                              • gen2_available_cpu: Increasing the Function CPU count allows setting higher concurrency, which in turn allows processing more messages from the Pub/Sub in parallel. The high CPU count will effectively lower the number of forwarder function instances which will lower number of connections to ESA.
                                              • gen2_container_concurrency: See bullet point above.
                                              • audit_log_dead_letter_topic: Dead-letter Pub/Sub topic name. This topic will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ topic can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                      

                                            • Monitoring Log Forwarder Resources

                                              • Protector Function Logs: If protector function is unable to send logs to Pub/Sub, it will log the following message:

                                                Failed to send x/y audit logs to GCP Pub/Sub.
                                                

                                                See the description of ‘audit_log_flush_interval’ in the protector function configuration section above to learn about potential mitigation.

                                              • Pub/Sub DLQ Topic Metrics: Any positive value in count aggregator on ’topic/message_sizes’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Install Log Forwarder Function via Terraform Scripts

                                              • Log Forwarder Function Logs: If log forwarder function is unable to send logs to ESA, it will log the following message:

                                                [/jenkins/workspace/iaplambda_release_3.1/src/iap/logging/fluent-bit-external-sink.cpp:225] opensearch.0: Dropped records: x/y.
                                                

                                                See the description of ‘audit_log_flush_interval’ in the log forwarder configuration section above to learn about potential mitigation.

                                            2.6 - Audit Logging

                                            Audit log description/formatting

                                              Audit Logging

                                              Audit records and application logs stream to Google Cloud Logging. Cloud Protect uses a JSON format for audit records that is described in the following sections.

                                              You can analyze and alert on audit records using Protegrity ESA or Google Cloud Logging. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Google Cloud Logging, refer to the Google Cloud Logging overview.

                                              For more information about audit records, refer to the Protegrity Analytics Guide.

                                              Audit record fields

                                              The audit record format has been altered in version 3.1 of the protector to provide more information.

                                              FieldDescription
                                              additional_info.deployment_idThe deployment_id contains the name of the Protect Function. It is automatically set based on the cloud-specific environment variables assigned to the Protect Function. This allows identifying the Cloud Protect deployment responsible for generating audit log.
                                              additional_info.cluster(Optional) Redshift cluster ARN
                                              additional_info.descriptionA human-readable message describing the operation
                                              additional_info.query_id(Optional) Identifies the query that triggered the operation
                                              additional_info.request_id(Optional) AWS Lambda request identifier
                                              cntNumber of operations, may be aggregated
                                              correlationid(Deprecated) Use additional_info instead
                                              levelLog severity, one of: SUCCESS, WARNING, ERROR, EXCEPTION
                                              logtypeAlways “Protection”
                                              origin.ipThe private IP address of the compute resource that operates the Protect Function and is responsible for generating the log entry.
                                              origin.hostnameHostname of the system that generated the log entry
                                              origin.time_utcUTC timestamp when the log entry was generated
                                              protection.audit_codeAudit code of the protect operation; see the log return codes table in the Protegrity Troubleshooting Guide
                                              protection.dataelementData element used for the policy operation
                                              protection.datastoreName of the data store corresponding to the deployed policy
                                              protection.mask_setting(Optional) Mask setting from policy management
                                              protection.operationOperation type, one of: Protect, Unprotect, Reprotect
                                              protection.policy_userUser that performed the operation
                                              protector.core_versionInternal core component version
                                              protector.familyAlways “cp” for Cloud Protect
                                              protector.lambda_versionProtector Lambda application version.
                                              protector.pcc_versionInternal pcc component version
                                              protector.vendorIdentifies the cloud vendor and the database vendor
                                              protector.versionProtector version number
                                              signature.checksumHash value of the signature key ID used to sign the log message when the log is generated
                                              signature.key_idKey used to sign the log message when the log is generated

                                              The following are sample audit messages:

                                              Protect Success:

                                              {
                                                    "additional_info": {
                                                      "description": "Data protect operation was successful.",
                                                      "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                      "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "SUCESS",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 6,
                                                      "datastore": "SAMPLE_POLICY",
                                                      "policy_user": "test_user"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "cp",
                                                      "lambda_version": "3.2.10",
                                                      "version": "3.2.0",
                                                      "vendor": "aws.snowflake",
                                                      "pcc_version": "3.4.0.14",
                                                      "core_version": "1.2.1+55.g590fe.HEAD"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              User permission denied:

                                              {
                                                    "additional_info": {
                                                      "description": "The user does not have the appropriate permissions to perform the requested operation."
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "ERROR",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 3,
                                                      "policy_user": "test_user"
                                                    },
                                                    "process": {
                                                      "id": "1",
                                                      "thread_id": "849348352"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "IAP Lambda",
                                                      "lambda_version": "3.2.10",
                                                      "version": "3.2.0",
                                                      "vendor": "Cloud Protect",
                                                      "pcc_version": "3.3.0.5",
                                                      "core_version": "1.1.0"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              Data element not found:

                                              {
                                                    "additional_info": {
                                                      "description": "The data element could not be found in the policy in shared memory."
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "ERROR",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 2,
                                                      "policy_user": "test_user"
                                                    },
                                                    "process": {
                                                      "id": "1",
                                                      "thread_id": "849348352"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "IAP Lambda",
                                                      "lambda_version": "3.2.10",
                                                      "version": "3.2.0",
                                                      "vendor": "Cloud Protect",
                                                      "pcc_version": "3.3.0.5",
                                                      "core_version": "1.1.0"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              Example Audit Records

                                              The following are sample audit messages:

                                              Protect Success:

                                              {
                                                    "additional_info": {
                                                      "description": "Data protect operation was successful.",
                                                      "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                      "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "SUCESS",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 6,
                                                      "datastore": "SAMPLE_POLICY",
                                                      "policy_user": "test_user"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "cp",
                                                      "version": "3.1.0",
                                                      "vendor": "aws.snowflake",
                                                      "pcc_version": "3.4.0.14",
                                                      "core_version": "1.2.1+55.g590fe.HEAD"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              Reprotect Success:

                                              {
                                                    "additional_info": {
                                                      "description": "Data reprotect operation was successful.",
                                                      "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                      "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "SUCCESS",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "old_dataelement": "deAddress1",
                                                      "dataelement": "deAddress2",
                                                      "operation": "Reprotect",
                                                      "audit_code": 50,
                                                      "datastore": "SAMPLE_POLICY",
                                                      "policy_user": "test_user"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "cp",
                                                      "version": "3.1.0",
                                                      "vendor": "aws.snowflake",
                                                      "pcc_version": "3.4.0.14",
                                                      "core_version": "1.2.1+55.g590fe.HEAD"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              User permission denied:

                                              {
                                                    "additional_info": {
                                                      "description": "The user does not have the appropriate permissions to perform the requested operation.",
                                                      "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                      "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "ERROR",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 3,
                                                      "datastore": "SAMPLE_POLICY",
                                                      "policy_user": "test_user"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "cp",
                                                      "version": "3.1.0",
                                                      "vendor": "aws.snowflake",
                                                      "pcc_version": "3.4.0.14",
                                                      "core_version": "1.2.1+55.g590fe.HEAD"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              Data element not found:

                                              {
                                                    "additional_info": {
                                                      "description": "The data element could not be found in the policy in shared memory.",
                                                      "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                      "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                    },
                                                    "cnt": 4000,
                                                    "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                    "logtype": "Protection",
                                                    "level": "ERROR",
                                                    "origin": {
                                                      "hostname": "localhost",
                                                      "time_utc": 1635363966
                                                    },
                                                    "protection": {
                                                      "dataelement": "deAddress",
                                                      "operation": "Protect",
                                                      "audit_code": 2,
                                                      "datastore": "SAMPLE_POLICY",
                                                      "policy_user": "test_user"
                                                    },
                                                    "client": {},
                                                    "protector": {
                                                      "family": "cp",
                                                      "version": "3.1.0",
                                                      "vendor": "aws.snowflake",
                                                      "pcc_version": "3.4.0.14",
                                                      "core_version": "1.2.1+55.g590fe.HEAD"
                                                    },
                                                    "signature": {
                                                      "key_id": "95f5a194-b0a4-4351-a",
                                                      "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                    }
                                                  }
                                              

                                              2.7 - No Access Behavior

                                              Unauthorized unprotect requests behaviour.

                                              No Access Behavior

                                              The security policy maintains a No Access Operation, configured in an ESA, which determines the response for unauthorized unprotect requests.

                                              The following table describes the result returned in the response for the various no access unprotect permissions.

                                              No Access OperationData Returned
                                              Nullnull
                                              Protected(protected value)
                                              ExceptionQuery will fail with an exception

                                              2.8 - Upgrading To The Latest Version

                                              Instructions for upgrading the protector.

                                              2.9 - Known Limitations

                                              Known product limitations.
                                              • Only protect and unprotect operations are supported. The re-protect operation is not supported.

                                              • The Semi-structured (JSON) data type is not supported in the product.

                                              • Cloud Function (Gen2) labels must not be updated from the Cloud Run Services console. When updating labels for a GCP Cloud Function (Gen2) through the Cloud Run Services console, GCP creates a new Cloud Run revision with the updated labels, but the underlying Cloud Function retains the old labels. Because the policy agent reads labels from the Cloud Function definition (not the Cloud Run revision), it will not detect the label change and will not trigger a policy update.

                                                Cloud Run labels vs Cloud Function labels

                                                To avoid this issue, always update labels using one of the following methods:

                                                • Cloud Run Functions console — Navigate to Cloud Run Functions, select the function, and update labels there. This ensures both the Cloud Function and its underlying Cloud Run revision are updated consistently.
                                                • Terraform — Update the labels variable in your Terraform configuration and run terraform apply.
                                                • gcloud CLI — Use gcloud functions deploy with the updated --update-labels flag.

                                                If labels were already updated incorrectly through the Cloud Run Services console, redeploy the function using one of the methods above to synchronize the labels and trigger a policy update.

                                              2.10 - Appendices

                                              Additional references for the protector.

                                              2.10.1 - Integrating Cloud Protect with PPC (Protegrity Provisioned Cluster)

                                              Concepts for integrating with PPC (Protegrity Provisioned Cluster)

                                                This guide describes how to configure the Protegrity Policy Agent and Log Forwarder to connect to a Protegrity Provisioned Cluster (PPC), highlighting the differences from connecting to ESA.

                                                Key Differences: PPC vs ESA

                                                FeatureESA 10.2PPC (this guide)
                                                Datastore Key FingerprintOptional/RecommendedRequired
                                                CA Certificate on AgentOptional/RecommendedOptional/Recommended
                                                CA Certificate on Log ForwarderOptional/RecommendedNot supported
                                                Client Certificate Authentication from Log ForwarderOptional/RecommendedNot supported
                                                IP AddressESA IP addressPPC address

                                                Prerequisites

                                                • Access to PPC and required credentials.
                                                • Tools: curl, kubectl installed.

                                                Policy Agent Setup with PPC

                                                Follow these instructions as a guide for understanding specific inputs for Policy Agent integrating with PPC:

                                                1. Obtain the Datastore Key Fingerprint

                                                  To retrieve the fingerprint for your Policy Agent:

                                                  1. Retrieve public key from the Cloud Provider Key Management service for the policy encryption key created in pre-configuration:

                                                    1. Navigate to the Key Management Service in AWS console and open Customer Managed Keys
                                                    2. Select the desired key
                                                    3. Select the Public Key tab
                                                    4. Select Download
                                                    1. Navigate to the Key Vault in Azure console and open Objects>Keys
                                                    2. Select the desired key
                                                    3. Select the key indicated as CURRENT VERSION
                                                    4. Select Download public key
                                                    1. Navigate to Key Management in GCP console
                                                    2. Select the desired key and open the Versions tab
                                                    3. Select Get public key from the Actions column menu
                                                    4. Select Download

                                                  2. Escape the new line characters in the downloaded public key for use in the next step - for example:

                                                    awk 'NF {printf "%s\\n",$0}' "<public_key_file>" > "new-line-escaped-public-key.pem"
                                                    cat new-line-escaped-public-key.pem
                                                    
                                                  3. Export key fingerprint using the PPC API as indicated in the curl example below:

                                                    curl -k -H "Authorization: Bearer ${TOKEN}" -X POST https://${HOST}/pty/v2/pim/datastores/1/export/keys  -H "Content-Type: application/json" --data '{
                                                      "algorithm": "RSA-OAEP-256",
                                                      "description": "example-key-from-key-management",
                                                      "pem": "<value of new-line-escaped-public-key>"
                                                    }'
                                                    

                                                    Sample Output:

                                                    {"uid":"1","algorithm":"RSA-OAEP-256","fingerprint":"4c:46:d8:05:35:2e:eb:39:4d:39:8e:6f:28:c3:ab:d3:bc:9e:7a:cb:95:cb:b1:8e:b5:90:21:0f:d3:2c:0b:27","description":"example-key-from-kms"}
                                                    
                                                  4. Record the value for fingerprint and configure the Policy Agent:

                                                    Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Lambda function to the fingerprint value.

                                                    Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Function App to the fingerprint value.

                                                    Set the variable in Policy Agent main.tf pty_datastore_key to the fingerprint value and apply the changes.

                                                2. Retrieve the PPC CA Certificate

                                                  To obtain the CA certificate from PPC:

                                                  kubectl -n api-gateway get secret ingress-certificate-secret -o jsonpath='{.data.ca\.crt}' | base64 -d > CA.pem
                                                  

                                                  Use the ProtegrityCA.pem that was returned as described in Policy Agent Installation.

                                                3. Configure the PPC Address

                                                  Use the PPC address in place of the ESA IP address wherever required in your configuration.

                                                Log Forwarder Setup with PPC

                                                • The Log Forwarder will proceed without certificates and will print a warning if PTY_ESA_CA_SERVER_CERT is not provided.
                                                • No additional certificate or CA configuration is needed for PPC.

                                                2.10.2 - Sample BigQuery Remote Function

                                                Sample BigQuery Remote Function definitions and calls for tokenization data elements.

                                                Method: Tokenization

                                                Type: ALPHA

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                STRING

                                                16M (16,777,216 bytes)

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_ALPHA ( val STRING ) 
                                                  RETURNS STRING 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_ALPHA"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_ALPHA ( val STRING ) 
                                                  RETURNS STRING 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_ALPHA"),("op_type", "PROTECT")]
                                                  );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_ALPHA ('Hello World')
                                                
                                                SELECT PTY_UNPROTECT_ALPHA('rfDtw sLMJK');
                                                

                                                Method: Tokenization

                                                Type: NUMERIC

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                NUMERIC

                                                 

                                                DECIMAL

                                                INTEGER

                                                FLOAT64

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_NUMERIC ( val NUMERIC ) 
                                                  RETURNS NUMERIC  
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_NUMERIC"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_NUMERIC ( val NUMERIC) 
                                                  RETURNS NUMERIC 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_NUMERIC"),("op_type", "PROTECT")]
                                                  );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_NUMERIC ('123456789');
                                                
                                                SELECT PTY_UNPROTECT_NUMERIC ('752513497');
                                                

                                                Method: Tokenization

                                                Type: DATE YYYY-MM-DD

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                DATE (any supported format)

                                                10 bytes

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_DATEYYYYMMDD ( val date ) 
                                                  RETURNS DATE 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_DATEYYYYMMDD"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_DATEYYYYMMDD ( val date ) 
                                                  RETURNS DATE 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_DATEYYYYMMDD"),("op_type", "UNPROTECT")]
                                                  );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_DATEYYYYMMDD ('2020-12-31');
                                                
                                                SELECT PTY_UNPROTECT_DATEYYYYMMDD('0653-06-01');
                                                
                                                SELECT PTY_PROTECT_DATEYYYYMMDD ('31-DEC-2020');
                                                
                                                SELECT PTY_UNPROTECT_DATEYYYYMMDD('01-JUN-0653');
                                                
                                                SELECT PTY_PROTECT_DATEYYYYMMDD('12/31/2020');
                                                
                                                SELECT PTY_UNPROTECT_DATEYYYYMMDD('06/01/0653');
                                                

                                                Method: Tokenization

                                                Type: DATETIME

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                DATE

                                                10 bytes

                                                DATETIME

                                                29 bytes

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_DATETIME ( val DATETIME ) 
                                                  RETURNS DATETIME 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_DATETIME"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_DATETIME ( val DATETIME ) 
                                                              RETURNS DATETIME 
                                                              REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                              OPTIONS (
                                                    endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                    user_defined_context = [("data_element", "TOK_DATETIME"),("op_type", "UNPROTECT")]
                                                              );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_DATETIME('2010-10-25');
                                                
                                                SELECT PTY_UNPROTECT_DATETIME('0845-04-04');
                                                
                                                SELECT PTY_PROTECT_DATETIME('2010-10-25 10:45:33');
                                                
                                                SELECT PTY_UNPROTECT_DATETIME('0845-04-04 10:45:33');
                                                
                                                SELECT PTY_PROTECT_DATETIME('2010-10-25 10:45:33.123');
                                                
                                                SELECT PTY_UNPROTECT_DATETIME('0845-04-04 10:45:33.123');
                                                

                                                Method: Tokenization

                                                Type: DECIMAL

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                DECIMAL

                                                38 digits

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_DECIMAL ( val DECIMAL ) 
                                                  RETURNS DECIMAL 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_DECIMAL"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_DECIMAL ( val decimal ) 
                                                  RETURNS decimal 
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_DECIMAL"),("op_type", "UNPROTECT")]
                                                  );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_DECIMAL (12345678.99);
                                                
                                                SELECT PTY_UNPROTECT_DECIMAL (21872469.760000);
                                                

                                                Method: Tokenization

                                                Type: INTEGER

                                                BigQuery Data Types

                                                Protegrity Max Size

                                                NUMERIC

                                                INTEGER

                                                External Function Sample Definitions:

                                                CREATE FUNCTION PTY_PROTECT_INTEGER ( val INTEGER ) 
                                                  RETURNS INTEGER
                                                  REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                  OPTIONS (
                                                      endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                      user_defined_context = [("data_element", "TOK_INTEGER"),("op_type", "PROTECT")]
                                                  );
                                                
                                                CREATE FUNCTION PTY_UNPROTECT_INTEGER ( val INTEGER ) 
                                                              RETURNS INTEGER
                                                              REMOTE WITH CONNECTION `location.cloud-resource-connection-id`
                                                              OPTIONS (
                                                    endpoint ='https://<location-project-id>.cloudfunctions.net/<protect-function-name>',
                                                    user_defined_context = [("data_element", "TOK_INTEGER"),("op_type", "UNPROTECT")]
                                                              );
                                                

                                                Sample EF Calls:

                                                SELECT PTY_PROTECT_INTEGER (123456789);
                                                
                                                SELECT PTY_UNPROTECT_INTEGER (1104108887);
                                                
                                                When values are…then use the following Data Element:
                                                Between -32768 and 32767INTEGER (2 bytes)
                                                Between -2147483648 and 2147483647INTEGER (4 bytes)
                                                Between -9223372036854775808 and 9223372036854775807INTEGER (8 bytes)
                                                < -9223372036854775808 or > 9223372036854775807DECIMAL

                                                When in doubt, use DECIMAL for any numeric range.

                                                2.10.3 - Configuring Regular Expression to Extract Policy Username

                                                Example configurations for user extraction with regular expressions

                                                Configuring Regular Expression to Extract Policy Username

                                                Cloud Protect Cloud Function exposes USERNAME_REGEX configuration to allow extraction of policy username from user in the request.

                                                • USERNAME_REGEX Cloud Function Environment configuration

                                                  The USERNAME_REGEX environment variable can be set to contain regular expression with one capturing group. This group is used to extract the username. Examples below show different regular expression values and the resulting policy user.

                                                USERNAME_REGEX

                                                User in the request

                                                Effective Policy User

                                                Not Set

                                                user@domain.com

                                                user@domain.com

                                                service-account-user@project-id.iam.gserviceaccount.com

                                                service-account-user@project-id.iam.gserviceaccount.com

                                                ^(.*)@.*$
                                                

                                                service-account-user@project-id.iam.gserviceaccount.com

                                                service-account-user

                                                user@domain.com

                                                user

                                                2.10.4 - Associating ESA Data Store With Cloud Protect Agent

                                                ESA controls policy access by mapping server IPs to data stores, registering a node when an agent requests a policy and its IP is identified.

                                                ESA controls which policy is deployed to protector using concept of data store. A data store may contain a list of IP addresses identifying servers allowed to pull the policy associated with that specific data store. Data store may also be defined as default data store, which allows any server to pull the policy, provided it does not belong to any other data stores. Node registration occurs when the policy server (in this case the policy agent) makes a policy request to ESA, where the agent’s IP address is identified by ESA.

                                                Policy agent function source IP address used for node registration on ESA depends on ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP and the PTY_ADDIPADDRESSHEADER configuration exposed by the agent function.

                                                The function service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range described in Function app outbound IP addresses section under function configuration. By default, when agent function is contacting ESA to register node for policy download, ESA uses agent function outbound IP address. This default behavior is caused by the default ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP=false and agent default configuration PTY_ADDIPADDRESSHEADER=yes.

                                                In some cases, when there is a proxy server between the ESA and agent function, the desirable ESA configuration is ASSIGN_DATASTORE_USING_NODE_IP=true. and PTY_ADDIPADDRESSHEADER=no which will cause the ESA to use proxy server IP address.

                                                The table below shows how the hubcontroller and agent settings will affect node IP registration on ESA.

                                                Agent source IPAgent Function Outbound IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent function config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                                                169.254.144.8120.75.43.207No Proxytrueyes169.254.144.81
                                                trueno20.75.43.207
                                                falseyes
                                                falseno
                                                169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                                                trueno34.230.42.110
                                                falseyes
                                                falseno

                                                2.10.5 - Undeliverable Audit Log Recovery

                                                Cloudapi Audit log Recovery

                                                  Protegrity Cloud Protect Log Forwarder installation provides a solution to recover undelivered audit logs. Reasons for undeliverable logs may include:

                                                  • Changes to network configuration in ESA or cloud provider (VPC, firewall, certificate rotation, service user credentials)
                                                  • Log Forwarder IAM Service Account permissions
                                                  • Log Forwarder Cloud Run Function configuration
                                                  • Disruption in cloud provider service

                                                  Log Forwarder Dead Letter Pub/Sub Architecture

                                                  Log Forwarder is triggered by pub/sub events generated by Protect Functions. If Log Forwarder is unable to reach ESA to deliver the logs, they are pushed to a dead letter pub/sub topic. Dead letter pub/sub topic is created when installing the Log Forwarder with the service installation script. See Install Log Forwarder Function via Terraform Scripts for dead letter topic configuration options and naming conventions.

                                                  Logs are not delivered to ESA. Undelivered audit logs are sent to a dead letter pub/sub topic.

                                                  Monitoring Undelivered Logs

                                                  Logs pushed to the dead letter pub/sub topic will be purged and no longer recoverable when specified dlq_topic_message_retention_duration has been reached. Monitoring the dead letter topic is recommended to ensure timely recovery of audit messages before they are permanently lost. Consult the GCP monitoring alerts documentation for setting up alerts based on pub/sub topic metrics.

                                                  Protegrity recommends creation of an additional Log Forwarder installation in the case where logs are not delivered to ESA, as described in Log Forwarder Dead Letter Pub/Sub Architecture.

                                                  Audit log recovery using new log forwarder installation

                                                  Steps to recover audit logs using new Log Forwarder installation:

                                                  1. Create a second Log Forwarder installation (Log Forwarder 2 in the above diagram) for processing undelivered logs. Value for audit_log_dead_letter_topic in the terraform script should be set to null during installation.

                                                  2. Configure and test newly installed Log Forwarder to verify ESA connectivity. See Install Log Forwarder Function via Terraform Scripts for installation instructions.

                                                  3. Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                    terraform output
                                                    

                                                    for the Log Forwarder which failed to deliver logs (Log Forwarder as described in Log Forwarder Dead Letter Pub/Sub Architecture). Note the value for audit_log_dlq_topic.

                                                  4. Set audit_log_dead_letter_topic in the new Log Forwarder (Log Forwarder 2 in the above diagram) terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with terraform apply.

                                                  5. Monitor the new Log Forwarder function logs for any failures.

                                                  Recovering Logs in Dead Letter Topic (Alternative)

                                                  When the recommended method of for recovery described in Recovering Logs in Dead Letter Topic (Recommended) is not an option, you may use the existing Log Forwarder to reprocess undelivered logs.

                                                  Audit log recovery using existing log forwarder installation

                                                  Steps to recover audit logs using existing Log Forwarder installation:

                                                  • Fix any configuration errors causing the Log Forwarder to fail. Verify audit logs are being transmitted successfully to ESA.

                                                  • Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                    terraform output
                                                    

                                                    for the Log Forwarder. Note the value for audit_log_dlq_topic.

                                                  • Set audit_log_dead_letter_topic in the terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with

                                                    terraform apply
                                                    
                                                  • When audit logs have been transmitted to ESA, revert setting audit_log_dead_letter_topic to null Apply the changes with

                                                    terraform apply
                                                    

                                                  2.10.6 -

                                                  Recovering Logs in Dead Letter Topic (Alternative)

                                                  When the recommended method of for recovery described in Recovering Logs in Dead Letter Topic (Recommended) is not an option, you may use the existing Log Forwarder to reprocess undelivered logs.

                                                  Audit log recovery using existing log forwarder installation

                                                  Steps to recover audit logs using existing Log Forwarder installation:

                                                  • Fix any configuration errors causing the Log Forwarder to fail. Verify audit logs are being transmitted successfully to ESA.

                                                  • Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                    terraform output
                                                    

                                                    for the Log Forwarder. Note the value for audit_log_dlq_topic.

                                                  • Set audit_log_dead_letter_topic in the terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with

                                                    terraform apply
                                                    
                                                  • When audit logs have been transmitted to ESA, revert setting audit_log_dead_letter_topic to null Apply the changes with

                                                    terraform apply
                                                    

                                                  2.10.7 -

                                                  Log Forwarder Dead Letter Pub/Sub Architecture

                                                  Log Forwarder is triggered by pub/sub events generated by Protect Functions. If Log Forwarder is unable to reach ESA to deliver the logs, they are pushed to a dead letter pub/sub topic. Dead letter pub/sub topic is created when installing the Log Forwarder with the service installation script. See Install Log Forwarder Function via Terraform Scripts for dead letter topic configuration options and naming conventions.

                                                  Logs are not delivered to ESA. Undelivered audit logs are sent to a dead letter pub/sub topic.

                                                  2.10.8 -

                                                  Monitoring Undelivered Logs

                                                  Logs pushed to the dead letter pub/sub topic will be purged and no longer recoverable when specified dlq_topic_message_retention_duration has been reached. Monitoring the dead letter topic is recommended to ensure timely recovery of audit messages before they are permanently lost. Consult the GCP monitoring alerts documentation for setting up alerts based on pub/sub topic metrics.

                                                  2.10.9 -

                                                  Protegrity recommends creation of an additional Log Forwarder installation in the case where logs are not delivered to ESA, as described in Log Forwarder Dead Letter Pub/Sub Architecture.

                                                  Audit log recovery using new log forwarder installation

                                                  Steps to recover audit logs using new Log Forwarder installation:

                                                  1. Create a second Log Forwarder installation (Log Forwarder 2 in the above diagram) for processing undelivered logs. Value for audit_log_dead_letter_topic in the terraform script should be set to null during installation.

                                                  2. Configure and test newly installed Log Forwarder to verify ESA connectivity. See Install Log Forwarder Function via Terraform Scripts for installation instructions.

                                                  3. Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                    terraform output
                                                    

                                                    for the Log Forwarder which failed to deliver logs (Log Forwarder as described in Log Forwarder Dead Letter Pub/Sub Architecture). Note the value for audit_log_dlq_topic.

                                                  4. Set audit_log_dead_letter_topic in the new Log Forwarder (Log Forwarder 2 in the above diagram) terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with terraform apply.

                                                  5. Monitor the new Log Forwarder function logs for any failures.

                                                  2.11 -

                                                  Solution Overview

                                                  The GCP (Google Cloud Platform) BigQuery Protector is a cloud-native, serverless product for fine-grained data protection. This enables the invocation of Protegrity data protection cryptographic methods in cloud-native serverless technology. The benefits of serverless include rapid auto-scaling, performance, low administrative overhead, and reduced infrastructure costs compared to a server-based solution.

                                                  This product provides integration with Google BigQuery Remote Function. The product is designed to scale elastically and yield reliable query performance under extremely high concurrent loads. During idle use, the serverless product will scale completely down, providing significant savings in Cloud compute fees.

                                                  Protegrity utilizes a data security policy maintained by an Enterprise Security Administrator (ESA), similar to other Protegrity products. Using a simple REST API interface, authorized users can perform both de-identification (protect) and re-identification (unprotect) operations on data. A user’s individual capabilities are subject to privileges and policies defined by the Enterprise Security Administrator.

                                                  3 - Snowflake

                                                  Protector for Snowflake on GCP.

                                                  This section describes the high-level architecture of the Protegrity Snowflake Protector on Google Cloud Platform (GCP), and the installation procedures. This section focuses on Protegrity specific aspects and should be consumed in conjunction with corresponding Snowflake and Google Cloud documentation.

                                                  This guide may also be used with the Protegrity Enterprise Security Administrator Guide, which explains the mechanism for managing the data security policy.

                                                  3.1 - Overview

                                                  Solution overview and features.

                                                    Solution Overview

                                                    Snowflake Protector on Google Cloud is a cloud native, serverless product for fine-grained data protection with Snowflake™, a managed Cloud data warehouse. This enables invocation of the Protegrity data protection cryptographic methods from the Snowflake SQL execution context. The benefits of serverless include rapid auto-scaling, performance, low administrative overhead, and reduced infrastructure costs compared to a server-based solution.

                                                    This product provides data protection services invoked by External User Defined Functions (UDFs) within Snowflake. The UDFs act as a client transmitting micro-batches of data to the serverless Protegrity Cloud function. User queries may generate hundreds or thousands of parallel requests to perform security operations. Protegrity’s serverless function is designed to scale and yield reliable query performance under such load.

                                                    Snowflake Protector on Google Cloud utilizes a data security policy maintained by an Enterprise Security Administrator (ESA), similar to other Protegrity products. Using regular SQL database queries or tools, such as, Tableau™, authorized users can perform de-identification (protect) and re-identification (unprotect) operations on data within the managed Cloud data warehouse. A user’s individual capabilities are subject to privileges and policies defined by the Enterprise Security Administrator.

                                                    The following data ingestion patterns are available with your managed Cloud data warehouse:

                                                    • Data protection at source applications: In this case, sensitive data is already de-identified (protected) across the enterprise wherever it resides, including the managed data warehouse. Protected data can be ingested directly into your managed Cloud data warehouse. Depending on usage patterns, this ensures that your managed data warehouse is not brought into scope for PCI, PII, GDPR, HIPPA, and other compliance policies.
                                                    • Data protection using the Extract-Transform-Load (ETL) pattern: In this case, sensitive data may be transformed with a Protegrity protector either on-premise or in the Cloud before it is ingested into Snowflake.
                                                    • Data protection using the Extract-Load-Transform (ELT) pattern: In this case, sensitive data is protected after it lands into the target system typically through a temporary landing table. It uses the native data warehouse’s compute engine with Protegrity to protect incoming data at very high throughput rates. After the data is protected, the intermediate loading tables are dropped as part of the ingestion workflow.

                                                    Analytics on Protected Data

                                                    Protegrity’s format and length preserving tokenization scheme make it possible to perform analytics directly on protected data. Tokens are join-preserving so protected data can be joined across datasets. Often statistical analytics and machine learning training can be performed without the need to re-identify protected data. However, a user or service account with authorized security policy privileges may re-identify subsets of data using the Snowflake Protector on GCP service.

                                                    Features

                                                    Snowflake Protector on GCP incorporates Protegrity’s patent-pending vaultless tokenization capabilities into cloud-native serverless technology. Combined with an ESA security policy, the protector provides the following features:

                                                    • Role-based access control (RBAC) to protect and unprotect (re-identify) data depending on the user privileges.
                                                    • Policy enforcement features of other Protegrity application protectors.

                                                    For more information about the available protection options, such as, data types, Tokenization or Encryption types, or length preserving and non-preserving tokens, refer to Protection Methods Reference.

                                                    3.2 - Architecture

                                                    Deployment architecture and connectivity

                                                      Deployment Architecture

                                                      The Protegrity product should be deployed in the customer’s Cloud account within the same Google Cloud region as the Snowflake cluster. The product incorporates Protegrity’s vaultless tokenization engine within Google Cloud Functions. The encrypted data security policy from an ESA is deployed periodically as a static resource together with Cloud Function binaries. The policy is decrypted in memory at runtime within the Cloud Function. This architecture allows Protegrity to be highly available and scale very quickly without direct dependency on any other Protegrity services.

                                                      The product exposes a remote data protection service invoked from external User Defined Functions (UDFs), a native feature of specific Cloud databases. The UDFs can be invoked through direct SQL queries or database views. The external UDF makes parallel API calls to the serverless Protegrity Cloud function via the GCP API Gateway to perform protect and unprotect data operations. Each network REST request includes a micro-batch of data to process and a secure context header generated by the database with the username and a Protegrity context header with the data element type, and operation to perform. The product applies the ESA security policy including user authorization and returns a corresponding response. Security operations on sensitive data performed by protector can be audited. The product can be configured to send audit logs to ESA via optional component called Log Forwarder.

                                                      The security policy is synchronized through another serverless component called the Protegrity Policy Agent. The agent operates on a configurable schedule, fetches the policy from the ESA, performs envelope encryption using Google Key Management Service, and deploys new version of Cloud Function with updated policy. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. There is no downtime for users during this process. Instances provisioned with the function’s previous policy version may continue running (and processing traffic) for several minutes after a deployment has finished.

                                                      The following diagram shows the high-level architecture described above.

                                                      The following diagram shows a reference architecture for synchronizing the security policy from the ESA to the product.

                                                      The Protegrity Policy Agent requires network access from the Cloud to your ESA. Most organizations install the ESA on-premise. Therefore, it is recommended that the Policy Agent is installed into a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

                                                      The ESA is a soft appliance that must be pre-installed on a separate server. It is used to create and manage security policies.

                                                      For more information about installing the ESA, and creating and managing policies, refer to the Policy Management Section.

                                                      Audit Log Forwarding Architecture

                                                      Audit logs are by default sent to Cloud Logging. The Protegrity Product can also be configured to send audit logs to ESA. Such configuration requires deploying Log Forwarder component which is available as part of Protegrity Product deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

                                                      The log forwarder component includes Pub/Sub service topic and the audit log forwarder function. Pub/Sub service is used to asynchronously send audit records to forwarder function, where similar audit logs are aggregated before sending to ESA. Aggregation rules are described in the Protegrity Log Forwarding guide. When the protector function is configured to send audit logs to log forwarder, audit logs are aggregated on the protector function before sending to Pub/Sub topic. Protector function exposes configuration to control the time it spends aggregating audit logs which is described in the protector function installation section.

                                                      The security of audit logs is ensured by using HTTPS connection on each link of the communication between protector function and ESA. Integrity and authenticity of audit logs is additionally checked on log forwarder which verifies individual logs signature. The signature verification is done upon arrival from Pub/Sub topic before applying aggregation. If signature cannot be verified, the log is forwarded as is to ESA where additional signature verification can be configured. Log forwarder function uses basic auth and optional certificate verification to authenticate calls to ESA. Basic auth credentials are stored securely in Secret Manager Service.

                                                      To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instruction can be found in the Audit Log Forwarder Installation.

                                                      The audit log forwarding requires network access from the cloud to the ESA. Most organizations install the ESA on-premise. Therefore, it is recommended that the Log Forwarder Function is installed into a private subnet with a Cloud VPC using a NAT Gateway to enable this communication through a corporate firewall.

                                                      Snowflake Connectivity

                                                      Snowflake communicates to the Snowflake Protector through the Google Cloud API Gateway. The API Gateway is configured to use an OAuth 2.0 implicit grant flow. Snowflake generates a JWT token used for remote authorization with the API Gateway. Snowflake requests are directed to the customer’s Google API Gateway which is configured to verify the JWT token. The following figure illustrates the integration architecture between Snowflake and the Protegrity software.

                                                      Snowflake’s API Integration Object

                                                      The Snowflake API Integration Object provides a connection between your Snowflake Google Cloud Account and your Google Cloud account where the Protegrity product is hosted. Creating this connection requires setting up the API Gateway and the appropriate access policies. These steps are provided in the installation.

                                                      3.3 - Installation

                                                      Product Installation Guide.

                                                      3.3.1 - Prerequisites

                                                      Requirements before installing the protector.

                                                        Google Cloud Services

                                                        The following table describes the Google Cloud services that may a part of your Protegrity installation.

                                                        ServiceDescription
                                                        Cloud Run FunctionsProvides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates.
                                                        API GatewayProvides the end-point and access control (Required for Snowflake only).
                                                        Key Management ServiceProvides cryptographic keys for envelope encryption/decryption of the policy.
                                                        Secret Manager ServiceStores secrets required during deployment, e.g., ESA credentials.
                                                        Cloud Storage ServiceStorage location for the encrypted ESA policy package.
                                                        Identity and Access ManagementEnforces access policies for deployed resources.
                                                        Cloud Logging ServiceApplication and audit logs, performance monitoring, and alerts.
                                                        Cloud VPCRequired for securing network access to On-Prem or cloud-based ESA.
                                                        Pub/SubProvides a messaging service when forwarding audit logs to ESA is enabled.

                                                        ESA Version Requirements

                                                        The Protector and Log Forwarder functions require a security policy from a compatible ESA version.

                                                        The table below shows compatibility between different Protector and ESA versions.

                                                        Protector VersionESA Version
                                                        8.x9.09.1 & 9.210.0
                                                        2.xNoYes*No
                                                        3.0.x & 3.1.xNoNoYesNo
                                                        3.2.xNoNoYes*
                                                        4.0.xNoNoNoYes

                                                        Legend

                                                        Yes

                                                        Protector was designed to work with this ESA version

                                                        No

                                                        Protector will not work with this ESA version

                                                        *

                                                        Backward compatible policy download supported:

                                                        • Data elements and features which are common between this and previous ESA versions will be downloaded
                                                        • Data elements and features which are new to this ESA version and do not exist in previous ESA version will not be downloaded

                                                        Prerequisites

                                                        The following requirements must be completed for the Snowflake implementation.

                                                        RequirementsDescription
                                                        Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
                                                        Protegrity ESA 10.0+The Cloud VPC must be able to obtain network access to the ESA
                                                        Google Cloud AccountRecommend creating a new project for Protegrity Serverless
                                                        Snowflake cluster (Enterprise Edition recommended)
                                                        Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

                                                        Required Skills and Abilities

                                                        RequirementsDescription
                                                        Google Cloud Account AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
                                                        Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                                        Snowflake AdministratorAccount Admin access required to setup access
                                                        Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

                                                        3.3.2 - Pre-Configuration

                                                        Configuration steps prior product installation.

                                                          Google Cloud Project

                                                          Identify or create a new Google Cloud Project where the Protegrity solution will be installed. It is recommended to create a new project. This provides greater security controls and avoids conflicts with other applications that might impact regional account limits. An individual with the Owner role will be required for some of the subsequent installations.

                                                          Google Project ID: ___________________

                                                          Google Project Number: ___________________

                                                          Google Cloud Region: ___________________

                                                          Region

                                                          Query the Google Cloud region where the Snowflake cluster is running. This is the region in which Protegrity Serverless must be installed.

                                                          To determine the Google Cloud region:

                                                          1. Login to Snowflake

                                                          2. In the SQL console, run the following query.

                                                            select current_region();
                                                            
                                                          3. Record the Google Cloud region. For example, GCP_US_CERNTAL1.

                                                            Snowflake Google Cloud Region: ___________________

                                                          Key Management Service

                                                          The Google Cloud Key Management Service (KMS) provides Protegrity Serverless solution the ability to encrypt and decrypt the Protegrity Security Policy.

                                                          To create KMS Key Ring and Asymmetric Encryption Master Key:

                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                          2. Navigate to Security > Key Management.

                                                          3. Select Create key ring.

                                                          4. Specify key ring name. For example, protegrity-policy-keyring.

                                                          5. select Key ring location which corresponds to the region where Protegrity solution will be installed.

                                                          6. Select Create.

                                                          7. Select CREATE KEY to create encryption key.

                                                          8. Specify key name. For example, protegrity-policy-key.

                                                          9. under Purpose selection, select Asymmetric Decrypt .

                                                          10. Select Key Algorithm. For example, 3072-bit RSA with OAEP Padding and SHA256 digest.

                                                          11. Select Create.

                                                          12. Once the key is created, a screen opens on the key. If the screen does not appear, click on the key name.

                                                          13. Then click on the elipses under Actions that is next to the key version.

                                                          14. Select Copy Resource Name and record the value below, e.g., projects/{project-id}/locations/region/keyRings/{key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                                            Policy Encryption Key Version Resource Name: ___________________

                                                          Google Cloud Storage

                                                          Cloud Storage buckets are required for the Gen 2 Cloud Function sources, the Terraform backend, and the deployment of the Protegrity installation artifacts. It is recommended that you create 3 separate buckets to separate files used for different purposes. If you cannot create 3 separate buckets, you may reuse a bucket for multiple purposes.

                                                          Create the buckets:

                                                          1. Run the cloud command below to enable the Google Storage Transfer API.

                                                            gcloud services enable storagetransfer.googleapis.com
                                                            
                                                          2. Create the Gen 2 Cloud Function sources bucket. This bucket is not required if you will be deploying to Gen 1 Cloud Functions. The bucket name much match the example below. Replace the <gcp-project-number> and <region> placeholders.

                                                            gcf-v2-sources-<gcp-project-number>-<region>
                                                            

                                                            Use the following gcloud command to obtain project number

                                                            gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
                                                            
                                                          3. Create the deployment bucket or reuse an existing bucket. This bucket is used during the installation process to store the Protegrity installation artifacts.

                                                            Deployment Bucket Name:___________________

                                                          4. Create the Terraform backend bucket or reuse an existing bucket. This bucket is used by Terraform to store information about your Cloud Protect installation, and will be used if you upgrade to a later version of Cloud Protect in the future.

                                                            Terraform Backend Bucket Name:___________________

                                                          Cloud Functions Service Accounts

                                                          Cloud Functions use the service accounts created in this deployment. You can create Service accounts manually or use the Protegrity Terraform installation script to create one. Each service account requires specific permissions, which must be granted through IAM roles. Run the following steps to create service accounts and configure the required IAM access. If you use Terraform scripts, skip these steps.

                                                          Agent Function IAM Role

                                                          To create Agent Function IAM Role:

                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                          3. Specify role name and description.

                                                          4. Select ADD PERMISSIONS.

                                                          5. Select the following permissions:

                                                            • cloudkms.cryptoKeyVersions.useToEncrypt
                                                            • cloudkms.cryptoKeyVersions.viewPublicKey
                                                            • secretmanager.versions.access
                                                            • storage.objects.get
                                                            • storage.objects.create
                                                            • storage.objects.delete
                                                            • storage.objects.list
                                                            • storage.objects.update
                                                            • storage.buckets.get
                                                            • cloudfunctions.functions.get
                                                            • cloudfunctions.functions.update
                                                            • cloudfunctions.functions.sourceCodeGet
                                                            • cloudfunctions.functions.sourceCodeSet
                                                            • iam.serviceAccounts.actAs
                                                          6. Click Add and then Create.

                                                          Alternatively, you can run the following command from the Cloud Shell Terminal.

                                                                gcloud iam roles create role-id \
                                                                --project=project-id \
                                                                --title=role-title \
                                                                --description=role-description \
                                                                --permissions=cloudkms.cryptoKeyVersions.useToEncrypt,\
                                                                cloudkms.cryptoKeyVersions.viewPublicKey,\
                                                                secretmanager.versions.access,\
                                                                storage.objects.get,\
                                                                storage.objects.create,\
                                                                storage.objects.delete,\
                                                                storage.objects.list,\
                                                                storage.objects.update,\
                                                                storage.buckets.get,\
                                                                cloudfunctions.functions.get,\
                                                                cloudfunctions.functions.update,\
                                                                cloudfunctions.functions.sourceCodeGet,\
                                                                cloudfunctions.functions.sourceCodeSet,\
                                                                iam.serviceAccounts.actAs \
                                                                --stage=GA 
                                                                
                                                          
                                                          • role-id

                                                            is the name of the role, such as ptyProtectRole.

                                                          • project-id

                                                            is the name of the project, such as my-project-id.

                                                          • role-description

                                                            is a short description of the role, such as “My custom role description”.

                                                          Sample output:

                                                          
                                                                Created role [role-id]. 
                                                                description: role-description 
                                                                etag: *****************
                                                                includedPermissions: 
                                                                - cloudfunctions.functions.get 
                                                                - cloudfunctions.functions.sourceCodeGet 
                                                                - cloudfunctions.functions.sourceCodeSet 
                                                                - cloudfunctions.functions.update 
                                                                - cloudkms.cryptoKeyVersions.useToEncrypt 
                                                                - cloudkms.cryptoKeyVersions.viewPublicKey 
                                                                - iam.serviceAccounts.actAs 
                                                                - secretmanager.versions.access 
                                                                - storage.buckets.get 
                                                                - storage.objects.create 
                                                                - storage.objects.delete 
                                                                - storage.objects.get 
                                                                - storage.objects.list 
                                                                - storage.objects.update 
                                                                name: projects/{project-id}/roles/{role-id} 
                                                                stage: GA 
                                                                title: role-title
                                                                
                                                          

                                                          Agent Service Account

                                                          To create Agent Service Account:

                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                          3. Select CREATE SERVICE ACCOUNT.

                                                          4. Specify service account name and description.

                                                          5. Select Create and Continue.

                                                          6. In the next step, click Select Role.

                                                          7. Select Custom and select the role created above .

                                                          8. Click Done.

                                                          9. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                          10. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com

                                                            Agent Function Service Account Email: ___________________

                                                          Protect Function IAM role

                                                          To create Protect Function IAM role:

                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                          3. Specify role name and description.

                                                          4. Select ADD PERMISSIONS.

                                                          5. Select the cloudkms.cryptoKeyVersions.useToDecrypt permission.

                                                          6. Click Add and then Create.

                                                          Protect Service Account

                                                          To create Protect Service Account:

                                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                          3. Select CREATE SERVICE ACCOUNT.

                                                          4. Specify service account name and description.

                                                          5. Select Create and Continue.

                                                          6. In the next step, click Select Role. Then select Custom and select the role created above .

                                                          7. Click Done.

                                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                            Protect Function Service Account Email: ___________________

                                                          3.3.3 - Protect Service Installation

                                                          Product Installation Guide.

                                                            Preparation

                                                            1. Ensure that all the steps in Pre-Configuration are performed.

                                                            2. Log in to the Google Cloud account where Protegrity will be installed.

                                                            3. Select the project.

                                                            4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                                            5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                                            Install Protect Function via Terraform Scripts

                                                            Resources created with Terraform scripts include Protect Cloud Functions Service and other required resources depending on Terraform parameters. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                                                            To install using Terraform:

                                                            1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                                                            2. Unzip the main bundle. Then unzip protegrity-cloud-protect-gcp-{version}.zip. Verify that the following files are available:

                                                              • pty-protect-gcp/
                                                              • main.tf
                                                              • outputs.tf
                                                              • protegrity-cloud-protect-gcp-{version}.zip
                                                              • README.md
                                                            3. Unzip the protegrity-cloud-protect-gcp-{version}.zip file. Verify that the following files are available:

                                                              • pty-protect-gcp/
                                                              • main.tf
                                                              • outputs.tf
                                                              • protegrity-cloud-protect-gcp-{version}.zip
                                                              • README.md
                                                            4. Open the main.tf file and update Terraform backend information at the top of the file:

                                                              terraform {
                                                                backend "gcs" {
                                                                  bucket  = ""
                                                                  prefix  = "protegrity/terraform/pty-protect-gcp/state"
                                                                }
                                                              }
                                                              
                                                            5. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                                                            Parameter

                                                            Description

                                                            project_id

                                                            The project id recorded in the pre-configuration step

                                                            region

                                                            The Region recorded in the pre-configuration step.

                                                            deployment_id

                                                            Specify short name to identify deployment. This id will be added to all resources deployed with Terraform.

                                                            deployment_bucket

                                                            Use Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.

                                                            create_service_account

                                                            Leave this as false if you created service account in pre-configuration. Otherwise set to true.

                                                            protect_function_service_account_email

                                                            Use Protect Function Service account recorded in pre-configuration or leave empty.

                                                            api_gateway_gcp_service_account_issuer

                                                            Allows setting issuer of JSON Web Token credential used to authenticate calls to API Gateway. Set this to API_GCP_SERVICE_ACCOUNT obtained in section Describe the API Integration Object

                                                            username_regex

                                                            If username_regex is set, the effective policy user will be extracted from the user in the request.

                                                            max_instance_count

                                                            GCP Cloud Functions advanced configuration

                                                            available_memory_mb

                                                            GCP Cloud Functions advanced configuration

                                                            timeout_seconds

                                                            GCP Cloud Functions advanced configuration

                                                            gen2_available_cpu

                                                            2nd Gen Cloud Function advanced configuration

                                                            gen2_container_concurrency

                                                            2nd Gen Cloud Function advanced configuration

                                                            upgrade_step

                                                            Set this variable when upgrading to the latest version.

                                                            labels

                                                            You can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

                                                            min_log_level

                                                            Minimum log level for log forwarder function. One of off|severe|warning|info|config|all. Defaults to ‘severe’

                                                            pty_log_output

                                                            Audit log output. Accepted values: “”(empty string), “pub_sub”.

                                                            pty_pub_sub_topic

                                                            Pub/Sub topic where audit logs will be sent.

                                                            1. Run the following command.

                                                              terraform init
                                                              
                                                            2. Terraform will download necessary providers.

                                                            3. Run the following command to verify configuration and print out deployment plan.

                                                              terraform plan
                                                              
                                                            4. Run the following command to deploy resources to your account.

                                                              terraform apply
                                                              
                                                            5. Once deployment is complete Terraform will print output variables.

                                                            6. Record the following values:

                                                              • protect_function_name: ________________________________
                                                              • protect_function_url: __________________________
                                                              • api_gateway_managed_service: _____________________________
                                                              • api_gateway_protect_service_url: ____________________
                                                              • protect_function_resource_name: _______________________

                                                            Test Protect Function Installation

                                                            Before continuing with next steps, you can verify whether Cloud Functions are installed correctly. This step is optional and can be skipped.

                                                            1. Below you can find example CURL command to test your function.

                                                            2. Before you can execute it, you need to obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the roles/run.invoker role. Record the output of print identity token command.

                                                              gcloud_auth_token: _________________

                                                            3. Replace {protect_function_url}; with value recorded in previous step.

                                                            4. Replace {gcloud_auth_token} with value recorded in above step.

                                                            5. Run the following CURL command to test Function deployment.

                                                              curl -X POST "{protect_function_url}" \
                                                                      -H 'Authorization:Bearer {gcloud_auth_token}' \
                                                              -H 'sf-custom-X-Protegrity-HCoP-Rules: {"jsonpaths":[{"op_type":"unprotect","data_element":"alpha"}]}' \
                                                              -H 'sf-context-current-user: test' \
                                                              -H 'sf-external-function-current-query-id: test-id' \
                                                              -H 'Content-Type: application/json' \
                                                              -d '{ 
                                                                "data": [ 
                                                                  ["0", "UtfVk UHgcD!"] 
                                                                ] 
                                                              } 
                                                              ' 
                                                              
                                                            6. Verify the following output:

                                                              {"data":[[0,"hello world!"]]}
                                                              

                                                            3.3.4 - Snowflake Configuration

                                                            Configure Snowflake to access the API Gateway.

                                                              The following sections will configure Snowflake to access the API Gateway. The Terraform installation deployed a sample policy that can be used to smoke test the installation.

                                                              Login to Snowflake as ACCOUNTADMIN

                                                              Ensure that the current user can assume the Account Administrator role. This role is required to create the Snowflake API Integration object.

                                                              Create the Snowflake API Integration Object

                                                              1. From the Snowflake console worksheet, select the role ACCOUNTADMIN.

                                                              2. Paste the following text and replace the two parameters <api_gateway_managed_service> and <api_gateway_protect_service_url> with values recorded in the last installation step of Install Protect Function via Terraform Scripts, then run the following Data Definition Language (DDL) in the console to create API integration object:

                                                                create or replace api integration protegrity_api 
                                                                api_provider = google_api_gateway
                                                                google_audience = '<api_gateway_managed_service>' 
                                                                enabled = true
                                                                api_allowed_prefixes = ('<api_gateway_protect_service_url>/pty/snowflake');
                                                                

                                                              Describe the API Integration Object

                                                              We require values generated by the Snowflake integration object to configure the API Gateway Authorization.

                                                              To describe API integration objects:

                                                              1. Run the following query in the console.

                                                                DESCRIBE API INTEGRATION protegrity_api;
                                                                
                                                              2. Record the API_GCP_SERVICE_ACCOUNT value from the resulting query:

                                                                • API GCP Service Account: ___________________

                                                              Update API Gateway Authorization Configuration

                                                              This step allows the Snowflake service account to invoke Protect API Gateway endpoint.

                                                              Update Protect API Gateway Endpoint:

                                                              1. Return to Terraform script used to install Protegrity Protect service.

                                                              2. Open main.tf and update api_client_service_account_email with the API GCP Service Account recorded in previous step.

                                                              3. Run terraform apply.

                                                              4. Wait till the process is completed.

                                                              Test Connectivity

                                                              Perform the following steps to verify whether Snowflake is working correctly with the Protegrity product.

                                                              1. Access the Snowflake SQL console.

                                                              2. Copy and paste the following snippet into a worksheet.

                                                                CREATE OR REPLACE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_SAMPLE_POLICY(VAL VARCHAR)
                                                                    RETURNS VARCHAR(16777216)
                                                                    IMMUTABLE
                                                                    API_INTEGRATION = PROTEGRITY_API
                                                                    HEADERS =(  
                                                                    'X-Protegrity-HCoP-Rules'=
                                                                    '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"alpha"}]}'
                                                                    ) 
                                                                    CONTEXT_HEADERS = (CURRENT_USER,CURRENT_TIMESTAMP,CURRENT_ACCOUNT)
                                                                    COMMENT='Unprotects text using an alpha token type.'
                                                                    AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                
                                                              3. Replace the placeholder value indicated substituting your API Gateway URL captured in the Terraform outputs (api_gateway_protect_service_url).

                                                              4. Run the following protect in the console:

                                                                select pty_unprotect_sample_policy('UtfVk UHgcD!');
                                                                
                                                              5. Verify that the string hello world! is returned.

                                                              Troubleshooting

                                                              Use Cloud Logging to troubleshoot errors.

                                                              From your Google Console, navigate to Logging > Logs Explorer

                                                              Use the Log Fields panel to filter results by resource type, name, severity, and other criteria. For instance to see the last Cloud Protect Function logs, make the following selections:

                                                              RESOURCE TYPE = Cloud Function 
                                                                  FUNCTION NAME = pty-protect-{deployment-id}
                                                              

                                                              You can also use the Log Filter Query and run the following query:

                                                              resource.type="cloud_function" 
                                                                  resource.labels.function_name="pty-protect-"
                                                              

                                                              You can change the time range in the top right corner. If Protegrity policy is configured to generate audit logs, you can use the following query to only view the audit logs:

                                                              resource.type="cloud_function" 
                                                                resource.labels.function_name="pty-protect-" 
                                                                jsonPayload.message=~"\"type\":\"audit\""
                                                              

                                                              3.3.5 - Policy Agent Installation

                                                              Install the policy agent.

                                                                Policy Agent Function installation is done via Terraform scripts provided by Protegrity. Before running the template, some resources must be created manually.

                                                                ESA Server

                                                                Policy Agent function requires ESA server running and accessible from Agent Cloud Function on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted.

                                                                Note down ESA IP address:

                                                                ESA IP Address (EsaIpAddress): ___________________

                                                                Certificates on ESA

                                                                By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Cloud Function Environment variables configuration.

                                                                In case ESA is configured with publicly signed certificates, this section can be skipped since the Cloud Function will use public CA to validate ESA certificates.

                                                                To obtain self-signed CA certificate from ESA:

                                                                1. Log in to ESA Web UI.

                                                                2. Select Settings > Network > Manage Certificates.

                                                                3. Hover over Server Certificate and click on download icon to download the CA certificate.

                                                                4. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                                                  To escape new lines from command line, use one of the following commands depending on your operating system:

                                                                  Linux Bash:

                                                                  awk 'NF {printf "%s\\n",$0;}' ProtegrityCA.pem > output.txt
                                                                  

                                                                  Windows PowerShell:

                                                                  (Get-Content '.\ProtegrityCA.pem') -join '\n' | Set-Content 'output.txt'
                                                                  
                                                                5. Record the certificate content with new lines escaped.

                                                                  ESA CA Server Certificate (EsaCaCert): ___________________

                                                                  This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section.

                                                                For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                                                Identify or Create a new VPC

                                                                Google Cloud VPC is used to route traffic from Policy Agent Cloud Function to ESA. If your ESA is in a Google Cloud VPC, it is recommended to create a serverless VPC access and record its name:

                                                                google_vpc_access_connector_name: ___________________

                                                                If ESA is not on Google Cloud VPC, you can either create one or choose to let Terraform script to create one. The Terraform script will create the following elements:

                                                                • NAT gateway

                                                                  To connect to ESA outside the Google Cloud Network

                                                                • External IP address

                                                                  Can add it to the allowlist by the firewall in the network environment where ESA is hosted.

                                                                • Serverless VPC access

                                                                  Allows connectivity from the Cloud function to the VPC.

                                                                Creating ESA Credentials

                                                                Policy Agent Function requires ESA credentials to be provided as one of the two options:

                                                                Secret Manager

                                                                Secret Manager is the recommended option for storing ESA credentials.

                                                                Create ESA credentials secrets:

                                                                1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                2. Go to Security > Secret Manager.

                                                                3. Select CREATE SECRET.

                                                                4. Specify the Secret Value:

                                                                  {
                                                                    "username": "{esa_username}", 
                                                                    "password": "{esa_password}"
                                                                  }
                                                                  
                                                                5. Select Create Secret.

                                                                6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                                                7. Click on Actions, next to the secret version you just created.

                                                                8. Select Copy Resource ID and record the full secret version path, For example, projects/{project-id}/secrets/{secret name}/versions/2.

                                                                  Secret resource id: ___________________

                                                                Custom Cloud Function

                                                                If you have the skills to write code, you may provide a custom Cloud Function that returns the ESA credentials to the Policy Agent. One use case is when reading the ESA credentials from a third-party password vault.

                                                                Create the Cloud Function:

                                                                1. Create a new 2nd gen Cloud Function using any runtime.

                                                                  1. The Policy Agent does not provide an input payload.

                                                                  2. The Cloud Function must return a response according to the following schema:

                                                                    response: 
                                                                      type: object 
                                                                        properties: 
                                                                          username: string 
                                                                          password: string
                                                                    

                                                                    For example,

                                                                    example output: {"username": "admin", "password": "Password1234"} 
                                                                    
                                                                  3. Sample GCP Function in Python:

                                                                    def handler(request): 
                                                                        return {"username": "admin", "password": "password1234"} 
                                                                    
                                                                2. Grant the Cloud Run Invoker role to the Policy Agent function service account.

                                                                3. Grant the cloudfunctions.functions.get permission to the Policy Agent function service account role.

                                                                4. Record the Function name:

                                                                  ESA CREDENTIALS FUNCTION NAME: _______________

                                                                Install Policy Agent Function through Terraform Scripts

                                                                Agent Terraform scripts provided by Protegrity create a Cloud Function in your Google account. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can also create the following optional resources by specifying the corresponding parameters:

                                                                • Service account with IAM role
                                                                • VPC with NAT external IP
                                                                • VPC access connector

                                                                To install Policy Agent Function through Terraform:

                                                                1. From command shell, move to the directory where you downloaded Protegrity installation bundle.

                                                                2. Unzip the bundle, then unzip the protegrity-agent-gcp-{version}.zip. Verify that the following files are available:

                                                                  • pty-agent-gcp/
                                                                  • main.tf
                                                                  • outputs.tf
                                                                  • README.md
                                                                3. Open the main.tf file and update Terraform backend information at the top of the file:

                                                                  
                                                                  terraform {
                                                                    backend "gcs" {
                                                                      bucket  = ""
                                                                      prefix  = "protegrity/terraform/pty-protect-gcp/state"
                                                                    }
                                                                  }
                                                                  
                                                                4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                                                5. Set the prefix property with value unique to your deployment.

                                                                6. In the same main.tf file, specify the following Terraform variables.

                                                                  ParameterDescription
                                                                  project_idThe Project ID recorded in the pre-configuration step
                                                                  regionThe Region recorded in the pre-configuration step, for example, us-central1.
                                                                  deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                                                  deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                                                  deployment_bucket_locationGeographical location of deployment bucket, e.g., US, EU, ASIA.
                                                                  deployment_file_directory_pathPath to directory where deployment zip file is located. By default the deployment file should be in the same directory as this main.tf file.
                                                                  policy_download_cron_expressionCron expression determining how often policy agent function will run to synchronize security policy from ESA.
                                                                  create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                                                  agent_function_service_account_emailUse Agent Function Service account recorded in pre-configuration or leave empty.
                                                                  create_vpcSet this to true, if you would like to create VPC with NAT, external IP and vpc access connector, otherwise leave empty. This will be ignored if google_vpc_access_connector_name is specified.
                                                                  google_vpc_access_connector_nameSpecify the existing VPC access connector name you identified in earlier step, otherwise leave empty. This setting will disable create_vpc = true.
                                                                  google_vpc_access_connector_full_resource_nameAlternative configuration for VPC access connector. If this parameter is set the google_vpc_access_connector_name will be ignored. Use this parameter, if vpc connector is in different region/project that the one specified for the deployment.
                                                                  labelsYou can set this map to include labels for deployed resources. Pay attention to gcp label requirements. More information in: https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

                                                                  All the values were recorded in Pre-Configuration and this section’s previous steps.

                                                                7. Provide Policy update Terraform variables. In the same main.tf file, you can specify configuration related to policy update. Any of these variables can be updated at any given time by running the terraform again or directly in the GCP Console. Most of the values were recorded in previous installation steps.

                                                                  Parameter

                                                                  Description

                                                                  Notes

                                                                  pty_esa_ip

                                                                  ESA IP address or hostname

                                                                  ESA Server

                                                                  pty_esa_ca_server_cert

                                                                  ESA self-signed CA certificate used by policy Agent Function to ensure ESA is the trusted server.

                                                                  Recorded in step Certificates on ESA

                                                                  In case ESA is configured with publicly signed certificates, the pty_esa_ca_server_cert configuration will be ignored.

                                                                  gcp_esa_credentials_secret_resource_id

                                                                  ESA username and password (encrypted value by Google Cloud Secrets Manager). For example, projects/{project-id}/secrets/{secret name}/versions/{version}

                                                                  Creating ESA Credentials

                                                                  pty_esa_credentials_function

                                                                  ESA credentials GCP function resource name. For example, projects/{project-name}/locations/{region}/functions/{esa-credentials-function-name}.

                                                                  Recorded in step Option 2: Custom Cloud Function ESA CREDENTIALS FUNCTION NAME. Presence of gcp_esa_credentials_secret_resource_id will cause this value to be ignored. The Policy Agent Function must have network access and IAM permissions to call the ESA Credentials function you have created in Option 2: Custom Cloud Function.

                                                                  gcp_kms_key_resource_name

                                                                  The Key full resource name. For Example, projects/{project-id}/locations/region/keyRings/ {key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                                                  Key Management Service

                                                                  gcp_protect_function_resource_name

                                                                  List of comma separated Protect function resource names. For Example, projects/{project-id}/ locations/{region}/functions/{function-name1},projects/{project-id}/ locations/{region}/functions/{function-name2}

                                                                  Use protect_function_resource_name recorded in Protect Service Installation section.

                                                                  gcp_policy_retention_storage_bucket

                                                                  Deployment Bucket Name where the encrypted policy will be written.

                                                                  You can use deployment bucket recorded in Google Cloud Storage section, or you can specify other existing bucket.

                                                                  gcp_policy_version_object_key

                                                                  Filename of the encrypted policy stored in the Deployment Bucket Name

                                                                  Default: policy.zip

                                                                  retain_policy_versions

                                                                  Number of policy versions to retain as backup. (e.g. 2 will retain the latest 2 policies and remove older ones). -1 retains all.

                                                                  Default: 10

                                                                  disable_deploy

                                                                  This flag can be either 1 or 0. If set to 1, then the agent will not update protector function with the newest policy. Else, the policy will be saved in the cloud storage bucket and deployed to the protector function.

                                                                  Default: 0

                                                                  log_level

                                                                  Application and audit logs verbiage level

                                                                  Default: INFO. Allowed values: DEBUG – the most verbose INFO, WARNING, ERROR – the least verbose

                                                                  policy_pull_timeout

                                                                  Time in seconds to wait for the ESA to send the full policy

                                                                  Default: 20

                                                                  pty_core_casesensitive

                                                                  Specifies whether policy usernames should be case sensitive

                                                                  Default: no. Allowed values: yes, no

                                                                  pty_core_emptystring

                                                                  Override default behavior. Empty string response values are returned as null values. For instance, (un)protect(’’) -> null (un)protect(’’) -> ''

                                                                  Default: empty. Allowed values: null, empty

                                                                  esa_connection_timeout

                                                                  Time in seconds to wait for the ESA response

                                                                  Default: 5s

                                                                  pty_addipaddressheader

                                                                  When enabled, agent will send its source IP address in the request header. This configuration works in conjunction with ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP (default=false). See Associating ESA Data Store With Cloud Protect Agent for more information.

                                                                  Default: yes. Allowed values: yes, no

                                                                  pty_datastore_key

                                                                  ESA policy datastore public key fingerprint (64 char long) e.g. 123bff642f621123d845f006c6bfff27737b21299e8a2ef6380aa642e76e89e5.

                                                                  The export key is the public part of an asymmetric key pair created in a Create KMS Key. A user with Security Officer permissions adds the public key to the data store in ESA via Policy Management > Data Stores > Export Keys. The fingerprint can then be copied using the Copy Fingerprint icon next to the key. Refer to Exporting Keys to Datastore for details.

                                                                  pty_sync_datastore

                                                                  Optional name of the policy datastore to sync with ESA. Refer to ESA documentation for more information on policy datastore sync.

                                                                  Default: ""
                                                                8. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                                                  protegrity-agent-gcp-{version}/pty-agent-gcp/
                                                                  
                                                                9. Run terraform init.

                                                                  Terraform will download necessary providers.

                                                                10. Run terraform plan to verify configuration and print out deployment plan.

                                                                11. Run terraform apply to deploy resources to your account. Once deployment is complete, Terraform will print output variables.

                                                                12. Below is the sample output from successful deployment.

                                                                  
                                                                          Apply complete! Resources: 1 added, 0 changed, 0 destroyed. 
                                                                          Outputs: 
                                                                          agent_function_service_account_email = "pty-agent-test@test.iam.gserviceaccount.com" 
                                                                          deployment_bucket_name = "test-bucket" 
                                                                          nat_ip = 0 
                                                                          policy_agent_function_deployment_object = "pty-agent-test-1.0.1.zip" 
                                                                          policy_agent_function_name = "pty-agent-test" 
                                                                  

                                                                Test Agent Function Installation

                                                                After configuration is complete, you can test the function.

                                                                To test and run the Policy Agent Function:

                                                                1. From the Google Cloud console, go to Cloud Run Functions or Cloud Run.

                                                                2. Click on the function you just deployed: pty_agent_{deployment_id}.

                                                                3. Click Test button at the top right section of the screen.

                                                                4. Scroll down to CLI test command.

                                                                5. Copy and run the curl command to trigger the agent. Alternatively, use the option Test in Cloud Shell.

                                                                6. Wait for the function to complete.

                                                                7. Navigate to the LOGS tab to view agent execution logs.

                                                                8. Alternatively, you may review the logs by navigating to Logging from your Google Console. In the Log Explorer select the All resources dropdown, then Cloud Run Revision > pty-agent-{deployment-id} and apply.

                                                                  
                                                                  Function execution took 23892 ms, finished with status: 'ok'
                                                                  iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_21-00-00.zip]
                                                                  iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_19-03-23.zip]
                                                                  iap.policy_deployer:INFO:Removing old function versions in [test-artifacts]. Will retain [1] versions.
                                                                  iap.policy_deployer:INFO:Updating function [projects/cloud-engineering-315519/locations/us-central1/functions/pty-protect-test] with new deployment artifact [test-artifacts/policy_v07-26-2021_21-00-01.zip] ...
                                                                  iap.imp_creator:INFO:Uploading encrypted policy data to: [test-artifacts/policy_v07-26-2021_19-03-23.zip]
                                                                  iap.imp_creator:INFO:Preparing deployment package ...
                                                                  iap_agent_gcp.cloud_functions_util:INFO:Downloading function deployment package ...
                                                                  iap.imp_creator:INFO:Encrypting policy package ...
                                                                  iap.policy_agent:INFO:Preparing new policy deployment ...
                                                                  iap.policy_agent:WARNING:Current policy deployment has no checksum_mapping metadata:
                                                                  iap.imp_creator:INFO:Checking current policy version ...
                                                                  iap.policy_agent:INFO:Current deployment package version: [policy_v07-26-2021_18-51-43.zip].
                                                                  iap.policy_agent:INFO:Getting current policy metadata ...
                                                                  iap.imp_creator:INFO:Policy downloaded successfully ...
                                                                  iap.imp_creator:INFO:PepServer started ...
                                                                  iap.imp_creator:INFO:Starting PepServer ...
                                                                  iap.imp_creator:INFO:PepServer configured successfully
                                                                  iap.imp_creator:INFO:Downloading certificates from ESA ...
                                                                  iap.imp_creator:INFO:Configuring PepServer ...
                                                                  iap.policy_agent:INFO:Starting policy agent ...
                                                                  iap.policy_agent:INFO:Using Secret Manager [GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID] to retreive ESA credentials.
                                                                  iap.policy_agent:INFO:PTY_CORE_CASESENSITIVE [no]
                                                                  iap.policy_agent:INFO:PTY_CORE_EMPTYSTRING [empty]
                                                                  iap.policy_agent:INFO:RETAIN_POLICY_VERSIONS [1]
                                                                  iap.policy_agent:INFO:GCP_PROTECT_FUNCTION_RESOURCE_NAME [projects/test/locations/us-central1/functions/pty-protect-test]
                                                                  iap.policy_agent:INFO:GCP_POLICY_VERSION_OBJECT_KEY [policy.zip]
                                                                  iap.policy_agent:INFO:GCP_POLICY_RETENTION_STORAGE_BUCKET [test-artifacts]
                                                                  iap.policy_agent:INFO:GCP_KMS_KEY_RESOURCE_NAME [projects/test/locations/us-central1/keyRings/test-key-ring/cryptoKeys/test-protect-asymmetric/cryptoKeyVersions/1]
                                                                  iap.policy_agent:INFO:GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID [projects/1234/secrets/ESA_ADMIN_CREDENTIALS/versions/2]
                                                                  iap.policy_agent:INFO:PTY_ESA_IP [54.236.107.39]
                                                                  iap.policy_agent:INFO:POLICY_PULL_TIMEOUT [20]
                                                                  iap.policy_agent:INFO:DISABLE_DEPLOY [0]
                                                                  Function execution started
                                                                  

                                                                Troubleshooting

                                                                Configure additional logging:

                                                                1. Set log_level Terraform variable on the Agent function to DEBUG.

                                                                2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                                                  resource.type="cloud_run_revision"
                                                                  resource.labels.service_name=~"pty-agent-<deploymentd-id>"
                                                                  severity=ERROR OR textPayload=~"\[error\]"
                                                                  -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                                                  
                                                                3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                                                Error message

                                                                Details

                                                                iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Resource 'projects/<account>/locations/<region>/functions/protegrity-protect-<deployment-id>' was not found
                                                                
                                                                This error may indicate the following configuration issues:
                                                                1. The function name indicated in setting gcp_protect_function_resource_name has been provided incorrectly, and thus cannot be found.
                                                                2. disable_deploy has been set, and a dummy function has been entered to work around the gcp_protect_function_resource_name requirement. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate.
                                                                [ERROR] policy_agent:Invalid GCP_PROTECT_FUNCTION_RESOURCE_NAME parameter value. Must be a comma separated list of Lambda Function names or ARNs.
                                                                
                                                                This error may indicate the following configuration issues:
                                                                1. The setting gcp_protect_function_resource_name is empty. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate, this setting may not be left empty.
                                                                2. The list of function names provided to gcp_protect_function_resource_name contains invalid function name or is not valid csv format.
                                                                [ERROR] iap_agent_gcp.cloud_functions_util:<HttpError 403 when requesting https://cloudfunctions.googleapis.com/v2/projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>:generateDo
                                                                wnloadUrl?alt=json returned "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/<deployment-id>'". Details: "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'">
                                                                [ERROR] policy_agent:Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'
                                                                ...
                                                                iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>' 
                                                                

                                                                Indicates the Agent Cloud Run function’s identity does not have permissions to sourceCodeGet for Protect/Log Forwarder function(s) provided to the gcp_protect_function_resource_name configuration.

                                                                3.3.6 - Audit Log Forwarder Installation

                                                                Install the audit log forwarder.

                                                                    Audit Log Forwarder installation is done via Terraform scripts provided by Protegrity in the installation bundle.

                                                                    ESA Audit Store Configuration

                                                                    ESA server is required as the recipient of audit logs. Verify the information below to ensure ESA is accessible and configured properly.

                                                                    1. ESA server running and accessible on TCP port 9200.

                                                                    2. Audit Store service is configured and running on ESA. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                    Certificates on ESA

                                                                    By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Log Forwarder configuration.

                                                                    In case ESA is configured with publicly signed certificates, this section can be skipped since the Log Forwarder will use public CA to validate ESA certificates.

                                                                    To obtain self-signed CA certificate from ESA:

                                                                    1. Download ESA CA certificate from the /etc/ksa/certificates/plug directory of the ESA

                                                                    2. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                                                      To escape new lines from command line, use one of the following commands depending on your operating system:

                                                                      Linux Bash:

                                                                      awk 'NF {printf "%s\\n",$0;}' CA.pem > output.txt
                                                                      

                                                                      Windows PowerShell:

                                                                      (Get-Content '.\CA.pem') -join '\n' | Set-Content 'output.txt'
                                                                      
                                                                    3. Record the certificate content with new lines escaped.

                                                                      ESA CA Server Certificate (EsaCaCert): ___________________

                                                                      This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section. Install Log Forwarder via Terraform

                                                                    For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                                                    VPC configuration

                                                                    Similar to Policy Agent Function, log forwarder function requires Google Cloud VPC to route traffic from the function to ESA. Review the VPC configuration steps for agent in section Identify or Create a new VPC. Same VPC connector as the policy agent can be used. Note down VPC connector name:

                                                                    google_vpc_access_connector_name: ___________________

                                                                    ESA Authentication

                                                                    Audit Log Forwarder must authenticate with ESA using certificate-based authentication with client certificate and certificate key. Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                                                    File NameDescription
                                                                    client.keyClient certificate key
                                                                    client.pemClient certificate (PEM)

                                                                    Both certificate and certificate key must be converted to single-line values using code similar to the following examples.

                                                                    Client certificate (client.pem):

                                                                    $folder = 'C:\Temp'
                                                                    cd $folder
                                                                    (Get-Content "$folder\client.pem") -join '\n' | Set-Content "$folder\one-liner-client.pem"
                                                                    cat "$folder\one-liner-client.pem"
                                                                    
                                                                    folder="/tmp"
                                                                    cd "$folder"
                                                                    awk 'NF {printf "%s\\n",$0}' "client.pem" > "one-liner-client.pem"
                                                                    cat "one-liner-client.pem"
                                                                    

                                                                    Client certificate key (client.key):

                                                                    $folder = 'C:\Temp'
                                                                    cd $folder
                                                                    (Get-Content "$folder\client.key") -join '\n' | Set-Content "$folder\one-liner-client.key"
                                                                    cat "$folder\one-liner-client.key"
                                                                    
                                                                    folder="/tmp"
                                                                    cd "$folder"
                                                                    awk 'NF {printf "%s\\n",$0}' "client.key" > "one-liner-client.key"
                                                                    cat "one-liner-client.key"
                                                                    

                                                                    While installing using Terraform template:

                                                                    1. Provide single-line client certificate for pty_esa_client_cert
                                                                    2. Provide ID of the GCP secret containing the single-line certificate key for pty_esa_client_cert_key_secret_id Secret is created in a later step

                                                                    Configure ESA Secrets In GCP Secret Manager

                                                                    Audit Log Forwarder Function uses GCP Secret Manager to store ESA Audit Store credentials used during authentication.

                                                                    For information on how to configure basic and certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                                                    1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                    2. Go to Security > Secret Manager.

                                                                    3. Select CREATE SECRET.

                                                                    4. Specify the Secret Value:

                                                                      {
                                                                        "username": "admin", 
                                                                        "password": "{esa_password}"
                                                                      }
                                                                      
                                                                    5. Select Create Secret.

                                                                    6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                                                    7. Click on Actions, next to the secret version you just created.

                                                                    8. Select Copy Resource ID and record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/2.

                                                                      ESA Log Forwarder Credentials Secret Name: _________________

                                                                    9. Create another secret with single-line contents of ESA client certificate key file

                                                                      See Certificate Authentication for details on client certificate key

                                                                    10. Record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/1.

                                                                      ESA Log Forwarder Client Certificate Key Secret Name: _________________

                                                                    Create Log Forwarder Service Account

                                                                    To create Log Forwarder Service Account:

                                                                    1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                    2. Navigate to IAM & Admin > Service Accounts.

                                                                    3. Select CREATE SERVICE ACCOUNT.

                                                                    4. Specify service account name and description.

                                                                    5. Select Create and Continue.

                                                                    6. In the next step, click Select Role. Then select the following roles:

                                                                      • Cloud KMS CryptoKey Decrypter
                                                                      • Pub/Sub Publisher
                                                                      • Secret Manager Secret Accessor
                                                                    7. Click Done.

                                                                    8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                    9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                      Log Forwarder Function Service Account Email: ___________________

                                                                    Create Service Account For Forwarder Pub/Sub

                                                                    Pub/Sub service requires Cloud Run Invoker permissions in order to be able to send messages to the Forwarder function.

                                                                    1. Log in to Google Account and select the project where Protegrity forwarder will be installed.

                                                                    2. Navigate to IAM & Admin > Service Accounts.

                                                                    3. Select CREATE SERVICE ACCOUNT.

                                                                    4. Specify service account name and description.

                                                                    5. Select Create and Continue.

                                                                    6. In the next step, click Select Role. Then select Cloud Run Invoker.

                                                                    7. Click Done.

                                                                    8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                    9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                      Pub/Sub Log Forwarder Service Account Email: ___________________

                                                                    Preparation

                                                                    1. Ensure that all the steps in Google Cloud Project are performed.

                                                                    2. Log in to the Google Cloud account where Protegrity will be installed.

                                                                    3. Select the project.

                                                                    4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                                                    5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                                                    Install Log Forwarder Function via Terraform Scripts

                                                                    Resources created with Terraform scripts include Audit Log Forwarder Cloud Functions Service and Pub/Sub topic. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                                                                    To install using Terraform:

                                                                    1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                                                                    2. Unzip the bundle, then unzip the protegrity-gcp-bigquery-{version}.zip. Navigate to pty-log-forwarder-gcp/. Verify that the following files are available:

                                                                      • pty-log-forwarder-gcp/
                                                                      • main.tf
                                                                      • outputs.tf
                                                                      • protegrity-cloud-api-gcp-{version}.zip
                                                                      • README.md
                                                                    3. Open the main.tf file and update Terraform backend information at the top of the file:

                                                                      terraform {
                                                                        backend "gcs" {
                                                                          bucket  = ""
                                                                          # The bucket/prefix combination must be unique for different deployments 
                                                                          # to avoid conflicting Terraform states and accidental resources destruction.
                                                                          # prefix = "protegrity-gcp-bigquery/forwarder/<deployment_id>/tf-state"
                                                                        }
                                                                      }
                                                                      
                                                                    4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                                                    5. Set the prefix property with value unique to your deployment.

                                                                    6. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                                                                      ParameterDescription
                                                                      project_idThe project id recorded in the pre-configuration step
                                                                      regionThe Region recorded in the pre-configuration step.
                                                                      deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                                                      deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                                                      create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                                                      forwarder_function_service_account_emailUse Forwarder Function Service account recorded in pre-configuration or leave empty.
                                                                      pub_sub_log_forwarder_service_account_emailService account of the audit log Pub/Sub trigger. The service account must be assigned Cloud Run Invoker (roles/run.invoker) role.
                                                                      create_vpcIf create_vpc flag is set, new vpc will be created together with vpc connector, NAT and external IP Use this flag if you have VPC admin permissions in your Google Account. If you set it to false, you can specify the existing VPC in the google_vpc_access_connector_name parameter.
                                                                      google_vpc_access_connector_nameUse existing VPC connector to associate with Log Forwarder Function. You can specify either the VPC connector name or the full resource name if vpc connector is in different region/project that the one specified for the deployment. You can alternatively set the use google_vpc_access_connector_full_resource_name. Both parameters are optional. Full resource name takes precedence over connector name.
                                                                      log_destination_esa_ipIp address of the ESA where Protector logs will be sent to.
                                                                      pty_esa_ca_server_certESA self-signed CA certificate used by log forwarder function to ensure ESA is the trusted server. See documentation for more details.
                                                                      esa_credentials_secret_resource_idGCP Secret Manager secret id where ESA Fluent Bit logger credentials are stored.
                                                                      pty_esa_client_certSingle-line ESA client certificate content. See Certificate Authentication for details on client certificate
                                                                      pty_esa_client_cert_key_secret_idGCP Secret Manager secret id where single-line ESA client certificate key content is stored. See Configure ESA Secrets In GCP Secret Manager for details on client certificate key secret
                                                                      min_log_levelMinimum log level for log forwarder function. Must be one of the following: [off,severe,warning,info,config,all].
                                                                      esa_tls_disable_cert_verifyDisable certificate verification when connecting to ESA. This is only for dev purposes, should not be used in production environment.
                                                                      esa_connect_timeoutEsa connection timeout in seconds.
                                                                      esa_virtual_hostESA Virtual Host.
                                                                      audit_log_flush_intervalTime interval in seconds used to accumulate audit logs before sending to ESA. Default value: 10
                                                                      Min value: 1
                                                                      Max value: 900
                                                                      dlq_topic_message_retention_durationIndicates the minimum duration to retain a message in dead letter queue topic in case log destination server is not available. Value must be decimal number, followed by the letter s (seconds). Cannot be more than 31 days or less than 10 minutes. Default value is 1 day
                                                                      audit_log_dead_letter_topicThis parameter is expected to be used in a separate deployment to replay dead letter queue messages.
                                                                      max_instance_countGCP Cloud Functions advanced configuration
                                                                      available_memory_mbGCP Cloud Functions advanced configuration
                                                                      timeout_secondsGCP Cloud Functions advanced configuration
                                                                      gen2_available_cpu2nd Gen Cloud Function advanced configuration
                                                                      gen2_container_concurrency2nd Gen Cloud Function advanced configuration
                                                                      upgrade_stepSet this variable when upgrading to the latest version.
                                                                      labelsYou can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.
                                                                    7. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                                                      pty-log-forwarder-gcp-{version}/pty-log-forwarder-gcp/
                                                                      
                                                                    8. Run the following command.

                                                                      terraform init
                                                                      
                                                                    9. Terraform will download necessary providers.

                                                                    10. Run the following command to verify configuration and print out deployment plan.

                                                                      terraform plan
                                                                      
                                                                    11. Run the following command to deploy resources to your account.

                                                                      terraform apply
                                                                      
                                                                    12. Once deployment is complete Terraform will print output variables.

                                                                    13. Record the following values:

                                                                      • forwarder_function_name: ____________________________
                                                                      • forwarder_function_url: ____________________________
                                                                      • forwarder_function_resource_name: __________________

                                                                    Turn on Instance-based billing.

                                                                    Both Protect and Log Forwarder functions must run for a short period of time after all requests are handled. In order for the GCP Cloud Run service to allow that, the Instance-based billing feature must be enabled for both function deployments.

                                                                    To enable Instance-based billing:

                                                                    1. Log in to Google Account and select the project where Protegrity Cloud Run Function was installed.

                                                                    2. Navigate to Cloud Run.

                                                                    3. Click on the Cloud Function name.

                                                                    4. In Cloud Run revision view, select Edit & deploy new revision.

                                                                    5. Scroll down to Billing.

                                                                    6. Select Instance-based.

                                                                    7. Click DEPLOY.

                                                                    8. Repeat the steps for Log Forwarder function.

                                                                    Test Log Forwarder Function Installation

                                                                    Before continuing with next steps, you can verify whether Log Forwarder Function is installed correctly. This step is optional and can be skipped.

                                                                    1. Below you can find example CURL command to test your function.

                                                                    2. Before you can execute it, test if you can obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the Cloud Run Invoker permissions. Continue to the next step if the command succeeds and prints the token.

                                                                    3. Replace {forwarder_function_url}; with value recorded in previous step.

                                                                    4. Run the following CURL command to test Function deployment.

                                                                      curl {forwarder_function_url} \
                                                                      -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
                                                                      -H "Content-Type: application/json" \
                                                                      -H "ce-id: 123451234512345" \
                                                                      -H "ce-specversion: 1.0" \
                                                                      -H "ce-time: 2020-01-02T12:34:56.789Z" \
                                                                      -H "ce-type: google.cloud.pubsub.topic.v1.messagePublished" \
                                                                      -H "ce-source: //pubsub.googleapis.com/projects/MY-PROJECT/topics/MY-TOPIC" \
                                                                      -d '{
                                                                          "message": { 
                                                                              "data": "'"$(echo '{"additional_info":{"description":"Data unprotect operation was successful.","query_id":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23"},"client":{},"cnt":4000,"correlationid":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23","level":"SUCCESS","logtype":"Protection","origin":{"hostname":"localhost","time_utc":1725558586},"process":{"id":1},"protection":{"audit_code":8,"dataelement":"alpha","datastore":"SAMPLE_POLICY","mask_setting":"","operation":"Unprotect","policy_user":"master_user"},"protector":{"core_version":"1.2.2+42.g01eb3.HEAD","family":"cp","pcc_version":"3.4.0.20","vendor":"gcp.snowflake","version":"3.1.0.158"},"signature":{"checksum":"7CE5FFCE9DBE570AAA72D1BB20CD083532EF8FAD3E96E38629EB92E837272D8E","key_id":"676c5178-756d-4363-9"}}' | base64 -w 0)"'",
                                                                              "attributes": {},  
                                                                              "messageId": "",  
                                                                              "publishTime": "2014-10-02T15:01:23Z",
                                                                              "orderingKey": ""
                                                                         }
                                                                      }'
                                                                      
                                                                    5. In GCP Logs Explorer console verify that the following output appears in the logs:

                                                                      Request finished HTTP/1.1 POST http://pty-forwarder-31-smoke-jf-pfadh7riaq-uc.a.run.app/ - 200 0 - 75.6570ms
                                                                      
                                                                    6. .

                                                                    Grant Pub/Sub Publisher Permission to the Protect Function Service Account

                                                                    Protect function requires permissions to publish audit log messages to Pub/Sub.

                                                                    1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                    2. Navigate to IAM & Admin.

                                                                    3. Search for protector function service account email recorded in protect service installation step.

                                                                    4. Select Edit principal pencil icon.

                                                                    5. Select ADD ANOTHER ROLE.

                                                                    6. Select Pub/Sub Publisher.

                                                                    7. Click Save.

                                                                    Protect Function Pub/Sub Log Output

                                                                    Protect function must be configured to output audit logs to Pub/Sub topic.

                                                                    To configure Protect function audit log output:

                                                                    1. Go to Protect function Terraform deployment.

                                                                    2. Navigate to pty-protect-gcp/main.tf.

                                                                    3. Set Terraform variable pty_log_output=“pub_sub”.

                                                                    4. Set Terraform variable pty_pub_sub_topic to log forwarder Pub/Sub topic.

                                                                    5. Run terraform apply.

                                                                    Troubleshooting

                                                                    Configure additional logging:

                                                                    1. Set min_log_level Terraform variable on both Protect function and Log Forwarder function to config.

                                                                    2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                                                      resource.type="cloud_run_revision"
                                                                      resource.labels.service_name=~"pty-(protect|forwarder)-<deploymentd-id>"
                                                                      severity=ERROR OR textPayload=~"\[error\]"
                                                                      -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                                                      
                                                                    3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                                                    Error message

                                                                    Details

                                                                    Pub/Sub configuration error.
                                                                    
                                                                    1. Indicates problems with Pub/Sub service configuration/availability.

                                                                    2. Expand error log entry and check exception details. For instance:

                                                                      exception: "Grpc.Core.RpcException: Status(StatusCode="InvalidArgument", Detail="Invalid resource name given (name=projects/<todo>/topics/pty-forwarder-<todo>). 
                                                                      
                                                                    3. Verify that pty_pub_sub_topic Terraform variable is set to correct pub/sub resource name.

                                                                    4. Verify that Pub/Sub topic exists.

                                                                    Failed to send x/y audit logs to GCP Pub/Sub.   
                                                                    
                                                                    1. This error may be shown as a consequence of Pub/Sub configuration/availability errors.
                                                                    2. Check for pub/sub configuration errors.
                                                                    3. If pub/sub configuration looks correct, this may indicate that cloud function can’t process audit logs fast enough.
                                                                    4. From Protector Function Terraform configuration, try increasing CPU and concurrency.
                                                                    Audit log sink error: Unable to deliver all logs. 
                                                                    
                                                                    opensearch.0: Dropped records: 1/1
                                                                    
                                                                    [error] [output:opensearch:opensearch.0] HTTP status=401 URI=/_bulk
                                                                    
                                                                    1. Indicates problems with ESA Audit Store availability/configuration.
                                                                    2. Those errors will usually be displayed together. The third error will have details on what is the status or response from ESA.
                                                                    3. In this example, the HTTP status 401 indicates authentication issue.

                                                                    3.3.7 -

                                                                    Prerequisites

                                                                    The following requirements must be completed for the Snowflake implementation.

                                                                    RequirementsDescription
                                                                    Protegrity distribution and installation scriptsThese artifacts are provided by Protegrity
                                                                    Protegrity ESA 10.0+The Cloud VPC must be able to obtain network access to the ESA
                                                                    Google Cloud AccountRecommend creating a new project for Protegrity Serverless
                                                                    Snowflake cluster (Enterprise Edition recommended)
                                                                    Terraform CLI v0.14 or higherTerraform is used to deploy resources to Google Cloud Account

                                                                    3.3.8 -

                                                                    Required Skills and Abilities

                                                                    RequirementsDescription
                                                                    Google Cloud Account AdministratorRun Terraform (or perform steps manually), create/configure a VPC and IAM permissions.
                                                                    Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                                                    Snowflake AdministratorAccount Admin access required to setup access
                                                                    Network AdministratorOpen firewall to access ESA and evaluate Google Cloud network setup

                                                                    3.4 - Understanding Snowflake Objects

                                                                    Key concepts in understanding the Protegrity Serverless with Snowflake.

                                                                    3.4.1 - External Functions

                                                                    Call out to a process external to Snowflake through a REST API.

                                                                    External Functions

                                                                    Snowflake provides an External Function capability used to call out to a process external to Snowflake through a REST request over TLS encryption. In the Protegrity Cloud Protect for Snowflake solution, this external service is the Protegrity Endpoint for data re-identification operations.

                                                                    Security Operation Parameters

                                                                    The following table describes optional and required security operation parameters.

                                                                    Parameter

                                                                    Type

                                                                    Example

                                                                    Description

                                                                    op_type

                                                                    String

                                                                    “op_type”:“UNPROTECT” “op_type”:“PROTECT”

                                                                    Required operation name, can be either UNPROTECT or PROTECT

                                                                    data_element

                                                                    String

                                                                    “data_element”:“TOK_ALPHA”

                                                                    Required data element name defined in Protegrity Security Policy

                                                                    external_iv

                                                                    String

                                                                    “external_iv”:“abc-123”

                                                                    Optional external intialization vector, which allows for different tokenized results for the same input data and data element of the same security policy. Refer to the External Initialization Vector (IV) in the Protection Methods Reference for more details.

                                                                    External Function Sample Definition with External IV:

                                                                    CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_ALPHA ( val varchar )
                                                                      RETURNS varchar
                                                                      NULL
                                                                      IMMUTABLE
                                                                      COMMENT = 'Protects using an ALPHA data element using External IV'
                                                                      API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID
                                                                      HEADERS = (
                                                                        'X-Protegrity-HCoP-Rules'=
                                                                        '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_ALPHA","external_iv":"abc-123"}]}'
                                                                      )
                                                                      CONTEXT_HEADERS = ( current_user, current_timestamp, current_account )
                                                                      AS '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                                
                                                                    

                                                                    3.4.2 - Snowflake Masking Policies

                                                                    Optimize REST requests to the Protegrity endpoint.

                                                                    Masking Policies in the Sample Application are used to optimize REST requests to the Protegrity endpoint and to prevent integration of External Functions into queries.

                                                                    3.5 - Performance

                                                                    Performance benchmarks and considerations.

                                                                    3.5.1 - Performance Considerations

                                                                    The following factors may affect performance benchmarks

                                                                    Performance Considerations

                                                                    The following factors may affect performance benchmarks:

                                                                    • Cold startup: Cloud Function spends additional time on the initial invocation to decrypt and load the policy into memory. This time can vary depending on the policy size. Once the Function is initialized, subsequent “warm executions” should process quickly.
                                                                    • Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                                                                    • Cloud Function memory: GCP provides more virtual cores based on the memory configuration. The initial configuration of 2048 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                                                    • Number of security operations (protect or unprotect).
                                                                    • Cloud Function max instances and concurrency quota: The instance limit affects how functions are scaled. By default the limit is not set to allow handling any traffic pattern. The instance limit can be set to prevent abnormally high request levels. Cloud Functions are also subject to maximum quota for concurrent invocations and request rate.
                                                                    • Size of data element: Operations on larger text consume time.

                                                                    3.5.2 - Sample Benchmarks

                                                                    Sample benchmarks for Snowflake performance with Cloud Protect.

                                                                    The following benchmarks were performed against different cluster sizes. These are average times of approximately six runs each. The query unprotected six columns per row (first_name, last_name, email, street, city, birthday):

                                                                    Rows x Cols# OpsSmallMediumLarge2XL
                                                                    100K x 6 cols600K3.43.53.33.3
                                                                    1M x 6 cols6M9.08.99.18.7
                                                                    10M x 6 cols60M29.621.918.433.3
                                                                    100M x 6 cols600M--77.076.7

                                                                    3.5.3 - Concurrency

                                                                    Snowflake concurrency considerations.

                                                                    Snowflake provides guidance on the maximum concurrent requests to the Protegrity API. However, reaching this maximum request depends on additional factors, such as, cluster use and available resources. In addition, depending on the query plan, individual batches may be processed serially across different UDFs.

                                                                    The formula for theoretical maximum Snowflake concurrency is N * C * M * E * P:

                                                                    • N - # of servers in the cluster (e.g. 2xl = 32, xl = 16)
                                                                    • C - # of CPUs. This is typically 8, but depends on the hardware.
                                                                    • M – parallelism multiplier (fixed to 8)
                                                                    • E - # of external functions invoked
                                                                    • P - # of queries in running in parallel

                                                                    The following table shows this calculation for a single query.

                                                                    Cluster sizePredicted concurrent per query *1 UDF2 UDF5 UDF10 UDF
                                                                    Medium4 servers x 8 CPU x 8 = 2562565121,2802,560
                                                                    X-Large16 servers x 8 CPU x 8 = 1,0241,0242,0485,12010,240
                                                                    2X-Large32 servers x 8 CPU x 8 = 2,0482,0484,09610,24020,480

                                                                    3.5.4 - Log Forwarder Performance

                                                                    Guidance on Log Forwarder Performance settings and considerations.

                                                                    Log Forwarder Performance

                                                                    Log forwarder architecture is optimized to minimize the amount of connections and reduce the overall network bandwidth required to send audit logs to ESA. This is achieved with batching and aggregation taking place on two levels. The first level is in protector function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching and aggregation takes place in the log forwarder function before audit logs are forwarded to ESA. This section shows how to configure the deployment to accommodate different patterns of anticipated audit log stream. It also shows how to monitor deployment resources to detect problems before audit records are lost.

                                                                                

                                                                    • Protector Function Terraform configuration:

                                                                      • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to Pub/Sub topic. Default value is 30 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The protector function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to Pub/Sub. The protector function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to Pub/Sub. This can be avoided by lowering the interval value.

                                                                                              

                                                                    • Log Forwarder Function Terraform configuration

                                                                      • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to ESA audit log store. Default value is 10 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The forwarder function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to ESA. The forwarder function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to ESA. This can be avoided by lowering the interval value. On the other hand if the interval is too short, forwarder function might end up sending to many requests to ESA, which in some extreme cases may result in messages being sent to dead letter queue.
                                                                      • gen2_available_cpu: Increasing the Function CPU count allows setting higher concurrency, which in turn allows processing more messages from the Pub/Sub in parallel. The high CPU count will effectively lower the number of forwarder function instances which will lower number of connections to ESA.
                                                                      • gen2_container_concurrency: See bullet point above.
                                                                      • audit_log_dead_letter_topic: Dead-letter Pub/Sub topic name. This topic will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ topic can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                                              

                                                                    • Monitoring Log Forwarder Resources

                                                                      • Protector Function Logs: If protector function is unable to send logs to Pub/Sub, it will log the following message:

                                                                        Failed to send x/y audit logs to GCP Pub/Sub.
                                                                        

                                                                        See the description of ‘audit_log_flush_interval’ in the protector function configuration section above to learn about potential mitigation.

                                                                      • Pub/Sub DLQ Topic Metrics: Any positive value in count aggregator on ’topic/message_sizes’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Install Log Forwarder Function via Terraform Scripts

                                                                      • Log Forwarder Function Logs: If log forwarder function is unable to send logs to ESA, it will log the following message:

                                                                        [/jenkins/workspace/iaplambda_release_3.1/src/iap/logging/fluent-bit-external-sink.cpp:225] opensearch.0: Dropped records: x/y.
                                                                        

                                                                        See the description of ‘audit_log_flush_interval’ in the log forwarder configuration section above to learn about potential mitigation.

                                                                    3.6 - Audit Logging

                                                                    Audit log description/formatting

                                                                      Audit Logging

                                                                      Audit records and application logs stream to Google Cloud Logging. Cloud Protect uses a JSON format for audit records that is described in the following sections.

                                                                      You can analyze and alert on audit records using Protegrity ESA or Google Cloud Logging. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Google Cloud Logging, refer to the Google Cloud Logging overview.

                                                                      For more information about audit records, refer to the Protegrity Analytics Guide.

                                                                      Audit record fields

                                                                      The audit record format has been altered in version 3.1 of the protector to provide more information.

                                                                      FieldDescription
                                                                      additional_info.deployment_idThe deployment_id contains the name of the Protect Function. It is automatically set based on the cloud-specific environment variables assigned to the Protect Function. This allows identifying the Cloud Protect deployment responsible for generating audit log.
                                                                      additional_info.cluster(Optional) Redshift cluster ARN
                                                                      additional_info.descriptionA human-readable message describing the operation
                                                                      additional_info.query_id(Optional) Identifies the query that triggered the operation
                                                                      additional_info.request_id(Optional) AWS Lambda request identifier
                                                                      cntNumber of operations, may be aggregated
                                                                      correlationid(Deprecated) Use additional_info instead
                                                                      levelLog severity, one of: SUCCESS, WARNING, ERROR, EXCEPTION
                                                                      logtypeAlways “Protection”
                                                                      origin.ipThe private IP address of the compute resource that operates the Protect Function and is responsible for generating the log entry.
                                                                      origin.hostnameHostname of the system that generated the log entry
                                                                      origin.time_utcUTC timestamp when the log entry was generated
                                                                      protection.audit_codeAudit code of the protect operation; see the log return codes table in the Protegrity Troubleshooting Guide
                                                                      protection.dataelementData element used for the policy operation
                                                                      protection.datastoreName of the data store corresponding to the deployed policy
                                                                      protection.mask_setting(Optional) Mask setting from policy management
                                                                      protection.operationOperation type, one of: Protect, Unprotect, Reprotect
                                                                      protection.policy_userUser that performed the operation
                                                                      protector.core_versionInternal core component version
                                                                      protector.familyAlways “cp” for Cloud Protect
                                                                      protector.lambda_versionProtector Lambda application version.
                                                                      protector.pcc_versionInternal pcc component version
                                                                      protector.vendorIdentifies the cloud vendor and the database vendor
                                                                      protector.versionProtector version number
                                                                      signature.checksumHash value of the signature key ID used to sign the log message when the log is generated
                                                                      signature.key_idKey used to sign the log message when the log is generated

                                                                      The following are sample audit messages:

                                                                      Protect Success:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "Data protect operation was successful.",
                                                                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "SUCESS",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 6,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "lambda_version": "3.2.10",
                                                                              "version": "3.2.0",
                                                                              "vendor": "aws.snowflake",
                                                                              "pcc_version": "3.4.0.14",
                                                                              "core_version": "1.2.1+55.g590fe.HEAD"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      User permission denied:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "The user does not have the appropriate permissions to perform the requested operation."
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "ERROR",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 3,
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "process": {
                                                                              "id": "1",
                                                                              "thread_id": "849348352"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "IAP Lambda",
                                                                              "lambda_version": "3.2.10",
                                                                              "version": "3.2.0",
                                                                              "vendor": "Cloud Protect",
                                                                              "pcc_version": "3.3.0.5",
                                                                              "core_version": "1.1.0"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      Data element not found:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "The data element could not be found in the policy in shared memory."
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "ERROR",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 2,
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "process": {
                                                                              "id": "1",
                                                                              "thread_id": "849348352"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "IAP Lambda",
                                                                              "lambda_version": "3.2.10",
                                                                              "version": "3.2.0",
                                                                              "vendor": "Cloud Protect",
                                                                              "pcc_version": "3.3.0.5",
                                                                              "core_version": "1.1.0"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      Example Audit Records

                                                                      The following are sample audit messages:

                                                                      Protect Success:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "Data protect operation was successful.",
                                                                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "SUCESS",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 6,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "3.1.0",
                                                                              "vendor": "aws.snowflake",
                                                                              "pcc_version": "3.4.0.14",
                                                                              "core_version": "1.2.1+55.g590fe.HEAD"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      Reprotect Success:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "Data reprotect operation was successful.",
                                                                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "SUCCESS",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "old_dataelement": "deAddress1",
                                                                              "dataelement": "deAddress2",
                                                                              "operation": "Reprotect",
                                                                              "audit_code": 50,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "3.1.0",
                                                                              "vendor": "aws.snowflake",
                                                                              "pcc_version": "3.4.0.14",
                                                                              "core_version": "1.2.1+55.g590fe.HEAD"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      User permission denied:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "The user does not have the appropriate permissions to perform the requested operation.",
                                                                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "ERROR",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 3,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "3.1.0",
                                                                              "vendor": "aws.snowflake",
                                                                              "pcc_version": "3.4.0.14",
                                                                              "core_version": "1.2.1+55.g590fe.HEAD"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      Data element not found:

                                                                      {
                                                                            "additional_info": {
                                                                              "description": "The data element could not be found in the policy in shared memory.",
                                                                              "query_id": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                              "request_id": "8476a536-e9f4-11e8-9739-2dfe598c3fcd"
                                                                            },
                                                                            "cnt": 4000,
                                                                            "correlationid": "sf-query-id:01978dbc-0582-d7e4-0000-002a3603a20d",
                                                                            "logtype": "Protection",
                                                                            "level": "ERROR",
                                                                            "origin": {
                                                                              "hostname": "localhost",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 2,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            "client": {},
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "3.1.0",
                                                                              "vendor": "aws.snowflake",
                                                                              "pcc_version": "3.4.0.14",
                                                                              "core_version": "1.2.1+55.g590fe.HEAD"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      3.7 - No Access Behavior

                                                                      Unauthorized unprotect requests behaviour.

                                                                      The security policy maintains a No Access Operation, configured in an ESA, which determines the response for unauthorized unprotect requests.

                                                                      The following table describes the value returned to the UDF function for various cases:

                                                                      No Access OperationData Returned
                                                                      Nullnull
                                                                      Protected(protected value)
                                                                      ExceptionQuery will return an exception

                                                                      3.8 - Upgrading To The Latest Version

                                                                      Instructions for upgrading the protector.

                                                                      3.9 - Known Limitations

                                                                      Known product limitations.
                                                                      • Only protect and unprotect operations are supported. The re-protect operation is not supported.

                                                                      • The Semi-structured (JSON) data type is not supported in the product.

                                                                      • Cloud Function (Gen2) labels must not be updated from the Cloud Run Services console. When updating labels for a GCP Cloud Function (Gen2) through the Cloud Run Services console, GCP creates a new Cloud Run revision with the updated labels, but the underlying Cloud Function retains the old labels. Because the policy agent reads labels from the Cloud Function definition (not the Cloud Run revision), it will not detect the label change and will not trigger a policy update.

                                                                        Cloud Run labels vs Cloud Function labels

                                                                        To avoid this issue, always update labels using one of the following methods:

                                                                        • Cloud Run Functions console — Navigate to Cloud Run Functions, select the function, and update labels there. This ensures both the Cloud Function and its underlying Cloud Run revision are updated consistently.
                                                                        • Terraform — Update the labels variable in your Terraform configuration and run terraform apply.
                                                                        • gcloud CLI — Use gcloud functions deploy with the updated --update-labels flag.

                                                                        If labels were already updated incorrectly through the Cloud Run Services console, redeploy the function using one of the methods above to synchronize the labels and trigger a policy update.

                                                                      3.10 - Appendices

                                                                      Additional references for the protector.

                                                                      3.10.1 - Integrating Cloud Protect with PPC (Protegrity Provisioned Cluster)

                                                                      Concepts for integrating with PPC (Protegrity Provisioned Cluster)

                                                                        This guide describes how to configure the Protegrity Policy Agent and Log Forwarder to connect to a Protegrity Provisioned Cluster (PPC), highlighting the differences from connecting to ESA.

                                                                        Key Differences: PPC vs ESA

                                                                        FeatureESA 10.2PPC (this guide)
                                                                        Datastore Key FingerprintOptional/RecommendedRequired
                                                                        CA Certificate on AgentOptional/RecommendedOptional/Recommended
                                                                        CA Certificate on Log ForwarderOptional/RecommendedNot supported
                                                                        Client Certificate Authentication from Log ForwarderOptional/RecommendedNot supported
                                                                        IP AddressESA IP addressPPC address

                                                                        Prerequisites

                                                                        • Access to PPC and required credentials.
                                                                        • Tools: curl, kubectl installed.

                                                                        Policy Agent Setup with PPC

                                                                        Follow these instructions as a guide for understanding specific inputs for Policy Agent integrating with PPC:

                                                                        1. Obtain the Datastore Key Fingerprint

                                                                          To retrieve the fingerprint for your Policy Agent:

                                                                          1. Retrieve public key from the Cloud Provider Key Management service for the policy encryption key created in pre-configuration:

                                                                            1. Navigate to the Key Management Service in AWS console and open Customer Managed Keys
                                                                            2. Select the desired key
                                                                            3. Select the Public Key tab
                                                                            4. Select Download
                                                                            1. Navigate to the Key Vault in Azure console and open Objects>Keys
                                                                            2. Select the desired key
                                                                            3. Select the key indicated as CURRENT VERSION
                                                                            4. Select Download public key
                                                                            1. Navigate to Key Management in GCP console
                                                                            2. Select the desired key and open the Versions tab
                                                                            3. Select Get public key from the Actions column menu
                                                                            4. Select Download

                                                                          2. Escape the new line characters in the downloaded public key for use in the next step - for example:

                                                                            awk 'NF {printf "%s\\n",$0}' "<public_key_file>" > "new-line-escaped-public-key.pem"
                                                                            cat new-line-escaped-public-key.pem
                                                                            
                                                                          3. Export key fingerprint using the PPC API as indicated in the curl example below:

                                                                            curl -k -H "Authorization: Bearer ${TOKEN}" -X POST https://${HOST}/pty/v2/pim/datastores/1/export/keys  -H "Content-Type: application/json" --data '{
                                                                              "algorithm": "RSA-OAEP-256",
                                                                              "description": "example-key-from-key-management",
                                                                              "pem": "<value of new-line-escaped-public-key>"
                                                                            }'
                                                                            

                                                                            Sample Output:

                                                                            {"uid":"1","algorithm":"RSA-OAEP-256","fingerprint":"4c:46:d8:05:35:2e:eb:39:4d:39:8e:6f:28:c3:ab:d3:bc:9e:7a:cb:95:cb:b1:8e:b5:90:21:0f:d3:2c:0b:27","description":"example-key-from-kms"}
                                                                            
                                                                          4. Record the value for fingerprint and configure the Policy Agent:

                                                                            Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Lambda function to the fingerprint value.

                                                                            Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Function App to the fingerprint value.

                                                                            Set the variable in Policy Agent main.tf pty_datastore_key to the fingerprint value and apply the changes.

                                                                        2. Retrieve the PPC CA Certificate

                                                                          To obtain the CA certificate from PPC:

                                                                          kubectl -n api-gateway get secret ingress-certificate-secret -o jsonpath='{.data.ca\.crt}' | base64 -d > CA.pem
                                                                          

                                                                          Use the ProtegrityCA.pem that was returned as described in Policy Agent Installation.

                                                                        3. Configure the PPC Address

                                                                          Use the PPC address in place of the ESA IP address wherever required in your configuration.

                                                                        Log Forwarder Setup with PPC

                                                                        • The Log Forwarder will proceed without certificates and will print a warning if PTY_ESA_CA_SERVER_CERT is not provided.
                                                                        • No additional certificate or CA configuration is needed for PPC.

                                                                        3.10.2 - Sample Snowflake External Function

                                                                        Sample Snowflake External Function definitions and calls for tokenization data elements.

                                                                        Appendix A. Sample Snowflake External Function

                                                                        Method: Tokenization

                                                                        Type: ALPHA

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        VARCHAR

                                                                        16M (16,777,216 bytes)

                                                                        4K (4,096 bytes)

                                                                        CHAR

                                                                        STRING

                                                                        TEXT

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_ALPHA ( val varchar ) 
                                                                          RETURNS varchar 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using an ALPHA data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                          'X-Protegrity-HCoP-Rules'=
                                                                          '{"jsonpaths": [{"op_type":"PROTECT","data_element":"TOK_ALPHA"}]}'
                                                                          )
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_ALPHA ( val varchar ) 
                                                                          RETURNS varchar 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using an ALPHA data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_ALPHA"}]}'
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                         

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_ALPHA ('Hello World')
                                                                        
                                                                        SELECT PTY_UNPROTECT_ALPHA('rfDtw sLMJK');
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy alpha_policy as (val string) returns string -> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_ALPHA(val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field01 set masking policy alpha_policy; 
                                                                        alter table pii_data modify column field01 unset masking policy;
                                                                        

                                                                        Method: Tokenization

                                                                        Type: NUMERIC

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        NUMBER

                                                                         

                                                                         

                                                                        DECIMAL

                                                                        INTEGER

                                                                        DOUBLE

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_NUMERIC ( val number ) 
                                                                          RETURNS number 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using a NUMERIC data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_NUMERIC"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_NUMERIC ( val number) 
                                                                          RETURNS number 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using a NUMERIC data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_NUMERIC"}]}'
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                         

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_NUMERIC ('123456789');
                                                                        
                                                                        SELECT PTY_UNPROTECT_NUMERIC ('752513497');
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy num_policy as (val number) returns number -> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_NUMERIC(val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field02 set masking policy num_policy; 
                                                                        alter table pii_data modify column field02 unset masking policy;
                                                                        

                                                                        Method: Tokenization

                                                                        Type: DATE YYYY-MM-DD

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        DATE (any supported format)

                                                                        10 bytes

                                                                        10 bytes

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_DATEYYYYMMDD ( val date ) 
                                                                          RETURNS date 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using a Date data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_DATEYYYYMMDD"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_DATEYYYYMMDD ( val date ) 
                                                                          RETURNS date 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using a Date data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_DATEYYYYMMDD"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_DATEYYYYMMDD ('2020-12-31');
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATEYYYYMMDD('0653-06-01');
                                                                        
                                                                        SELECT PTY_PROTECT_DATEYYYYMMDD ('31-DEC-2020');*
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATEYYYYMMDD('01-JUN-0653');*
                                                                        
                                                                        SELECT PTY_PROTECT_DATEYYYYMMDD('12/31/2020');*
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATEYYYYMMDD('06/01/0653');*
                                                                        
                                                                        SELECT PTY_PROTECT_DATEYYYYMMDD (current_date);
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy date_policy as (val date) returns date -> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_DATEYYYYMMDD (val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field11 set masking policy date_policy; 
                                                                        alter table pii_data modify column field11 unset masking policy;
                                                                        
                                                                        *: Automatic cast to YYYY-MM-DD, no need to make any conversions. The output is always in the YYYY-MM-DD format

                                                                        Cutover Dates of the Proleptic Gregorian Calendar: no issues (no conversions performed by Snowflake)

                                                                        Method: Tokenization

                                                                        Type: DATETIME

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        DATE

                                                                        10 bytes

                                                                        29 bytes

                                                                        DATETIME

                                                                        29 bytes

                                                                        TIMESTAMPNTZ*

                                                                        TIMESTAMP_NTZ*

                                                                        TIMESTAMP WITHOUT TIME ZONE*

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_DATETIME ( val timestamp ) 
                                                                          RETURNS timestamp 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using a TIMESTAMP data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_DATETIME"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_DATETIME ( val timestamp ) 
                                                                          RETURNS timestamp 
                                                                          NOT NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using a TIMESTAMP data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_DATETIME"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_DATETIME('2010-10-25');
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATETIME('0845-04-04');
                                                                        
                                                                        SELECT PTY_PROTECT_DATETIME('2010-10-25 10:45:33');
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATETIME('0845-04-04 10:45:33');
                                                                        
                                                                        SELECT PTY_PROTECT_DATETIME('2010-10-25 10:45:33.123');
                                                                        
                                                                        SELECT PTY_UNPROTECT_DATETIME('0845-04-04 10:45:33.123');
                                                                        
                                                                        SELECT PTY_PROTECT_DATETIME(current_date);
                                                                        
                                                                        SELECT PTY_PROTECT_DATETIME(cast(current_timestamp as TIMESTAMPNTZ));
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy datetime_policy as (val timestampntz) returns timestampntz -> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_DATETIME (val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field12 set masking policy datetime_policy; 
                                                                        alter table pii_data modify column field12 unset masking policy;
                                                                        
                                                                        *: Default TIMESTAMP in Snowflake includes Time Zone – not supported by Protegrity’s DATETIME data element

                                                                        Method: Tokenization

                                                                        Type: DECIMAL

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        NUMBER(N,M)

                                                                        38 digits

                                                                        36 digits

                                                                        NUMERIC(N,M)*

                                                                        DECIMAL(N,M)*

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_DECIMAL ( val NUMBER(38,6) ) 
                                                                          RETURNS NUMBER(38,6) 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using a DECIMAL data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_DECIMAL"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_DECIMAL ( val NUMBER(38,6) ) 
                                                                          RETURNS NUMBER(38,6) 
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using a DECIMAL data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_DECIMAL"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_DECIMAL (12345678.99);
                                                                        
                                                                        SELECT PTY_UNPROTECT_DECIMAL (21872469.760000);
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy decimal_policy as (val NUMBER(38,6)) returns NUMBER(38,6)-> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_DECIMAL (val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field13 set masking policy decimal_policy; 
                                                                        alter table pii_data modify column field13 unset masking policy;
                                                                        
                                                                        *: Synonymous with NUMBER

                                                                        Method: Tokenization

                                                                        Type: INTEGER

                                                                         

                                                                        Snowflake Data Types

                                                                        Snowflake Max Size

                                                                        Protegrity Max Size

                                                                        NUMBER

                                                                        38 digits

                                                                        2 bytes

                                                                        4 bytes

                                                                        8 bytes

                                                                        NUMERIC*

                                                                        INT*

                                                                        INTEGER*

                                                                        BIGINT*

                                                                        SMALLINT*

                                                                        TINYINT*

                                                                        BYTEINT*

                                                                         

                                                                        External Function Sample Definitions:

                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_PROTECT_INTEGER ( val NUMBER ) 
                                                                          RETURNS NUMBER
                                                                          NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Protects using an INTEGER data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"PROTECT","data_element":"TOK_INTEGER"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        
                                                                        CREATE SECURE EXTERNAL FUNCTION PTY_UNPROTECT_INTEGER ( val NUMBER ) 
                                                                          RETURNS NUMBER 
                                                                          NOT NULL 
                                                                          IMMUTABLE 
                                                                          COMMENT = 'Unprotects using an INTEGER data element'  
                                                                          API_INTEGRATION = REPLACE_WITH_YOUR_API_INTEGRATION_ID 
                                                                          HEADERS =(  
                                                                            'X-Protegrity-HCoP-Rules'=
                                                                            '{"jsonpaths":[{"op_type":"UNPROTECT","data_element":"TOK_INTEGER"}]}'    
                                                                          ) 
                                                                          CONTEXT_HEADERS = ( current_user, current_timestamp, current_account ) 
                                                                          AS '<api_gateway_protect_service_url>/pty/snowflake';
                                                                        

                                                                        Sample EF Calls:

                                                                        SELECT PTY_PROTECT_INTEGER (123456789);
                                                                        
                                                                        SELECT PTY_UNPROTECT_INTEGER (1104108887);
                                                                        

                                                                         

                                                                        Snowflake Masking Policy example:

                                                                        create or replace masking policy int_policy as (val NUMBER ) returns NUMBER -> 
                                                                         case 
                                                                         when current_role() in ('ACCOUNTADMIN') then PTY_UNPROTECT_INTEGER (val) 
                                                                         else val 
                                                                        end;
                                                                        
                                                                        alter table pii_data modify column field14 set masking policy int_policy; 
                                                                        alter table pii_data modify column field14 unset masking policy;
                                                                        
                                                                        *: Synonymous with NUMBER, except that precision and scale cannot be specified \(i.e. always defaults to NUMBER\(38, 0\)\)

                                                                        **Recommended approach for protecting whole numbers fields in Snowflake

                                                                        When values are…then use the following Data Element:
                                                                        Between -32768 and 32767INTEGER (2 bytes)
                                                                        Between -2147483648 and 2147483647INTEGER (4 bytes)
                                                                        Between -9223372036854775808 and 9223372036854775807INTEGER (8 bytes)
                                                                        < -9223372036854775808 or > 9223372036854775807DECIMAL

                                                                        When in doubt, use DECIMAL for any numeric range.

                                                                        3.10.3 - Configuring Regular Expression to Extract Policy Username

                                                                        Example configurations for user extraction with regular expressions

                                                                        Configuring Regular Expression to Extract Policy Username

                                                                        Cloud Protect Cloud Function exposes USERNAME_REGEX configuration to allow extraction of policy username from user in the request.

                                                                        • USERNAME_REGEX Cloud Function Environment configuration

                                                                          The USERNAME_REGEX environment variable can be set to contain regular expression with one capturing group. This group is used to extract the username. Examples below show different regular expression values and the resulting policy user.

                                                                        USERNAME_REGEX

                                                                        User in the request

                                                                        Effective Policy User

                                                                        Not Set

                                                                        user@domain.com

                                                                        user@domain.com

                                                                        service-account-user@project-id.iam.gserviceaccount.com

                                                                        service-account-user@project-id.iam.gserviceaccount.com

                                                                        ^(.*)@.*$
                                                                        

                                                                        service-account-user@project-id.iam.gserviceaccount.com

                                                                        service-account-user

                                                                        user@domain.com

                                                                        user

                                                                        3.10.4 - Associating ESA Data Store With Cloud Protect Agent

                                                                        ESA controls policy access by mapping server IPs to data stores, registering a node when an agent requests a policy and its IP is identified.

                                                                        ESA controls which policy is deployed to protector using concept of data store. A data store may contain a list of IP addresses identifying servers allowed to pull the policy associated with that specific data store. Data store may also be defined as default data store, which allows any server to pull the policy, provided it does not belong to any other data stores. Node registration occurs when the policy server (in this case the policy agent) makes a policy request to ESA, where the agent’s IP address is identified by ESA.

                                                                        Policy agent function source IP address used for node registration on ESA depends on ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP and the PTY_ADDIPADDRESSHEADER configuration exposed by the agent function.

                                                                        The function service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range described in Function app outbound IP addresses section under function configuration. By default, when agent function is contacting ESA to register node for policy download, ESA uses agent function outbound IP address. This default behavior is caused by the default ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP=false and agent default configuration PTY_ADDIPADDRESSHEADER=yes.

                                                                        In some cases, when there is a proxy server between the ESA and agent function, the desirable ESA configuration is ASSIGN_DATASTORE_USING_NODE_IP=true. and PTY_ADDIPADDRESSHEADER=no which will cause the ESA to use proxy server IP address.

                                                                        The table below shows how the hubcontroller and agent settings will affect node IP registration on ESA.

                                                                        Agent source IPAgent Function Outbound IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent function config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                                                                        169.254.144.8120.75.43.207No Proxytrueyes169.254.144.81
                                                                        trueno20.75.43.207
                                                                        falseyes
                                                                        falseno
                                                                        169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                                                                        trueno34.230.42.110
                                                                        falseyes
                                                                        falseno

                                                                        3.10.5 - Undeliverable Audit Log Recovery

                                                                        Audit log recovery procedures

                                                                          Protegrity Cloud Protect Log Forwarder installation provides a solution to recover undelivered audit logs. Reasons for undeliverable logs may include:

                                                                          • Changes to network configuration in ESA or cloud provider (VPC, firewall, certificate rotation, service user credentials)
                                                                          • Log Forwarder IAM Service Account permissions
                                                                          • Log Forwarder Cloud Run Function configuration
                                                                          • Disruption in cloud provider service

                                                                          Log Forwarder Dead Letter Pub/Sub Architecture

                                                                          Log Forwarder is triggered by pub/sub events generated by Protect Functions. If Log Forwarder is unable to reach ESA to deliver the logs, they are pushed to a dead letter pub/sub topic. Dead letter pub/sub topic is created when installing the Log Forwarder with the service installation script. See Install Log Forwarder Function via Terraform Scripts for dead letter topic configuration options and naming conventions.

                                                                          Logs are not delivered to ESA. Undelivered audit logs are sent to a dead letter pub/sub topic.

                                                                          Monitoring Undelivered Logs

                                                                          Logs pushed to the dead letter pub/sub topic will be purged and no longer recoverable when specified dlq_topic_message_retention_duration has been reached. Monitoring the dead letter topic is recommended to ensure timely recovery of audit messages before they are permanently lost. Consult the GCP monitoring alerts documentation for setting up alerts based on pub/sub topic metrics.

                                                                          Protegrity recommends creation of an additional Log Forwarder installation in the case where logs are not delivered to ESA, as described in Log Forwarder Dead Letter Pub/Sub Architecture.

                                                                          Audit log recovery using new log forwarder installation

                                                                          Steps to recover audit logs using new Log Forwarder installation:

                                                                          1. Create a second Log Forwarder installation (Log Forwarder 2 in the above diagram) for processing undelivered logs. Value for audit_log_dead_letter_topic in the terraform script should be set to null during installation.

                                                                          2. Configure and test newly installed Log Forwarder to verify ESA connectivity. See Install Log Forwarder Function via Terraform Scripts for installation instructions.

                                                                          3. Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                                            terraform output
                                                                            

                                                                            for the Log Forwarder which failed to deliver logs (Log Forwarder as described in Log Forwarder Dead Letter Pub/Sub Architecture). Note the value for audit_log_dlq_topic.

                                                                          4. Set audit_log_dead_letter_topic in the new Log Forwarder (Log Forwarder 2 in the above diagram) terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with terraform apply.

                                                                          5. Monitor the new Log Forwarder function logs for any failures.

                                                                          Recovering Logs in Dead Letter Topic (Alternative)

                                                                          When the recommended method of for recovery described in Recovering Logs in Dead Letter Topic (Recommended) is not an option, you may use the existing Log Forwarder to reprocess undelivered logs.

                                                                          Audit log recovery using existing log forwarder installation

                                                                          Steps to recover audit logs using existing Log Forwarder installation:

                                                                          • Fix any configuration errors causing the Log Forwarder to fail. Verify audit logs are being transmitted successfully to ESA.

                                                                          • Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                                            terraform output
                                                                            

                                                                            for the Log Forwarder. Note the value for audit_log_dlq_topic.

                                                                          • Set audit_log_dead_letter_topic in the terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with

                                                                            terraform apply
                                                                            
                                                                          • When audit logs have been transmitted to ESA, revert setting audit_log_dead_letter_topic to null Apply the changes with

                                                                            terraform apply
                                                                            

                                                                          3.11 -

                                                                          Solution Overview

                                                                          Snowflake Protector on Google Cloud is a cloud native, serverless product for fine-grained data protection with Snowflake™, a managed Cloud data warehouse. This enables invocation of the Protegrity data protection cryptographic methods from the Snowflake SQL execution context. The benefits of serverless include rapid auto-scaling, performance, low administrative overhead, and reduced infrastructure costs compared to a server-based solution.

                                                                          This product provides data protection services invoked by External User Defined Functions (UDFs) within Snowflake. The UDFs act as a client transmitting micro-batches of data to the serverless Protegrity Cloud function. User queries may generate hundreds or thousands of parallel requests to perform security operations. Protegrity’s serverless function is designed to scale and yield reliable query performance under such load.

                                                                          Snowflake Protector on Google Cloud utilizes a data security policy maintained by an Enterprise Security Administrator (ESA), similar to other Protegrity products. Using regular SQL database queries or tools, such as, Tableau™, authorized users can perform de-identification (protect) and re-identification (unprotect) operations on data within the managed Cloud data warehouse. A user’s individual capabilities are subject to privileges and policies defined by the Enterprise Security Administrator.

                                                                          The following data ingestion patterns are available with your managed Cloud data warehouse:

                                                                          • Data protection at source applications: In this case, sensitive data is already de-identified (protected) across the enterprise wherever it resides, including the managed data warehouse. Protected data can be ingested directly into your managed Cloud data warehouse. Depending on usage patterns, this ensures that your managed data warehouse is not brought into scope for PCI, PII, GDPR, HIPPA, and other compliance policies.
                                                                          • Data protection using the Extract-Transform-Load (ETL) pattern: In this case, sensitive data may be transformed with a Protegrity protector either on-premise or in the Cloud before it is ingested into Snowflake.
                                                                          • Data protection using the Extract-Load-Transform (ELT) pattern: In this case, sensitive data is protected after it lands into the target system typically through a temporary landing table. It uses the native data warehouse’s compute engine with Protegrity to protect incoming data at very high throughput rates. After the data is protected, the intermediate loading tables are dropped as part of the ingestion workflow.

                                                                          4 -

                                                                          Certificates on ESA

                                                                          By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Cloud Function Environment variables configuration.

                                                                          In case ESA is configured with publicly signed certificates, this section can be skipped since the Cloud Function will use public CA to validate ESA certificates.

                                                                          To obtain self-signed CA certificate from ESA:

                                                                          1. Log in to ESA Web UI.

                                                                          2. Select Settings > Network > Manage Certificates.

                                                                          3. Hover over Server Certificate and click on download icon to download the CA certificate.

                                                                          4. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                                                            To escape new lines from command line, use one of the following commands depending on your operating system:

                                                                            Linux Bash:

                                                                            awk 'NF {printf "%s\\n",$0;}' ProtegrityCA.pem > output.txt
                                                                            

                                                                            Windows PowerShell:

                                                                            (Get-Content '.\ProtegrityCA.pem') -join '\n' | Set-Content 'output.txt'
                                                                            
                                                                          5. Record the certificate content with new lines escaped.

                                                                            ESA CA Server Certificate (EsaCaCert): ___________________

                                                                            This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section.

                                                                          For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                                                          5 -

                                                                          Creating ESA Credentials

                                                                          Policy Agent Function requires ESA credentials to be provided as one of the two options:

                                                                          Secret Manager

                                                                          Secret Manager is the recommended option for storing ESA credentials.

                                                                          Create ESA credentials secrets:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Go to Security > Secret Manager.

                                                                          3. Select CREATE SECRET.

                                                                          4. Specify the Secret Value:

                                                                            {
                                                                              "username": "{esa_username}", 
                                                                              "password": "{esa_password}"
                                                                            }
                                                                            
                                                                          5. Select Create Secret.

                                                                          6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                                                          7. Click on Actions, next to the secret version you just created.

                                                                          8. Select Copy Resource ID and record the full secret version path, For example, projects/{project-id}/secrets/{secret name}/versions/2.

                                                                            Secret resource id: ___________________

                                                                          Custom Cloud Function

                                                                          If you have the skills to write code, you may provide a custom Cloud Function that returns the ESA credentials to the Policy Agent. One use case is when reading the ESA credentials from a third-party password vault.

                                                                          Create the Cloud Function:

                                                                          1. Create a new 2nd gen Cloud Function using any runtime.

                                                                            1. The Policy Agent does not provide an input payload.

                                                                            2. The Cloud Function must return a response according to the following schema:

                                                                              response: 
                                                                                type: object 
                                                                                  properties: 
                                                                                    username: string 
                                                                                    password: string
                                                                              

                                                                              For example,

                                                                              example output: {"username": "admin", "password": "Password1234"} 
                                                                              
                                                                            3. Sample GCP Function in Python:

                                                                              def handler(request): 
                                                                                  return {"username": "admin", "password": "password1234"} 
                                                                              
                                                                          2. Grant the Cloud Run Invoker role to the Policy Agent function service account.

                                                                          3. Grant the cloudfunctions.functions.get permission to the Policy Agent function service account role.

                                                                          4. Record the Function name:

                                                                            ESA CREDENTIALS FUNCTION NAME: _______________

                                                                          6 -

                                                                          Custom Cloud Function

                                                                          If you have the skills to write code, you may provide a custom Cloud Function that returns the ESA credentials to the Policy Agent. One use case is when reading the ESA credentials from a third-party password vault.

                                                                          Create the Cloud Function:

                                                                          1. Create a new 2nd gen Cloud Function using any runtime.

                                                                            1. The Policy Agent does not provide an input payload.

                                                                            2. The Cloud Function must return a response according to the following schema:

                                                                              response: 
                                                                                type: object 
                                                                                  properties: 
                                                                                    username: string 
                                                                                    password: string
                                                                              

                                                                              For example,

                                                                              example output: {"username": "admin", "password": "Password1234"} 
                                                                              
                                                                            3. Sample GCP Function in Python:

                                                                              def handler(request): 
                                                                                  return {"username": "admin", "password": "password1234"} 
                                                                              
                                                                          2. Grant the Cloud Run Invoker role to the Policy Agent function service account.

                                                                          3. Grant the cloudfunctions.functions.get permission to the Policy Agent function service account role.

                                                                          4. Record the Function name:

                                                                            ESA CREDENTIALS FUNCTION NAME: _______________

                                                                          7 -

                                                                          Secret Manager

                                                                          Secret Manager is the recommended option for storing ESA credentials.

                                                                          Create ESA credentials secrets:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Go to Security > Secret Manager.

                                                                          3. Select CREATE SECRET.

                                                                          4. Specify the Secret Value:

                                                                            {
                                                                              "username": "{esa_username}", 
                                                                              "password": "{esa_password}"
                                                                            }
                                                                            
                                                                          5. Select Create Secret.

                                                                          6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                                                          7. Click on Actions, next to the secret version you just created.

                                                                          8. Select Copy Resource ID and record the full secret version path, For example, projects/{project-id}/secrets/{secret name}/versions/2.

                                                                            Secret resource id: ___________________

                                                                          8 -

                                                                          ESA Server

                                                                          Policy Agent function requires ESA server running and accessible from Agent Cloud Function on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted.

                                                                          Note down ESA IP address:

                                                                          ESA IP Address (EsaIpAddress): ___________________

                                                                          9 -

                                                                          Identify or Create a new VPC

                                                                          Google Cloud VPC is used to route traffic from Policy Agent Cloud Function to ESA. If your ESA is in a Google Cloud VPC, it is recommended to create a serverless VPC access and record its name:

                                                                          google_vpc_access_connector_name: ___________________

                                                                          If ESA is not on Google Cloud VPC, you can either create one or choose to let Terraform script to create one. The Terraform script will create the following elements:

                                                                          • NAT gateway

                                                                            To connect to ESA outside the Google Cloud Network

                                                                          • External IP address

                                                                            Can add it to the allowlist by the firewall in the network environment where ESA is hosted.

                                                                          • Serverless VPC access

                                                                            Allows connectivity from the Cloud function to the VPC.

                                                                          10 -

                                                                          Install Policy Agent Function through Terraform Scripts

                                                                          Agent Terraform scripts provided by Protegrity create a Cloud Function in your Google account. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can also create the following optional resources by specifying the corresponding parameters:

                                                                          • Service account with IAM role
                                                                          • VPC with NAT external IP
                                                                          • VPC access connector

                                                                          To install Policy Agent Function through Terraform:

                                                                          1. From command shell, move to the directory where you downloaded Protegrity installation bundle.

                                                                          2. Unzip the bundle, then unzip the protegrity-agent-gcp-{version}.zip. Verify that the following files are available:

                                                                            • pty-agent-gcp/
                                                                            • main.tf
                                                                            • outputs.tf
                                                                            • README.md
                                                                          3. Open the main.tf file and update Terraform backend information at the top of the file:

                                                                            
                                                                            terraform {
                                                                              backend "gcs" {
                                                                                bucket  = ""
                                                                                prefix  = "protegrity/terraform/pty-protect-gcp/state"
                                                                              }
                                                                            }
                                                                            
                                                                          4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                                                          5. Set the prefix property with value unique to your deployment.

                                                                          6. In the same main.tf file, specify the following Terraform variables.

                                                                            ParameterDescription
                                                                            project_idThe Project ID recorded in the pre-configuration step
                                                                            regionThe Region recorded in the pre-configuration step, for example, us-central1.
                                                                            deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                                                            deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                                                            deployment_bucket_locationGeographical location of deployment bucket, e.g., US, EU, ASIA.
                                                                            deployment_file_directory_pathPath to directory where deployment zip file is located. By default the deployment file should be in the same directory as this main.tf file.
                                                                            policy_download_cron_expressionCron expression determining how often policy agent function will run to synchronize security policy from ESA.
                                                                            create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                                                            agent_function_service_account_emailUse Agent Function Service account recorded in pre-configuration or leave empty.
                                                                            create_vpcSet this to true, if you would like to create VPC with NAT, external IP and vpc access connector, otherwise leave empty. This will be ignored if google_vpc_access_connector_name is specified.
                                                                            google_vpc_access_connector_nameSpecify the existing VPC access connector name you identified in earlier step, otherwise leave empty. This setting will disable create_vpc = true.
                                                                            google_vpc_access_connector_full_resource_nameAlternative configuration for VPC access connector. If this parameter is set the google_vpc_access_connector_name will be ignored. Use this parameter, if vpc connector is in different region/project that the one specified for the deployment.
                                                                            labelsYou can set this map to include labels for deployed resources. Pay attention to gcp label requirements. More information in: https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.

                                                                            All the values were recorded in Pre-Configuration and this section’s previous steps.

                                                                          7. Provide Policy update Terraform variables. In the same main.tf file, you can specify configuration related to policy update. Any of these variables can be updated at any given time by running the terraform again or directly in the GCP Console. Most of the values were recorded in previous installation steps.

                                                                            Parameter

                                                                            Description

                                                                            Notes

                                                                            pty_esa_ip

                                                                            ESA IP address or hostname

                                                                            ESA Server

                                                                            pty_esa_ca_server_cert

                                                                            ESA self-signed CA certificate used by policy Agent Function to ensure ESA is the trusted server.

                                                                            Recorded in step Certificates on ESA

                                                                            In case ESA is configured with publicly signed certificates, the pty_esa_ca_server_cert configuration will be ignored.

                                                                            gcp_esa_credentials_secret_resource_id

                                                                            ESA username and password (encrypted value by Google Cloud Secrets Manager). For example, projects/{project-id}/secrets/{secret name}/versions/{version}

                                                                            Creating ESA Credentials

                                                                            pty_esa_credentials_function

                                                                            ESA credentials GCP function resource name. For example, projects/{project-name}/locations/{region}/functions/{esa-credentials-function-name}.

                                                                            Recorded in step Option 2: Custom Cloud Function ESA CREDENTIALS FUNCTION NAME. Presence of gcp_esa_credentials_secret_resource_id will cause this value to be ignored. The Policy Agent Function must have network access and IAM permissions to call the ESA Credentials function you have created in Option 2: Custom Cloud Function.

                                                                            gcp_kms_key_resource_name

                                                                            The Key full resource name. For Example, projects/{project-id}/locations/region/keyRings/ {key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                                                            Key Management Service

                                                                            gcp_protect_function_resource_name

                                                                            List of comma separated Protect function resource names. For Example, projects/{project-id}/ locations/{region}/functions/{function-name1},projects/{project-id}/ locations/{region}/functions/{function-name2}

                                                                            Use protect_function_resource_name recorded in Protect Service Installation section.

                                                                            gcp_policy_retention_storage_bucket

                                                                            Deployment Bucket Name where the encrypted policy will be written.

                                                                            You can use deployment bucket recorded in Google Cloud Storage section, or you can specify other existing bucket.

                                                                            gcp_policy_version_object_key

                                                                            Filename of the encrypted policy stored in the Deployment Bucket Name

                                                                            Default: policy.zip

                                                                            retain_policy_versions

                                                                            Number of policy versions to retain as backup. (e.g. 2 will retain the latest 2 policies and remove older ones). -1 retains all.

                                                                            Default: 10

                                                                            disable_deploy

                                                                            This flag can be either 1 or 0. If set to 1, then the agent will not update protector function with the newest policy. Else, the policy will be saved in the cloud storage bucket and deployed to the protector function.

                                                                            Default: 0

                                                                            log_level

                                                                            Application and audit logs verbiage level

                                                                            Default: INFO. Allowed values: DEBUG – the most verbose INFO, WARNING, ERROR – the least verbose

                                                                            policy_pull_timeout

                                                                            Time in seconds to wait for the ESA to send the full policy

                                                                            Default: 20

                                                                            pty_core_casesensitive

                                                                            Specifies whether policy usernames should be case sensitive

                                                                            Default: no. Allowed values: yes, no

                                                                            pty_core_emptystring

                                                                            Override default behavior. Empty string response values are returned as null values. For instance, (un)protect(’’) -> null (un)protect(’’) -> ''

                                                                            Default: empty. Allowed values: null, empty

                                                                            esa_connection_timeout

                                                                            Time in seconds to wait for the ESA response

                                                                            Default: 5s

                                                                            pty_addipaddressheader

                                                                            When enabled, agent will send its source IP address in the request header. This configuration works in conjunction with ESA hubcontroller configuration ASSIGN_DATASTORE_USING_NODE_IP (default=false). See Associating ESA Data Store With Cloud Protect Agent for more information.

                                                                            Default: yes. Allowed values: yes, no

                                                                            pty_datastore_key

                                                                            ESA policy datastore public key fingerprint (64 char long) e.g. 123bff642f621123d845f006c6bfff27737b21299e8a2ef6380aa642e76e89e5.

                                                                            The export key is the public part of an asymmetric key pair created in a Create KMS Key. A user with Security Officer permissions adds the public key to the data store in ESA via Policy Management > Data Stores > Export Keys. The fingerprint can then be copied using the Copy Fingerprint icon next to the key. Refer to Exporting Keys to Datastore for details.

                                                                            pty_sync_datastore

                                                                            Optional name of the policy datastore to sync with ESA. Refer to ESA documentation for more information on policy datastore sync.

                                                                            Default: ""
                                                                          8. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                                                            protegrity-agent-gcp-{version}/pty-agent-gcp/
                                                                            
                                                                          9. Run terraform init.

                                                                            Terraform will download necessary providers.

                                                                          10. Run terraform plan to verify configuration and print out deployment plan.

                                                                          11. Run terraform apply to deploy resources to your account. Once deployment is complete, Terraform will print output variables.

                                                                          12. Below is the sample output from successful deployment.

                                                                            
                                                                                    Apply complete! Resources: 1 added, 0 changed, 0 destroyed. 
                                                                                    Outputs: 
                                                                                    agent_function_service_account_email = "pty-agent-test@test.iam.gserviceaccount.com" 
                                                                                    deployment_bucket_name = "test-bucket" 
                                                                                    nat_ip = 0 
                                                                                    policy_agent_function_deployment_object = "pty-agent-test-1.0.1.zip" 
                                                                                    policy_agent_function_name = "pty-agent-test" 
                                                                            

                                                                          11 -

                                                                          Test Agent Function Installation

                                                                          After configuration is complete, you can test the function.

                                                                          To test and run the Policy Agent Function:

                                                                          1. From the Google Cloud console, go to Cloud Run Functions or Cloud Run.

                                                                          2. Click on the function you just deployed: pty_agent_{deployment_id}.

                                                                          3. Click Test button at the top right section of the screen.

                                                                          4. Scroll down to CLI test command.

                                                                          5. Copy and run the curl command to trigger the agent. Alternatively, use the option Test in Cloud Shell.

                                                                          6. Wait for the function to complete.

                                                                          7. Navigate to the LOGS tab to view agent execution logs.

                                                                          8. Alternatively, you may review the logs by navigating to Logging from your Google Console. In the Log Explorer select the All resources dropdown, then Cloud Run Revision > pty-agent-{deployment-id} and apply.

                                                                            
                                                                            Function execution took 23892 ms, finished with status: 'ok'
                                                                            iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_21-00-00.zip]
                                                                            iap.policy_deployer:INFO:Deleting object [policy_v07-26-2021_19-03-23.zip]
                                                                            iap.policy_deployer:INFO:Removing old function versions in [test-artifacts]. Will retain [1] versions.
                                                                            iap.policy_deployer:INFO:Updating function [projects/cloud-engineering-315519/locations/us-central1/functions/pty-protect-test] with new deployment artifact [test-artifacts/policy_v07-26-2021_21-00-01.zip] ...
                                                                            iap.imp_creator:INFO:Uploading encrypted policy data to: [test-artifacts/policy_v07-26-2021_19-03-23.zip]
                                                                            iap.imp_creator:INFO:Preparing deployment package ...
                                                                            iap_agent_gcp.cloud_functions_util:INFO:Downloading function deployment package ...
                                                                            iap.imp_creator:INFO:Encrypting policy package ...
                                                                            iap.policy_agent:INFO:Preparing new policy deployment ...
                                                                            iap.policy_agent:WARNING:Current policy deployment has no checksum_mapping metadata:
                                                                            iap.imp_creator:INFO:Checking current policy version ...
                                                                            iap.policy_agent:INFO:Current deployment package version: [policy_v07-26-2021_18-51-43.zip].
                                                                            iap.policy_agent:INFO:Getting current policy metadata ...
                                                                            iap.imp_creator:INFO:Policy downloaded successfully ...
                                                                            iap.imp_creator:INFO:PepServer started ...
                                                                            iap.imp_creator:INFO:Starting PepServer ...
                                                                            iap.imp_creator:INFO:PepServer configured successfully
                                                                            iap.imp_creator:INFO:Downloading certificates from ESA ...
                                                                            iap.imp_creator:INFO:Configuring PepServer ...
                                                                            iap.policy_agent:INFO:Starting policy agent ...
                                                                            iap.policy_agent:INFO:Using Secret Manager [GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID] to retreive ESA credentials.
                                                                            iap.policy_agent:INFO:PTY_CORE_CASESENSITIVE [no]
                                                                            iap.policy_agent:INFO:PTY_CORE_EMPTYSTRING [empty]
                                                                            iap.policy_agent:INFO:RETAIN_POLICY_VERSIONS [1]
                                                                            iap.policy_agent:INFO:GCP_PROTECT_FUNCTION_RESOURCE_NAME [projects/test/locations/us-central1/functions/pty-protect-test]
                                                                            iap.policy_agent:INFO:GCP_POLICY_VERSION_OBJECT_KEY [policy.zip]
                                                                            iap.policy_agent:INFO:GCP_POLICY_RETENTION_STORAGE_BUCKET [test-artifacts]
                                                                            iap.policy_agent:INFO:GCP_KMS_KEY_RESOURCE_NAME [projects/test/locations/us-central1/keyRings/test-key-ring/cryptoKeys/test-protect-asymmetric/cryptoKeyVersions/1]
                                                                            iap.policy_agent:INFO:GCP_ESA_CREDENTIALS_SECRET_RESOURCE_ID [projects/1234/secrets/ESA_ADMIN_CREDENTIALS/versions/2]
                                                                            iap.policy_agent:INFO:PTY_ESA_IP [54.236.107.39]
                                                                            iap.policy_agent:INFO:POLICY_PULL_TIMEOUT [20]
                                                                            iap.policy_agent:INFO:DISABLE_DEPLOY [0]
                                                                            Function execution started
                                                                            

                                                                          12 -

                                                                          Troubleshooting

                                                                          Configure additional logging:

                                                                          1. Set log_level Terraform variable on the Agent function to DEBUG.

                                                                          2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                                                            resource.type="cloud_run_revision"
                                                                            resource.labels.service_name=~"pty-agent-<deploymentd-id>"
                                                                            severity=ERROR OR textPayload=~"\[error\]"
                                                                            -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                                                            
                                                                          3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                                                          Error message

                                                                          Details

                                                                          iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Resource 'projects/<account>/locations/<region>/functions/protegrity-protect-<deployment-id>' was not found
                                                                          
                                                                          This error may indicate the following configuration issues:
                                                                          1. The function name indicated in setting gcp_protect_function_resource_name has been provided incorrectly, and thus cannot be found.
                                                                          2. disable_deploy has been set, and a dummy function has been entered to work around the gcp_protect_function_resource_name requirement. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate.
                                                                          [ERROR] policy_agent:Invalid GCP_PROTECT_FUNCTION_RESOURCE_NAME parameter value. Must be a comma separated list of Lambda Function names or ARNs.
                                                                          
                                                                          This error may indicate the following configuration issues:
                                                                          1. The setting gcp_protect_function_resource_name is empty. The Agent deployment requires a deployed Protect or Log Forwarder Cloud Run function to operate, this setting may not be left empty.
                                                                          2. The list of function names provided to gcp_protect_function_resource_name contains invalid function name or is not valid csv format.
                                                                          [ERROR] iap_agent_gcp.cloud_functions_util:<HttpError 403 when requesting https://cloudfunctions.googleapis.com/v2/projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>:generateDo
                                                                          wnloadUrl?alt=json returned "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/<deployment-id>'". Details: "Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'">
                                                                          [ERROR] policy_agent:Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>'
                                                                          ...
                                                                          iap_agent_gcp.cloud_functions_util.CloudFunctionsApiException: Permission 'cloudfunctions.functions.sourceCodeGet' denied on 'projects/<account>/locations/<region>/functions/pty-protect-<deployment-id>' 
                                                                          

                                                                          Indicates the Agent Cloud Run function’s identity does not have permissions to sourceCodeGet for Protect/Log Forwarder function(s) provided to the gcp_protect_function_resource_name configuration.

                                                                          13 -

                                                                          Recovering Logs in Dead Letter Topic (Alternative)

                                                                          When the recommended method of for recovery described in Recovering Logs in Dead Letter Topic (Recommended) is not an option, you may use the existing Log Forwarder to reprocess undelivered logs.

                                                                          Audit log recovery using existing log forwarder installation

                                                                          Steps to recover audit logs using existing Log Forwarder installation:

                                                                          • Fix any configuration errors causing the Log Forwarder to fail. Verify audit logs are being transmitted successfully to ESA.

                                                                          • Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                                            terraform output
                                                                            

                                                                            for the Log Forwarder. Note the value for audit_log_dlq_topic.

                                                                          • Set audit_log_dead_letter_topic in the terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with

                                                                            terraform apply
                                                                            
                                                                          • When audit logs have been transmitted to ESA, revert setting audit_log_dead_letter_topic to null Apply the changes with

                                                                            terraform apply
                                                                            

                                                                          14 -

                                                                          Protegrity Cloud Protect Log Forwarder installation provides a solution to recover undelivered audit logs. Reasons for undeliverable logs may include:

                                                                          • Changes to network configuration in ESA or cloud provider (VPC, firewall, certificate rotation, service user credentials)
                                                                          • Log Forwarder IAM Service Account permissions
                                                                          • Log Forwarder Cloud Run Function configuration
                                                                          • Disruption in cloud provider service

                                                                          15 -

                                                                          Log Forwarder Dead Letter Pub/Sub Architecture

                                                                          Log Forwarder is triggered by pub/sub events generated by Protect Functions. If Log Forwarder is unable to reach ESA to deliver the logs, they are pushed to a dead letter pub/sub topic. Dead letter pub/sub topic is created when installing the Log Forwarder with the service installation script. See Install Log Forwarder Function via Terraform Scripts for dead letter topic configuration options and naming conventions.

                                                                          Logs are not delivered to ESA. Undelivered audit logs are sent to a dead letter pub/sub topic.

                                                                          16 -

                                                                          Monitoring Undelivered Logs

                                                                          Logs pushed to the dead letter pub/sub topic will be purged and no longer recoverable when specified dlq_topic_message_retention_duration has been reached. Monitoring the dead letter topic is recommended to ensure timely recovery of audit messages before they are permanently lost. Consult the GCP monitoring alerts documentation for setting up alerts based on pub/sub topic metrics.

                                                                          17 -

                                                                          Protegrity recommends creation of an additional Log Forwarder installation in the case where logs are not delivered to ESA, as described in Log Forwarder Dead Letter Pub/Sub Architecture.

                                                                          Audit log recovery using new log forwarder installation

                                                                          Steps to recover audit logs using new Log Forwarder installation:

                                                                          1. Create a second Log Forwarder installation (Log Forwarder 2 in the above diagram) for processing undelivered logs. Value for audit_log_dead_letter_topic in the terraform script should be set to null during installation.

                                                                          2. Configure and test newly installed Log Forwarder to verify ESA connectivity. See Install Log Forwarder Function via Terraform Scripts for installation instructions.

                                                                          3. Identify the dead letter pub/sub topic (DLQ 1 in the above diagram) resource name by running command

                                                                            terraform output
                                                                            

                                                                            for the Log Forwarder which failed to deliver logs (Log Forwarder as described in Log Forwarder Dead Letter Pub/Sub Architecture). Note the value for audit_log_dlq_topic.

                                                                          4. Set audit_log_dead_letter_topic in the new Log Forwarder (Log Forwarder 2 in the above diagram) terraform installation script to the value of audit_log_dlq_topic identified in previous step. Apply the changes with terraform apply.

                                                                          5. Monitor the new Log Forwarder function logs for any failures.

                                                                          18 -

                                                                          Configuring Regular Expression to Extract Policy Username

                                                                          Cloud Protect Cloud Function exposes USERNAME_REGEX configuration to allow extraction of policy username from user in the request.

                                                                          • USERNAME_REGEX Cloud Function Environment configuration

                                                                            The USERNAME_REGEX environment variable can be set to contain regular expression with one capturing group. This group is used to extract the username. Examples below show different regular expression values and the resulting policy user.

                                                                          USERNAME_REGEX

                                                                          User in the request

                                                                          Effective Policy User

                                                                          Not Set

                                                                          user@domain.com

                                                                          user@domain.com

                                                                          service-account-user@project-id.iam.gserviceaccount.com

                                                                          service-account-user@project-id.iam.gserviceaccount.com

                                                                          ^(.*)@.*$
                                                                          

                                                                          service-account-user@project-id.iam.gserviceaccount.com

                                                                          service-account-user

                                                                          user@domain.com

                                                                          user

                                                                          19 -

                                                                          Certificates on ESA

                                                                          By default, ESA is configured with self-signed certificates, which can only be validated using self-signed CA certificate supplied in Log Forwarder configuration.

                                                                          In case ESA is configured with publicly signed certificates, this section can be skipped since the Log Forwarder will use public CA to validate ESA certificates.

                                                                          To obtain self-signed CA certificate from ESA:

                                                                          1. Download ESA CA certificate from the /etc/ksa/certificates/plug directory of the ESA

                                                                          2. After certificate is downloaded, open the PEM file in text editor and replace all new lines with escaped new line: \n.

                                                                            To escape new lines from command line, use one of the following commands depending on your operating system:

                                                                            Linux Bash:

                                                                            awk 'NF {printf "%s\\n",$0;}' CA.pem > output.txt
                                                                            

                                                                            Windows PowerShell:

                                                                            (Get-Content '.\CA.pem') -join '\n' | Set-Content 'output.txt'
                                                                            
                                                                          3. Record the certificate content with new lines escaped.

                                                                            ESA CA Server Certificate (EsaCaCert): ___________________

                                                                            This value will be used to set pty_esa_ca_server_cert Terraform variable in installation section. Install Log Forwarder via Terraform

                                                                          For more information about ESA certificate management refer to Certificate Management Guide in ESA documentation.

                                                                          20 -

                                                                          Create Log Forwarder Service Account

                                                                          To create Log Forwarder Service Account:

                                                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role. Then select the following roles:

                                                                            • Cloud KMS CryptoKey Decrypter
                                                                            • Pub/Sub Publisher
                                                                            • Secret Manager Secret Accessor
                                                                          7. Click Done.

                                                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                            Log Forwarder Function Service Account Email: ___________________

                                                                          21 -

                                                                          Create Service Account For Forwarder Pub/Sub

                                                                          Pub/Sub service requires Cloud Run Invoker permissions in order to be able to send messages to the Forwarder function.

                                                                          1. Log in to Google Account and select the project where Protegrity forwarder will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role. Then select Cloud Run Invoker.

                                                                          7. Click Done.

                                                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                            Pub/Sub Log Forwarder Service Account Email: ___________________

                                                                          22 -

                                                                          ESA Audit Store Configuration

                                                                          ESA server is required as the recipient of audit logs. Verify the information below to ensure ESA is accessible and configured properly.

                                                                          1. ESA server running and accessible on TCP port 9200.

                                                                          2. Audit Store service is configured and running on ESA. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                          23 -

                                                                          Certificate Authentication

                                                                          Certificate authentication uses a public certificate and a private certificate key. Consult Audit Store Guide on how to set up certificate authentication on ESA and how to download certificate and certificate key. Certificate contains no sensitive information. Certificate key contains private information and for this reason is stored in GCP Secret Manager. Both certificate and certificate key must be converted to single-line values using code similar to the following Powershell code snippet:

                                                                          
                                                                          $files = @('client.pem', 'client.key')
                                                                          $folder = 'C:\Temp'
                                                                          cd $folder
                                                                          foreach ($file in $files) {
                                                                              (Get-Content "$folder\$file") -join '\n' | Set-Content "$folder\one-liner-$file"
                                                                              cat "$folder\one-liner-$file"
                                                                          }
                                                                                  
                                                                          

                                                                          There are two options to configure Log Forwarder for certificate authentication:

                                                                          1. While installing using Terraform
                                                                            1. Provide single-line client certificate for pty_esa_client_cert
                                                                            2. Provide GCP Secret Manager secret name for pty_esa_client_cert_key_secret_id which stores single-line certificate key file
                                                                          2. When re-configuring after installation using environment variables
                                                                            1. Provide single-line client certificate for PTY_ESA_CLIENT_CERT
                                                                            2. Provide GCP Secret Manager secret name for PTY_ESA_CLIENT_CERT_KEY_SECRET_ID which stores single-line certificate key file

                                                                          24 -

                                                                          ESA Authentication

                                                                          Audit Log Forwarder must authenticate with ESA using certificate-based authentication with client certificate and certificate key. Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                                                          File NameDescription
                                                                          client.keyClient certificate key
                                                                          client.pemClient certificate (PEM)

                                                                          Both certificate and certificate key must be converted to single-line values using code similar to the following examples.

                                                                          Client certificate (client.pem):

                                                                          $folder = 'C:\Temp'
                                                                          cd $folder
                                                                          (Get-Content "$folder\client.pem") -join '\n' | Set-Content "$folder\one-liner-client.pem"
                                                                          cat "$folder\one-liner-client.pem"
                                                                          
                                                                          folder="/tmp"
                                                                          cd "$folder"
                                                                          awk 'NF {printf "%s\\n",$0}' "client.pem" > "one-liner-client.pem"
                                                                          cat "one-liner-client.pem"
                                                                          

                                                                          Client certificate key (client.key):

                                                                          $folder = 'C:\Temp'
                                                                          cd $folder
                                                                          (Get-Content "$folder\client.key") -join '\n' | Set-Content "$folder\one-liner-client.key"
                                                                          cat "$folder\one-liner-client.key"
                                                                          
                                                                          folder="/tmp"
                                                                          cd "$folder"
                                                                          awk 'NF {printf "%s\\n",$0}' "client.key" > "one-liner-client.key"
                                                                          cat "one-liner-client.key"
                                                                          

                                                                          While installing using Terraform template:

                                                                          1. Provide single-line client certificate for pty_esa_client_cert
                                                                          2. Provide ID of the GCP secret containing the single-line certificate key for pty_esa_client_cert_key_secret_id Secret is created in a later step

                                                                          25 -

                                                                          Install Log Forwarder Function via Terraform Scripts

                                                                          Resources created with Terraform scripts include Audit Log Forwarder Cloud Functions Service and Pub/Sub topic. If you don’t specify the deployment bucket Terraform parameter, a new storage bucket will also be created. You can optionally choose to create a new service account with custom IAM role.

                                                                          To install using Terraform:

                                                                          1. From the command shell move to directory where you downloaded Protegrity installation bundle.

                                                                          2. Unzip the bundle, then unzip the protegrity-gcp-bigquery-{version}.zip. Navigate to pty-log-forwarder-gcp/. Verify that the following files are available:

                                                                            • pty-log-forwarder-gcp/
                                                                            • main.tf
                                                                            • outputs.tf
                                                                            • protegrity-cloud-api-gcp-{version}.zip
                                                                            • README.md
                                                                          3. Open the main.tf file and update Terraform backend information at the top of the file:

                                                                            terraform {
                                                                              backend "gcs" {
                                                                                bucket  = ""
                                                                                # The bucket/prefix combination must be unique for different deployments 
                                                                                # to avoid conflicting Terraform states and accidental resources destruction.
                                                                                # prefix = "protegrity-gcp-bigquery/forwarder/<deployment_id>/tf-state"
                                                                              }
                                                                            }
                                                                            
                                                                          4. Set the bucket property to Terraform Backend Bucket Name recorded in Google Cloud Storage

                                                                          5. Set the prefix property with value unique to your deployment.

                                                                          6. In the same main.tf file, specify the following Terraform variables: All the values were recorded in Google Cloud Project.

                                                                            ParameterDescription
                                                                            project_idThe project id recorded in the pre-configuration step
                                                                            regionThe Region recorded in the pre-configuration step.
                                                                            deployment_idSpecify short name to identify deployment. This id will be added to all resources deployed with Terraform.
                                                                            deployment_bucketUse Deployment Bucket Name recorded in pre-configuration or leave empty to create new bucket.
                                                                            create_service_accountLeave this as false if you created service account in pre-configuration. Otherwise set to true.
                                                                            forwarder_function_service_account_emailUse Forwarder Function Service account recorded in pre-configuration or leave empty.
                                                                            pub_sub_log_forwarder_service_account_emailService account of the audit log Pub/Sub trigger. The service account must be assigned Cloud Run Invoker (roles/run.invoker) role.
                                                                            create_vpcIf create_vpc flag is set, new vpc will be created together with vpc connector, NAT and external IP Use this flag if you have VPC admin permissions in your Google Account. If you set it to false, you can specify the existing VPC in the google_vpc_access_connector_name parameter.
                                                                            google_vpc_access_connector_nameUse existing VPC connector to associate with Log Forwarder Function. You can specify either the VPC connector name or the full resource name if vpc connector is in different region/project that the one specified for the deployment. You can alternatively set the use google_vpc_access_connector_full_resource_name. Both parameters are optional. Full resource name takes precedence over connector name.
                                                                            log_destination_esa_ipIp address of the ESA where Protector logs will be sent to.
                                                                            pty_esa_ca_server_certESA self-signed CA certificate used by log forwarder function to ensure ESA is the trusted server. See documentation for more details.
                                                                            esa_credentials_secret_resource_idGCP Secret Manager secret id where ESA Fluent Bit logger credentials are stored.
                                                                            pty_esa_client_certSingle-line ESA client certificate content. See Certificate Authentication for details on client certificate
                                                                            pty_esa_client_cert_key_secret_idGCP Secret Manager secret id where single-line ESA client certificate key content is stored. See Configure ESA Secrets In GCP Secret Manager for details on client certificate key secret
                                                                            min_log_levelMinimum log level for log forwarder function. Must be one of the following: [off,severe,warning,info,config,all].
                                                                            esa_tls_disable_cert_verifyDisable certificate verification when connecting to ESA. This is only for dev purposes, should not be used in production environment.
                                                                            esa_connect_timeoutEsa connection timeout in seconds.
                                                                            esa_virtual_hostESA Virtual Host.
                                                                            audit_log_flush_intervalTime interval in seconds used to accumulate audit logs before sending to ESA. Default value: 10
                                                                            Min value: 1
                                                                            Max value: 900
                                                                            dlq_topic_message_retention_durationIndicates the minimum duration to retain a message in dead letter queue topic in case log destination server is not available. Value must be decimal number, followed by the letter s (seconds). Cannot be more than 31 days or less than 10 minutes. Default value is 1 day
                                                                            audit_log_dead_letter_topicThis parameter is expected to be used in a separate deployment to replay dead letter queue messages.
                                                                            max_instance_countGCP Cloud Functions advanced configuration
                                                                            available_memory_mbGCP Cloud Functions advanced configuration
                                                                            timeout_secondsGCP Cloud Functions advanced configuration
                                                                            gen2_available_cpu2nd Gen Cloud Function advanced configuration
                                                                            gen2_container_concurrency2nd Gen Cloud Function advanced configuration
                                                                            upgrade_stepSet this variable when upgrading to the latest version.
                                                                            labelsYou can set this map to include labels for deployed resources. Pay attention to GCP label requirements. For more information, refer to the following link https://cloud.google.com/compute/docs/labeling-resources. For example, only use lowercase and maximum length of 63 characters.
                                                                          7. From local command line or Cloud Shell, change directory to location of the main.tf, for example:

                                                                            pty-log-forwarder-gcp-{version}/pty-log-forwarder-gcp/
                                                                            
                                                                          8. Run the following command.

                                                                            terraform init
                                                                            
                                                                          9. Terraform will download necessary providers.

                                                                          10. Run the following command to verify configuration and print out deployment plan.

                                                                            terraform plan
                                                                            
                                                                          11. Run the following command to deploy resources to your account.

                                                                            terraform apply
                                                                            
                                                                          12. Once deployment is complete Terraform will print output variables.

                                                                          13. Record the following values:

                                                                            • forwarder_function_name: ____________________________
                                                                            • forwarder_function_url: ____________________________
                                                                            • forwarder_function_resource_name: __________________

                                                                          26 -

                                                                          Google Cloud Project

                                                                          Identify or create a new Google Cloud Project where the Protegrity solution will be installed. It is recommended to create a new project. This provides greater security controls and avoids conflicts with other applications that might impact regional account limits. An individual with the Owner role will be required for some of the subsequent installations.

                                                                          Google Project ID: ___________________

                                                                          Google Project Number: ___________________

                                                                          Google Cloud Region: ___________________

                                                                          27 -

                                                                          Preparation

                                                                          1. Ensure that all the steps in Google Cloud Project are performed.

                                                                          2. Log in to the Google Cloud account where Protegrity will be installed.

                                                                          3. Select the project.

                                                                          4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                                                          5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                                                          28 -

                                                                          Protect Function Pub/Sub Log Output

                                                                          Protect function must be configured to output audit logs to Pub/Sub topic.

                                                                          To configure Protect function audit log output:

                                                                          1. Go to Protect function Terraform deployment.

                                                                          2. Navigate to pty-protect-gcp/main.tf.

                                                                          3. Set Terraform variable pty_log_output=“pub_sub”.

                                                                          4. Set Terraform variable pty_pub_sub_topic to log forwarder Pub/Sub topic.

                                                                          5. Run terraform apply.

                                                                          29 -

                                                                          Configure ESA Secrets In GCP Secret Manager

                                                                          Audit Log Forwarder Function uses GCP Secret Manager to store ESA Audit Store credentials used during authentication.

                                                                          For information on how to configure basic and certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Go to Security > Secret Manager.

                                                                          3. Select CREATE SECRET.

                                                                          4. Specify the Secret Value:

                                                                            {
                                                                              "username": "admin", 
                                                                              "password": "{esa_password}"
                                                                            }
                                                                            
                                                                          5. Select Create Secret.

                                                                          6. Once the secret is created, you should see the secret screen opened. If not click on the secret name to see a screen with secret versions.

                                                                          7. Click on Actions, next to the secret version you just created.

                                                                          8. Select Copy Resource ID and record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/2.

                                                                            ESA Log Forwarder Credentials Secret Name: _________________

                                                                          9. Create another secret with single-line contents of ESA client certificate key file

                                                                            See Certificate Authentication for details on client certificate key

                                                                          10. Record the full secret version path, for example, projects/{project-id}/secrets/{secret name}/versions/1.

                                                                            ESA Log Forwarder Client Certificate Key Secret Name: _________________

                                                                          30 -

                                                                          Google Cloud Storage

                                                                          Cloud Storage buckets are required for the Gen 2 Cloud Function sources, the Terraform backend, and the deployment of the Protegrity installation artifacts. It is recommended that you create 3 separate buckets to separate files used for different purposes. If you cannot create 3 separate buckets, you may reuse a bucket for multiple purposes.

                                                                          Create the buckets:

                                                                          1. Run the cloud command below to enable the Google Storage Transfer API.

                                                                            gcloud services enable storagetransfer.googleapis.com
                                                                            
                                                                          2. Create the Gen 2 Cloud Function sources bucket. This bucket is not required if you will be deploying to Gen 1 Cloud Functions. The bucket name much match the example below. Replace the <gcp-project-number> and <region> placeholders.

                                                                            gcf-v2-sources-<gcp-project-number>-<region>
                                                                            

                                                                            Use the following gcloud command to obtain project number

                                                                            gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
                                                                            
                                                                          3. Create the deployment bucket or reuse an existing bucket. This bucket is used during the installation process to store the Protegrity installation artifacts.

                                                                            Deployment Bucket Name:___________________

                                                                          4. Create the Terraform backend bucket or reuse an existing bucket. This bucket is used by Terraform to store information about your Cloud Protect installation, and will be used if you upgrade to a later version of Cloud Protect in the future.

                                                                            Terraform Backend Bucket Name:___________________

                                                                          Note: You may delete the deployment bucket after you’ve completed the installation. A deployment bucket is required for upgrades, but it can be recreated at that time. The Terraform backend files must be retained for upgrading your Cloud Protect deployment in the future.

                                                                          31 -

                                                                          Test Log Forwarder Function Installation

                                                                          Before continuing with next steps, you can verify whether Log Forwarder Function is installed correctly. This step is optional and can be skipped.

                                                                          1. Below you can find example CURL command to test your function.

                                                                          2. Before you can execute it, test if you can obtain temporary authentication token. Run the gcloud auth login and then gcloud auth print-identity-token commands. The logged in gcloud user must have the Cloud Run Invoker permissions. Continue to the next step if the command succeeds and prints the token.

                                                                          3. Replace {forwarder_function_url}; with value recorded in previous step.

                                                                          4. Run the following CURL command to test Function deployment.

                                                                            curl {forwarder_function_url} \
                                                                            -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
                                                                            -H "Content-Type: application/json" \
                                                                            -H "ce-id: 123451234512345" \
                                                                            -H "ce-specversion: 1.0" \
                                                                            -H "ce-time: 2020-01-02T12:34:56.789Z" \
                                                                            -H "ce-type: google.cloud.pubsub.topic.v1.messagePublished" \
                                                                            -H "ce-source: //pubsub.googleapis.com/projects/MY-PROJECT/topics/MY-TOPIC" \
                                                                            -d '{
                                                                                "message": { 
                                                                                    "data": "'"$(echo '{"additional_info":{"description":"Data unprotect operation was successful.","query_id":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23"},"client":{},"cnt":4000,"correlationid":"sf-query-id:k6-test-df51a612-4739-4cfb-9fe4-6ec548b70d23","level":"SUCCESS","logtype":"Protection","origin":{"hostname":"localhost","time_utc":1725558586},"process":{"id":1},"protection":{"audit_code":8,"dataelement":"alpha","datastore":"SAMPLE_POLICY","mask_setting":"","operation":"Unprotect","policy_user":"master_user"},"protector":{"core_version":"1.2.2+42.g01eb3.HEAD","family":"cp","pcc_version":"3.4.0.20","vendor":"gcp.snowflake","version":"3.1.0.158"},"signature":{"checksum":"7CE5FFCE9DBE570AAA72D1BB20CD083532EF8FAD3E96E38629EB92E837272D8E","key_id":"676c5178-756d-4363-9"}}' | base64 -w 0)"'",
                                                                                    "attributes": {},  
                                                                                    "messageId": "",  
                                                                                    "publishTime": "2014-10-02T15:01:23Z",
                                                                                    "orderingKey": ""
                                                                               }
                                                                            }'
                                                                            
                                                                          5. In GCP Logs Explorer console verify that the following output appears in the logs:

                                                                            Request finished HTTP/1.1 POST http://pty-forwarder-31-smoke-jf-pfadh7riaq-uc.a.run.app/ - 200 0 - 75.6570ms
                                                                            
                                                                          6. .

                                                                          32 -

                                                                          Troubleshooting

                                                                          Configure additional logging:

                                                                          1. Set min_log_level Terraform variable on both Protect function and Log Forwarder function to config.

                                                                          2. In the GCP Logs Explorer, you can run the query below, replacing placeholders with your deployment id and project name.

                                                                            resource.type="cloud_run_revision"
                                                                            resource.labels.service_name=~"pty-(protect|forwarder)-<deploymentd-id>"
                                                                            severity=ERROR OR textPayload=~"\[error\]"
                                                                            -logName="projects/<gcp-project-id>/logs/run.googleapis.com%2Frequests"
                                                                            
                                                                          3. Expand each log entry for more details. Check for jsonPayload > exception to see more detailed error.

                                                                          Error message

                                                                          Details

                                                                          Pub/Sub configuration error.
                                                                          
                                                                          1. Indicates problems with Pub/Sub service configuration/availability.

                                                                          2. Expand error log entry and check exception details. For instance:

                                                                            exception: "Grpc.Core.RpcException: Status(StatusCode="InvalidArgument", Detail="Invalid resource name given (name=projects/<todo>/topics/pty-forwarder-<todo>). 
                                                                            
                                                                          3. Verify that pty_pub_sub_topic Terraform variable is set to correct pub/sub resource name.

                                                                          4. Verify that Pub/Sub topic exists.

                                                                          Failed to send x/y audit logs to GCP Pub/Sub.   
                                                                          
                                                                          1. This error may be shown as a consequence of Pub/Sub configuration/availability errors.
                                                                          2. Check for pub/sub configuration errors.
                                                                          3. If pub/sub configuration looks correct, this may indicate that cloud function can’t process audit logs fast enough.
                                                                          4. From Protector Function Terraform configuration, try increasing CPU and concurrency.
                                                                          Audit log sink error: Unable to deliver all logs. 
                                                                          
                                                                          opensearch.0: Dropped records: 1/1
                                                                          
                                                                          [error] [output:opensearch:opensearch.0] HTTP status=401 URI=/_bulk
                                                                          
                                                                          1. Indicates problems with ESA Audit Store availability/configuration.
                                                                          2. Those errors will usually be displayed together. The third error will have details on what is the status or response from ESA.
                                                                          3. In this example, the HTTP status 401 indicates authentication issue.

                                                                          33 -

                                                                          Turn on Instance-based billing.

                                                                          Both Protect and Log Forwarder functions must run for a short period of time after all requests are handled. In order for the GCP Cloud Run service to allow that, the Instance-based billing feature must be enabled for both function deployments.

                                                                          To enable Instance-based billing:

                                                                          1. Log in to Google Account and select the project where Protegrity Cloud Run Function was installed.

                                                                          2. Navigate to Cloud Run.

                                                                          3. Click on the Cloud Function name.

                                                                          4. In Cloud Run revision view, select Edit & deploy new revision.

                                                                          5. Scroll down to Billing.

                                                                          6. Select Instance-based.

                                                                          7. Click DEPLOY.

                                                                          8. Repeat the steps for Log Forwarder function.

                                                                          34 -

                                                                          Grant Pub/Sub Publisher Permission to the Protect Function Service Account

                                                                          Protect function requires permissions to publish audit log messages to Pub/Sub.

                                                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin.

                                                                          3. Search for protector function service account email recorded in protect service installation step.

                                                                          4. Select Edit principal pencil icon.

                                                                          5. Select ADD ANOTHER ROLE.

                                                                          6. Select Pub/Sub Publisher.

                                                                          7. Click Save.

                                                                          35 -

                                                                          VPC configuration

                                                                          Similar to Policy Agent Function, log forwarder function requires Google Cloud VPC to route traffic from the function to ESA. Review the VPC configuration steps for agent in section Identify or Create a new VPC. Same VPC connector as the policy agent can be used. Note down VPC connector name:

                                                                          google_vpc_access_connector_name: ___________________

                                                                          36 -

                                                                          Log Forwarder Performance

                                                                          Log forwarder architecture is optimized to minimize the amount of connections and reduce the overall network bandwidth required to send audit logs to ESA. This is achieved with batching and aggregation taking place on two levels. The first level is in protector function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching and aggregation takes place in the log forwarder function before audit logs are forwarded to ESA. This section shows how to configure the deployment to accommodate different patterns of anticipated audit log stream. It also shows how to monitor deployment resources to detect problems before audit records are lost.

                                                                                      

                                                                          • Protector Function Terraform configuration:

                                                                            • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to Pub/Sub topic. Default value is 30 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The protector function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to Pub/Sub. The protector function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to Pub/Sub. This can be avoided by lowering the interval value.

                                                                                                    

                                                                          • Log Forwarder Function Terraform configuration

                                                                            • audit_log_flush_interval: Determines the minimum amount of time audit logs are aggregated for before they are sent to ESA audit log store. Default value is 10 seconds. Changing flush interval may affect the level of aggregation and it will affect the backlog of audit logs buffered in the function. The forwarder function features multithreaded processing which means that multiple requests can be handled at the same time, which in turn can contribute to large backlog of audit logs waiting to be sent to ESA. The forwarder function is hosted on Cloud Run containerized environment where each instance of the function is shut down after specific amount of time when there is no more requests to be handled. If the flush interval is too long, the function might be shut down before all of the audit log backlog is send to ESA. This can be avoided by lowering the interval value. On the other hand if the interval is too short, forwarder function might end up sending to many requests to ESA, which in some extreme cases may result in messages being sent to dead letter queue.
                                                                            • gen2_available_cpu: Increasing the Function CPU count allows setting higher concurrency, which in turn allows processing more messages from the Pub/Sub in parallel. The high CPU count will effectively lower the number of forwarder function instances which will lower number of connections to ESA.
                                                                            • gen2_container_concurrency: See bullet point above.
                                                                            • audit_log_dead_letter_topic: Dead-letter Pub/Sub topic name. This topic will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ topic can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                                                    

                                                                          • Monitoring Log Forwarder Resources

                                                                            • Protector Function Logs: If protector function is unable to send logs to Pub/Sub, it will log the following message:

                                                                              Failed to send x/y audit logs to GCP Pub/Sub.
                                                                              

                                                                              See the description of ‘audit_log_flush_interval’ in the protector function configuration section above to learn about potential mitigation.

                                                                            • Pub/Sub DLQ Topic Metrics: Any positive value in count aggregator on ’topic/message_sizes’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Install Log Forwarder Function via Terraform Scripts

                                                                            • Log Forwarder Function Logs: If log forwarder function is unable to send logs to ESA, it will log the following message:

                                                                              [/jenkins/workspace/iaplambda_release_3.1/src/iap/logging/fluent-bit-external-sink.cpp:225] opensearch.0: Dropped records: x/y.
                                                                              

                                                                              See the description of ‘audit_log_flush_interval’ in the log forwarder configuration section above to learn about potential mitigation.

                                                                          37 -

                                                                          Performance Considerations

                                                                          The following factors may affect performance benchmarks:

                                                                          • Cold startup: Cloud Function spends additional time on the initial invocation to decrypt and load the policy into memory. This time can vary depending on the policy size. Once the Function is initialized, subsequent “warm executions” should process quickly.
                                                                          • Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                                                                          • Cloud Function memory: GCP provides more virtual cores based on the memory configuration. The initial configuration of 2048 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                                                          • Number of security operations (protect or unprotect).
                                                                          • Cloud Function max instances and concurrency quota: The instance limit affects how functions are scaled. By default the limit is not set to allow handling any traffic pattern. The instance limit can be set to prevent abnormally high request levels. Cloud Functions are also subject to maximum quota for concurrent invocations and request rate.
                                                                          • Size of data element: Operations on larger text consume time.

                                                                          38 -

                                                                          This guide describes how to configure the Protegrity Policy Agent and Log Forwarder to connect to a Protegrity Provisioned Cluster (PPC), highlighting the differences from connecting to ESA.

                                                                          Key Differences: PPC vs ESA

                                                                          FeatureESA 10.2PPC (this guide)
                                                                          Datastore Key FingerprintOptional/RecommendedRequired
                                                                          CA Certificate on AgentOptional/RecommendedOptional/Recommended
                                                                          CA Certificate on Log ForwarderOptional/RecommendedNot supported
                                                                          Client Certificate Authentication from Log ForwarderOptional/RecommendedNot supported
                                                                          IP AddressESA IP addressPPC address

                                                                          Prerequisites

                                                                          • Access to PPC and required credentials.
                                                                          • Tools: curl, kubectl installed.

                                                                          Policy Agent Setup with PPC

                                                                          Follow these instructions as a guide for understanding specific inputs for Policy Agent integrating with PPC:

                                                                          1. Obtain the Datastore Key Fingerprint

                                                                            To retrieve the fingerprint for your Policy Agent:

                                                                            1. Retrieve public key from the Cloud Provider Key Management service for the policy encryption key created in pre-configuration:

                                                                              1. Navigate to the Key Management Service in AWS console and open Customer Managed Keys
                                                                              2. Select the desired key
                                                                              3. Select the Public Key tab
                                                                              4. Select Download
                                                                              1. Navigate to the Key Vault in Azure console and open Objects>Keys
                                                                              2. Select the desired key
                                                                              3. Select the key indicated as CURRENT VERSION
                                                                              4. Select Download public key
                                                                              1. Navigate to Key Management in GCP console
                                                                              2. Select the desired key and open the Versions tab
                                                                              3. Select Get public key from the Actions column menu
                                                                              4. Select Download

                                                                            2. Escape the new line characters in the downloaded public key for use in the next step - for example:

                                                                              awk 'NF {printf "%s\\n",$0}' "<public_key_file>" > "new-line-escaped-public-key.pem"
                                                                              cat new-line-escaped-public-key.pem
                                                                              
                                                                            3. Export key fingerprint using the PPC API as indicated in the curl example below:

                                                                              curl -k -H "Authorization: Bearer ${TOKEN}" -X POST https://${HOST}/pty/v2/pim/datastores/1/export/keys  -H "Content-Type: application/json" --data '{
                                                                                "algorithm": "RSA-OAEP-256",
                                                                                "description": "example-key-from-key-management",
                                                                                "pem": "<value of new-line-escaped-public-key>"
                                                                              }'
                                                                              

                                                                              Sample Output:

                                                                              {"uid":"1","algorithm":"RSA-OAEP-256","fingerprint":"4c:46:d8:05:35:2e:eb:39:4d:39:8e:6f:28:c3:ab:d3:bc:9e:7a:cb:95:cb:b1:8e:b5:90:21:0f:d3:2c:0b:27","description":"example-key-from-kms"}
                                                                              
                                                                            4. Record the value for fingerprint and configure the Policy Agent:

                                                                              Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Lambda function to the fingerprint value.

                                                                              Set the environment variable PTY_DATASTORE_KEY in the Policy Agent Function App to the fingerprint value.

                                                                              Set the variable in Policy Agent main.tf pty_datastore_key to the fingerprint value and apply the changes.

                                                                          2. Retrieve the PPC CA Certificate

                                                                            To obtain the CA certificate from PPC:

                                                                            kubectl -n api-gateway get secret ingress-certificate-secret -o jsonpath='{.data.ca\.crt}' | base64 -d > CA.pem
                                                                            

                                                                            Use the ProtegrityCA.pem that was returned as described in Policy Agent Installation.

                                                                          3. Configure the PPC Address

                                                                            Use the PPC address in place of the ESA IP address wherever required in your configuration.

                                                                          Log Forwarder Setup with PPC

                                                                          • The Log Forwarder will proceed without certificates and will print a warning if PTY_ESA_CA_SERVER_CERT is not provided.
                                                                          • No additional certificate or CA configuration is needed for PPC.

                                                                          39 -

                                                                          Cloud Functions Service Accounts

                                                                          Cloud Functions use the service accounts created in this deployment. You can create Service accounts manually or use the Protegrity Terraform installation script to create one. Each service account requires specific permissions, which must be granted through IAM roles. Run the following steps to create service accounts and configure the required IAM access. If you use Terraform scripts, skip these steps.

                                                                          Agent Function IAM Role

                                                                          To create Agent Function IAM Role:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                                          3. Specify role name and description.

                                                                          4. Select ADD PERMISSIONS.

                                                                          5. Select the following permissions:

                                                                            • cloudkms.cryptoKeyVersions.useToEncrypt
                                                                            • cloudkms.cryptoKeyVersions.viewPublicKey
                                                                            • secretmanager.versions.access
                                                                            • storage.objects.get
                                                                            • storage.objects.create
                                                                            • storage.objects.delete
                                                                            • storage.objects.list
                                                                            • storage.objects.update
                                                                            • storage.buckets.get
                                                                            • cloudfunctions.functions.get
                                                                            • cloudfunctions.functions.update
                                                                            • cloudfunctions.functions.sourceCodeGet
                                                                            • cloudfunctions.functions.sourceCodeSet
                                                                            • iam.serviceAccounts.actAs
                                                                          6. Click Add and then Create.

                                                                          Alternatively, you can run the following command from the Cloud Shell Terminal.

                                                                                gcloud iam roles create role-id \
                                                                                --project=project-id \
                                                                                --title=role-title \
                                                                                --description=role-description \
                                                                                --permissions=cloudkms.cryptoKeyVersions.useToEncrypt,\
                                                                                cloudkms.cryptoKeyVersions.viewPublicKey,\
                                                                                secretmanager.versions.access,\
                                                                                storage.objects.get,\
                                                                                storage.objects.create,\
                                                                                storage.objects.delete,\
                                                                                storage.objects.list,\
                                                                                storage.objects.update,\
                                                                                storage.buckets.get,\
                                                                                cloudfunctions.functions.get,\
                                                                                cloudfunctions.functions.update,\
                                                                                cloudfunctions.functions.sourceCodeGet,\
                                                                                cloudfunctions.functions.sourceCodeSet,\
                                                                                iam.serviceAccounts.actAs \
                                                                                --stage=GA 
                                                                                
                                                                          
                                                                          • role-id

                                                                            is the name of the role, such as ptyProtectRole.

                                                                          • project-id

                                                                            is the name of the project, such as my-project-id.

                                                                          • role-description

                                                                            is a short description of the role, such as “My custom role description”.

                                                                          Sample output:

                                                                          
                                                                                Created role [role-id]. 
                                                                                description: role-description 
                                                                                etag: *****************
                                                                                includedPermissions: 
                                                                                - cloudfunctions.functions.get 
                                                                                - cloudfunctions.functions.sourceCodeGet 
                                                                                - cloudfunctions.functions.sourceCodeSet 
                                                                                - cloudfunctions.functions.update 
                                                                                - cloudkms.cryptoKeyVersions.useToEncrypt 
                                                                                - cloudkms.cryptoKeyVersions.viewPublicKey 
                                                                                - iam.serviceAccounts.actAs 
                                                                                - secretmanager.versions.access 
                                                                                - storage.buckets.get 
                                                                                - storage.objects.create 
                                                                                - storage.objects.delete 
                                                                                - storage.objects.get 
                                                                                - storage.objects.list 
                                                                                - storage.objects.update 
                                                                                name: projects/{project-id}/roles/{role-id} 
                                                                                stage: GA 
                                                                                title: role-title
                                                                                
                                                                          

                                                                          Agent Service Account

                                                                          To create Agent Service Account:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role.

                                                                          7. Select Custom and select the role created above .

                                                                          8. Click Done.

                                                                          9. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          10. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com

                                                                            Agent Function Service Account Email: ___________________

                                                                          Protect Function IAM role

                                                                          To create Protect Function IAM role:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                                          3. Specify role name and description.

                                                                          4. Select ADD PERMISSIONS.

                                                                          5. Select the cloudkms.cryptoKeyVersions.useToDecrypt permission.

                                                                          6. Click Add and then Create.

                                                                          Protect Service Account

                                                                          To create Protect Service Account:

                                                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role. Then select Custom and select the role created above .

                                                                          7. Click Done.

                                                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                            Protect Function Service Account Email: ___________________

                                                                          40 -

                                                                          Google Cloud Project

                                                                          Identify or create a new Google Cloud Project where the Protegrity solution will be installed. It is recommended to create a new project. This provides greater security controls and avoids conflicts with other applications that might impact regional account limits. An individual with the Owner role will be required for some of the subsequent installations.

                                                                          Google Project ID: ___________________

                                                                          Google Project Number: ___________________

                                                                          Google Cloud Region: ___________________

                                                                          41 -

                                                                          Key Management Service

                                                                          The Google Cloud Key Management Service (KMS) provides Protegrity Serverless solution the ability to encrypt and decrypt the Protegrity Security Policy.

                                                                          To create KMS Key Ring and Asymmetric Encryption Master Key:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to Security > Key Management.

                                                                          3. Select Create key ring.

                                                                          4. Specify key ring name. For example, protegrity-policy-keyring.

                                                                          5. select Key ring location which corresponds to the region where Protegrity solution will be installed.

                                                                          6. Select Create.

                                                                          7. Select CREATE KEY to create encryption key.

                                                                          8. Specify key name. For example, protegrity-policy-key.

                                                                          9. under Purpose selection, select Asymmetric Decrypt .

                                                                          10. Select Key Algorithm. For example, 3072-bit RSA with OAEP Padding and SHA256 digest.

                                                                          11. Select Create.

                                                                          12. Once the key is created, a screen opens on the key. If the screen does not appear, click on the key name.

                                                                          13. Then click on the elipses under Actions that is next to the key version.

                                                                          14. Select Copy Resource Name and record the value below, e.g., projects/{project-id}/locations/region/keyRings/{key-ring}/cryptoKeys/{key-name}/cryptoKeyVersions/1

                                                                            Policy Encryption Key Version Resource Name: ___________________

                                                                          42 -

                                                                          Agent Function IAM Role

                                                                          To create Agent Function IAM Role:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                                          3. Specify role name and description.

                                                                          4. Select ADD PERMISSIONS.

                                                                          5. Select the following permissions:

                                                                            • cloudkms.cryptoKeyVersions.useToEncrypt
                                                                            • cloudkms.cryptoKeyVersions.viewPublicKey
                                                                            • secretmanager.versions.access
                                                                            • storage.objects.get
                                                                            • storage.objects.create
                                                                            • storage.objects.delete
                                                                            • storage.objects.list
                                                                            • storage.objects.update
                                                                            • storage.buckets.get
                                                                            • cloudfunctions.functions.get
                                                                            • cloudfunctions.functions.update
                                                                            • cloudfunctions.functions.sourceCodeGet
                                                                            • cloudfunctions.functions.sourceCodeSet
                                                                            • iam.serviceAccounts.actAs
                                                                          6. Click Add and then Create.

                                                                          Alternatively, you can run the following command from the Cloud Shell Terminal.

                                                                                gcloud iam roles create role-id \
                                                                                --project=project-id \
                                                                                --title=role-title \
                                                                                --description=role-description \
                                                                                --permissions=cloudkms.cryptoKeyVersions.useToEncrypt,\
                                                                                cloudkms.cryptoKeyVersions.viewPublicKey,\
                                                                                secretmanager.versions.access,\
                                                                                storage.objects.get,\
                                                                                storage.objects.create,\
                                                                                storage.objects.delete,\
                                                                                storage.objects.list,\
                                                                                storage.objects.update,\
                                                                                storage.buckets.get,\
                                                                                cloudfunctions.functions.get,\
                                                                                cloudfunctions.functions.update,\
                                                                                cloudfunctions.functions.sourceCodeGet,\
                                                                                cloudfunctions.functions.sourceCodeSet,\
                                                                                iam.serviceAccounts.actAs \
                                                                                --stage=GA 
                                                                                
                                                                          
                                                                          • role-id

                                                                            is the name of the role, such as ptyProtectRole.

                                                                          • project-id

                                                                            is the name of the project, such as my-project-id.

                                                                          • role-description

                                                                            is a short description of the role, such as “My custom role description”.

                                                                          Sample output:

                                                                          
                                                                                Created role [role-id]. 
                                                                                description: role-description 
                                                                                etag: *****************
                                                                                includedPermissions: 
                                                                                - cloudfunctions.functions.get 
                                                                                - cloudfunctions.functions.sourceCodeGet 
                                                                                - cloudfunctions.functions.sourceCodeSet 
                                                                                - cloudfunctions.functions.update 
                                                                                - cloudkms.cryptoKeyVersions.useToEncrypt 
                                                                                - cloudkms.cryptoKeyVersions.viewPublicKey 
                                                                                - iam.serviceAccounts.actAs 
                                                                                - secretmanager.versions.access 
                                                                                - storage.buckets.get 
                                                                                - storage.objects.create 
                                                                                - storage.objects.delete 
                                                                                - storage.objects.get 
                                                                                - storage.objects.list 
                                                                                - storage.objects.update 
                                                                                name: projects/{project-id}/roles/{role-id} 
                                                                                stage: GA 
                                                                                title: role-title
                                                                                
                                                                          

                                                                          43 -

                                                                          Agent Service Account

                                                                          To create Agent Service Account:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role.

                                                                          7. Select Custom and select the role created above .

                                                                          8. Click Done.

                                                                          9. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          10. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com

                                                                            Agent Function Service Account Email: ___________________

                                                                          44 -

                                                                          Protect Function IAM role

                                                                          To create Protect Function IAM role:

                                                                          1. Log in to Google Account and select project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Roles, Select CREATE ROLE.

                                                                          3. Specify role name and description.

                                                                          4. Select ADD PERMISSIONS.

                                                                          5. Select the cloudkms.cryptoKeyVersions.useToDecrypt permission.

                                                                          6. Click Add and then Create.

                                                                          45 -

                                                                          Protect Service Account

                                                                          To create Protect Service Account:

                                                                          1. Log in to Google Account and select the project where Protegrity service will be installed.

                                                                          2. Navigate to IAM & Admin > Service Accounts.

                                                                          3. Select CREATE SERVICE ACCOUNT.

                                                                          4. Specify service account name and description.

                                                                          5. Select Create and Continue.

                                                                          6. In the next step, click Select Role. Then select Custom and select the role created above .

                                                                          7. Click Done.

                                                                          8. Once the service account is created, the screen should open on the service account. If the screen does not appear, refresh the page with the service account list and select the service account created.

                                                                          9. Record the full email. For example, service-account-name@project-id.iam.gserviceaccount.com.

                                                                            Protect Function Service Account Email: ___________________

                                                                          46 -

                                                                          Google Cloud Storage

                                                                          Cloud Storage buckets are required for the Gen 2 Cloud Function sources, the Terraform backend, and the deployment of the Protegrity installation artifacts. It is recommended that you create 3 separate buckets to separate files used for different purposes. If you cannot create 3 separate buckets, you may reuse a bucket for multiple purposes.

                                                                          Create the buckets:

                                                                          1. Run the cloud command below to enable the Google Storage Transfer API.

                                                                            gcloud services enable storagetransfer.googleapis.com
                                                                            
                                                                          2. Create the Gen 2 Cloud Function sources bucket. This bucket is not required if you will be deploying to Gen 1 Cloud Functions. The bucket name much match the example below. Replace the <gcp-project-number> and <region> placeholders.

                                                                            gcf-v2-sources-<gcp-project-number>-<region>
                                                                            

                                                                            Use the following gcloud command to obtain project number

                                                                            gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
                                                                            
                                                                          3. Create the deployment bucket or reuse an existing bucket. This bucket is used during the installation process to store the Protegrity installation artifacts.

                                                                            Deployment Bucket Name:___________________

                                                                          4. Create the Terraform backend bucket or reuse an existing bucket. This bucket is used by Terraform to store information about your Cloud Protect installation, and will be used if you upgrade to a later version of Cloud Protect in the future.

                                                                            Terraform Backend Bucket Name:___________________

                                                                          47 -

                                                                          Google Cloud Services

                                                                          The following table describes the Google Cloud services that may a part of your Protegrity installation.

                                                                          ServiceDescription
                                                                          Cloud Run FunctionsProvides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates.
                                                                          API GatewayProvides the end-point and access control (Required for Snowflake only).
                                                                          Key Management ServiceProvides cryptographic keys for envelope encryption/decryption of the policy.
                                                                          Secret Manager ServiceStores secrets required during deployment, e.g., ESA credentials.
                                                                          Cloud Storage ServiceStorage location for the encrypted ESA policy package.
                                                                          Identity and Access ManagementEnforces access policies for deployed resources.
                                                                          Cloud Logging ServiceApplication and audit logs, performance monitoring, and alerts.
                                                                          Cloud VPCRequired for securing network access to On-Prem or cloud-based ESA.
                                                                          Pub/SubProvides a messaging service when forwarding audit logs to ESA is enabled.

                                                                          48 -

                                                                          Preparation

                                                                          1. Ensure that all the steps in pre-configuration are performed.

                                                                          2. Log in to the Google Cloud account where Protegrity will be installed.

                                                                          3. Select the project.

                                                                          4. Ensure that you have access to shell command on your computer or Cloud Shell with Terraform CLI v0.14 or higher installed.

                                                                          5. Ensure that the Terraform scripts provided by Protegrity are available on your local computer.

                                                                          49 -

                                                                          Decommission Previous Log Forwarder Version

                                                                          Verify audit log transmission from old version is complete and remove installation. Before you begin

                                                                          To remove the previous installation:

                                                                          1. Navigate to the previous Log Forwarder installation

                                                                          2. run the command:

                                                                             terraform destroy
                                                                            
                                                                          3. Make sure the correct installation is indicated for removal, then approve the changes

                                                                          50 -

                                                                          Deploy Protect Function Changes

                                                                          After the upgrade is tested, it can be deployed to production Protect Cloud Function. Follow the instructions below to run terraform and deploy the upgrade.

                                                                          1. In the main.tf file set upgrade_step variable to “deploy_changes”. Apply Terraform changes.

                                                                            terraform plan
                                                                            terraform apply
                                                                            
                                                                          2. Make sure Protect Function works correctly after the Terraform apply is completed. If testing is unsuccessful, go to the next section to see the instruction how to rollback changes.

                                                                          3. The upgrade_step variable can be left set to “deploy_changes” for extended amount of time or until the next upgrade. This allows rolling back the upgrade at any given moment. Once the upgrade_step variable is set to “”(empty string) upgrade is final and rollback is no longer possible.

                                                                          51 -

                                                                          Upgrading to the Latest Version

                                                                          You can download the latest version of the deployment package from https://my.protegrity.com. Navigate to Data Protection > Cloud Protect to download the latest version.

                                                                          Perform the following steps to upgrade the Policy Agent Function and Protect Function separately.

                                                                          52 -

                                                                          Reset Agent environment variable for protect function resource name

                                                                          If the protect function was upgraded, function resource name environment variable must be updated to the original value.

                                                                          1. Reinstate the production function resource name in policy agent configuration. See the example below (replace placeholder with values recorded above):

                                                                            GCP_PROTECT_FUNCTION_RESOURCE_NAME=<protect_function_resource_name>
                                                                            
                                                                          2. Run the Terraform apply command to apply the change.

                                                                          53 -

                                                                          Resume Protegrity Agent Function Scheduled Job

                                                                          If the Agent Function Scheduled Job was paused at the beginning of the upgrade process, you must resume it. Follow the steps below to resume the Policy Agent Scheduled Job.

                                                                          1. Navigate back to Cloud Scheduler.

                                                                          2. Select checkbox next to Protegrity Agent Function, e.g. pty-agent-<deployment-id>

                                                                          3. Click Resume button placed on the top action panel.

                                                                          54 -

                                                                          Install New Log Forwarder Function

                                                                          Upgrade of log forwarder component requires new Log Forwarder installation.

                                                                          1. In the newly downloaded Protegrity Log Forwarder function Terraform directory, open the main.tf configuration file.

                                                                          2. Populate Terraform variables values, using your current Log Forwarder Terraform main.tf file as a guide.

                                                                            a. prefix in the backend configuration

                                                                            b. deployment_id

                                                                          3. Initialize Terraform modules.

                                                                            terraform init -upgrade
                                                                            
                                                                          4. Run the following command to verify configuration and print out deployment plan.

                                                                             terraform plan
                                                                            
                                                                          5. Run the following command to deploy updated resources to your account.

                                                                             terraform apply
                                                                            
                                                                          6. Note the following values:

                                                                            forwarder_function_resource_name: ___________________

                                                                            audit_log_topic: ___________________

                                                                          55 -

                                                                          Load Policy to Log Forwarder Function

                                                                          Modify Agent Cloud Function policy target with the new log forwarder function resource name. Run the Agent Function to load policy.

                                                                          1. Open the main.tf file for Policy Agent.

                                                                          2. Replace the current log forwarder function name in gcp_protect_function_resource_name variable (if it exists, otherwise add). Use the new Log Forwarder forwarder_function_resource_name recorded in previous steps.

                                                                          3. Cloud API on GCP v3.2.3 Upgrading to the Latest Version If the value for gcp_policy_version_object_key has not been updated as part of any other component upgrade for the new release, replace gcp_policy_version_object_key with a new object key.

                                                                          4. Save the main.tf file and run the Terraform apply command to apply the changes.

                                                                          5. Run Agent Function to upload your production policy to the Log Forwarder function.

                                                                            The Log Forwarder Function should now have the same policy as the Protect Function.

                                                                          56 -

                                                                          Pause Protegrity Agent Function Scheduled Job

                                                                          App Function Scheduled Job is used to periodically run Protegrity Agent Function to synchronize policy from ESA. The trigger must be paused temporarily for the time of the upgrade process.

                                                                          Follow the steps below to pause the Agent Function Scheduled Job.

                                                                          1. From GCP Console, go to Cloud Scheduler.

                                                                          2. Select checkbox next to Protegrity Agent Function, e.g. pty-agent-<deployment-id>

                                                                          3. Click Pause button placed on the top action panel.

                                                                          57 -

                                                                          Rollback Protect Function Changes

                                                                          Follow the instructions below to rollback upgrade changes deployed in previous section.

                                                                          1. In the main.tf file set upgrade_step variable to “rollback_changes”. Apply Terraform changes.

                                                                            terraform plan
                                                                            terraform apply
                                                                            
                                                                          2. In the main.tf file set upgrade_step variable to “”. Apply Terraform changes.

                                                                            terraform plan
                                                                            terraform apply
                                                                            

                                                                          58 -

                                                                          Stage Protect Function Changes

                                                                          The first step in upgrading Cloud Protect Function is staging the new changes in a separate Cloud Function (Upgrade Protect Function). This is done automatically with Terraform script. Follow the instructions below to update and run Terraform and then test production workloads against Upgrade Protect Function to ensure no unexpected behavior when changes are deployed to production Protect Function.

                                                                          1. In the newly downloaded Protegrity Protect Function Terraform directory, open the main.tf configuration file.

                                                                          2. Populate Terraform variables using values recorded in prerequisites section. Use the same deployment_id and backend configuration with the same gcs bucket and prefix.

                                                                            1. The variable cloud_function_generation is no longer applicable and should not be carried over from older versions.
                                                                          3. Initialize Terraform modules.

                                                                            terraform init -upgrade
                                                                            
                                                                          4. Update Terraform state configuration. Some of the steps will be skipped depending on your current release version.

                                                                            1. Skip b. and c. only if the command below returns the following error: No instance found for the given address. If no errors or other errors/warnings are printed, please proceed with steps b. and c.

                                                                              terraform state show module.pty-protect-gcp.google_cloudfunctions_function.protect_function
                                                                              
                                                                            2. Run Terraform output to print current Terraform deployment configuration.

                                                                              terraform output
                                                                              

                                                                              Record the value of protect_function_resource_name.

                                                                              protect_function_resource_name: ___________________

                                                                            3. Run the Terraform remove and import commands to migrate Terraform state for the protector function resource. Replace <protect_function_resource_name> placeholder with the value recorded above.

                                                                              terraform state rm module.pty-protect-gcp.google_cloudfunctions_function.protect_function
                                                                              
                                                                              terraform import module.pty-protect-gcp.module.protect_function.google_cloudfunctions_function.protect_function[0] <protect_function_resource_name>
                                                                              
                                                                          5. In the main.tf file set upgrade_step variable to empty string ("").

                                                                          6. Run Terraform plan. The update plan may contain in-place updates to Protect Cloud Function resource, however it should never contain updates to Protect Cloud Function source archive. If Terraform update plan shows updates to Protect Cloud Function source archive, double check that the previous steps were executed correctly or contact Protegrity support. Do not proceed with next steps until the issue is resolved.

                                                                            terraform plan
                                                                            
                                                                          7. Apply Terraform changes. This will update Terraform resources. Any changes to Protect Function will be applied in-place ensuring no interruptions to production traffic.

                                                                            terraform apply
                                                                            
                                                                            Error: googleapi: Error 409: Function <protect_function_name> in region <region> in project <gcp-project-id> already exists
                                                                            
                                                                          8. In the main.tf file set upgrade_step variable to “stage_changes”.

                                                                          9. Apply Terraform changes. This will deploy a copy of the current Protect Cloud Function with a postfix -upgrade. This function contain new Protect Cloud Function source code.

                                                                            terraform plan
                                                                            terraform apply
                                                                            
                                                                          10. Record the following values from the Terraform output.

                                                                            protect_function_resource_name: ___________________

                                                                            protect_function_upgrade_resource_name: ___________________

                                                                          11. Modify Agent Cloud Function policy target with the upgrade function resource name.

                                                                            Open the main.tf file for Policy Agent.

                                                                            1. Replace gcp\protect\function\resource\name variable with the upgraded function resource name. In the finalize steps, you will revert this to the original value.

                                                                              See the example below (replace placeholder with values recorded above):

                                                                              gcp\protect\function\resource\name=<protect_function_upgrade_resource_name>
                                                                              
                                                                            2. Replace gcp_policy_version_object_key with a new backup version object key for the upgraded function. Save the main.tf file and run the Terraform apply command to apply the changes.

                                                                          12. Run Agent Function to upload your production policy to Upgraded Protect Function.

                                                                          13. The Upgrade Protect Function should now have the same policy as your production Protect Function. Test your production workloads against the Upgrade Function to make sure that everything is working as expected. If the testing is completed successfully, proceed to the next section. If testing fails you can abort the upgrade by setting the upgrade_step variable to empty value (""), then run terraform apply again to destroy the upgrade function.

                                                                          59 -

                                                                          Update Log Forwarder Topic References

                                                                          Cloud Protectors transmit logs to Log Forwarder function by using pub/sub topics. Any protectors utilizing Log Forwarder

                                                                          Function must be updated to reference the upgraded Log Forwarder pub/sub topic.

                                                                          1. Open the main.tf file for Protector.

                                                                          2. Replace the current pty_pub_sub_topic value with the new Log Forwarder audit_log_topic recorded in previous steps.

                                                                          3. Save the main.tf file and run the Terraform apply command to apply the changes.

                                                                            Allow a few minutes for the change to take effect. Test the upgrade by invoking Protector such that audit logs are generated. Verify logs are flowing through the new topic by navigating to the pub/sub metrics in GCP console. Additionally validate delivery of audit logs in the ESA Audit Store.

                                                                          60 -

                                                                          Upgrading Protegrity Policy Agent Function

                                                                          Upgrade the Policy Agent:

                                                                          1. In the newly downloaded Protegrity Agent Function Terraform directory, open the main.tf configuration file.

                                                                          2. Populate Terraform variables using values from your current agent Terraform main.tf file.

                                                                            • If upgrading from a Policy Agent before 3.0.1, you must deploy a new Policy Agent function by changing the deployment_id and terraform backend prefix to new values. Starting in version 3.0.1, the Policy Agent uses 2nd gen Cloud Functions. If using a credentials function, ensure that it is a 2nd gen Cloud Function.
                                                                            • Otherwise, use the same backend configuration with the same gcs bucket and prefix.
                                                                          3. If your current Agent function version is lower than 3.0.13, make sure you set the new Terraform variables below. For more information about the new variables, refer to the Install Policy Agent Function through Terraform Scripts section.

                                                                            Set new agent function Terraform variables:

                                                                            pty_esa_ca_server_cert
                                                                            pty_addipaddressheader
                                                                            
                                                                          4. Initialize Terraform modules.

                                                                            terraform init -upgrade
                                                                            
                                                                          5. Run the following command to verify configuration and print out deployment plan.

                                                                            terraform plan
                                                                            
                                                                          6. Run the following command to deploy updated resources to your account.

                                                                            terraform apply
                                                                            
                                                                          7. Once deployment is complete Terraform will print updated output variables.

                                                                          61 -

                                                                          Upgrading Log Forwarder

                                                                          If the release version of the artifact zip file has not changed since the previous installation, Log Forwarder function upgrade may be skipped.

                                                                          62 -

                                                                          Log Forwarder Upgrade Prerequisites

                                                                          Follow the steps below to prepare for upgrade.

                                                                          1. Identify current Protegrity Log Forwarder Function Terraform module directory.

                                                                          2. Record release_version Terraform variable from pty-log-forwarder-gcp/variables.tf file.

                                                                            Current Log Forwarder Function Release Version: ___________________

                                                                          3. Record all Terraform variables from the main.tf file.

                                                                          4. Navigate to directory where new version of Protegrity installation bundle was downloaded.

                                                                          5. Unzip the main package. Then unzip protegrity-gcp-{protector}-{version}.zip. Verify that the following files are present:

                                                                            • pty-log-forwarder-gcp/
                                                                            • main.tf
                                                                            • outputs.tf
                                                                            • protegrity-gcp-{protector}-{version}.zip
                                                                            • README.md
                                                                          6. Open pty-log-forwarder-gcp/variables.tf file and check release-version variable. Compare it with the Current Log Forwarder Function Release Version recorded in the previous step. If the two versions are the same, Log Forwarder Function upgrade can be skipped. If not, continue with the next steps.

                                                                          7. Ensure that the Agent Cloud Function is running and ESA server is available for the policy synchronization. The Agent Function and ESA with production policy are required in the upgrade process.

                                                                          63 -

                                                                          Upgrading Protect Function

                                                                          Protect Function Terraform module contains upgrade functionality with zero downtime release and rollback capabilities.

                                                                          Diagram below illustrates upgrade process.

                                                                          GCP Protect Function Upgrade process

                                                                          Steps in the upgrade process have the following purpose:

                                                                          1. Stage - The new version is staged as a separate function in parallel with the production function. The new version can be tested before deploying to production.
                                                                          2. Deploy - The new version is deployed to protector function with no interruptions to production traffic.
                                                                          3. Rollback - New version can be optionally rolled back to version before upgrade.

                                                                          64 -

                                                                          Protect Function Upgrade Prerequisites

                                                                          Follow the steps below to prepare for upgrade.

                                                                          1. Identify current Protegrity Protect Function Terraform module directory.

                                                                          2. Record release-version Terraform variable from pty-protect-gcp/variables.tf file.

                                                                            Current Protect Function Release Version: ___________________

                                                                          3. Record all Terraform variables from the main.tf file.

                                                                          4. Navigate to directory where new version of Protegrity installation bundle was downloaded.

                                                                          5. Unzip the main package. Then unzip protegrity-gcp-{protector}-{version}.zip. Verify that the following files are present:

                                                                            • pty-protect-gcp/
                                                                            • main.tf
                                                                            • outputs.tf
                                                                            • protegrity-gcp-{protector}-{version}.zip
                                                                            • README.md
                                                                          6. Open pty-protect-gcp/variables.tf file and check release-version variable. Compare it with the Current Protect Function Release Version recorded in the previous step. If the two versions are the same, Protect Function upgrade can be skipped. If not, continue with the next steps.

                                                                          7. Ensure that the Agent Cloud Function is running and ESA server is available for the policy synchronization. The Agent Function and ESA with production policy are required in the upgrade process.

                                                                          65 -

                                                                          2nd Generation Protect Function Upgrade Prerequisites

                                                                          To run Cloud Protect in Gen 2 Cloud Functions, a new instance of Cloud Protect must be created using the included terraform installation scripts. Upgrading a Gen 1 Cloud Function to Gen 2 is not currently supported for Cloud Protect.

                                                                          1. Run the cloud command below to enable Google Storage Transfer API.

                                                                            gcloud services enable storagetransfer.googleapis.com
                                                                            
                                                                          2. Create Cloud Functions storage bucket below. Replace <gcp-project-number> and <region> placeholders.

                                                                            gcf-v2-sources-<gcp-project-number>-<region>
                                                                            

                                                                            Use the following gcloud command to obtain project number

                                                                            gcloud projects describe <gcp-project-id> --format='value(projectNumber)'
                                                                            
                                                                          3. If transitioning from Google Cloud Functions Gen1 to Gen 2, accessing services will require the permissions of Cloud Run Invoker. See Cloud Functions Authentication Reference GCP