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

Return to the regular view of this page.

Cloud Protect

Protegrity Cloud Protect is a family of cloud-native components for performing data protection operations within Cloud environments such as data pipelines and managed databases.

1 - AWS

Protegrity products for AWS.

1.1 - Cloud API

Protector with a REST API on AWS.

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

Solution overview and features.

    Solution Overview

    Cloud API Protector on AWS 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 AWS service.

    Features

    Cloud API Protector on AWS 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.1.2 - Architecture

    Deployment architecture and connectivity

      Protector Deployment Architecture

      The product will be deployed in the Customer’s AWS account. The product incorporates Protegrity’s vaultless tokenization engine within an AWS Lambda Function. The encrypted data security policy from an ESA is deployed as a static resource through an Amazon Lambda Layer. The policy is decrypted in memory at runtime within the Lambda. This architecture allows Protegrity Serverless 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 REST request includes a micro-batch of data to process and the data element type. The function applies the data security policy including user authorization and returns a corresponding response.

      When used with an Enterprise Security Administrator (ESA) application, 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 additional envelope encryption using Amazon KMS, and deploys the policy into the Lambda Layer used by the serverless product. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. The policy takes effect immediately for all new requests. There is no downtime for users during this process.

      The following diagram shows the high-level architecture described above.

      The following diagram shows a reference architecture for synchronizing the security policy from ESA.

      The Protegrity Policy Agent requires network access to an Enterprise Security Administrator (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 Guide.

      Log Forwarding Architecture

      Audit logs are by default sent to CloudWatch as long as the function’s execution role has the necessary permissions. 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 Amazon Kinesis data stream and the forwarder Lambda function. Amazon Kinesis stream is used to batch audit records before sending them 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 Amazon Kinesis. Due to specifics of the Lambda runtime lifecycle, audit logs may take up to 15 minutes before being sent to Amazon Kinesis. Protector function exposes configuration to minimize this time 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 Amazon Kinesis 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 client certificate to authenticate calls to ESA.

      To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instructions can be found in 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 following mechanisms are available for controlling and restricting access to the endpoint:

      • IAM policy: The IAM resource policy controls which IAM users or services may invoke Protect operations. IAM policies can be applied to the API Gateway and/or the Lambda directly depending on allowable access patterns and the client.
      • JWT tokens: The Lambda can be configured to use JSON Web Tokens (JWT) with optional verification. JSON Web Tokens (JWT) are an open, industry-standard RFC 7519 method for representing claims securely between two parties. JWT provides a mechanism for implementing custom authentication or integrating with AWS Cognito.

      AWS Resources

      Access and authorization between various AWS services involved in this architecture are achieved through IAM resource policies. For instance, the Amazon Lambda resource-based policy can restrict requests to the Amazon API Gateway or optionally allow direct invocation to the Lambda function itself. The installation steps provide a default recommended configuration. Alternative IAM role configurations are shown in the appendices in this document.

      REST API Authentication

      AWS API Gateway supports multiple mechanisms for controlling and managing access to the product.

      In standard solutions, AWS API Gateway will authorize access tokens generated in the identity provider. When setting up an AWS API Gateway method to require an authorization, customers can leverage AWS Signature Version 4 or Lambda authorizers to support their organization’s bearer token auth strategy.

      https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-control-access-to-api.html

      REST API Authorization

      Once the request is authenticated and authorized in the API Gateway, Protegrity Lambda Protector validates the user received in the authorization header of JWT, and the data element and security operations (protect or unprotect) from the payload with Protegrity Security Policy.

      If the API Gateway is not used or configured to verify JWT tokens, the product can be configured to perform the JWT verification in the Lambda function itself.

      1.1.3 - Installation

      Instructions for installing Protect Service, Policy Agent, and Log Forwarder.

      1.1.3.1 - Prerequisites

      Requirements before installing the protector.

        AWS Services

        The following table describes the AWS services that may be a part of your Protegrity installation.

        Service

        Description

        Lambda

        Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

        API Gateway

        Provides the endpoint and access control.

        KMS

        Provides secrets for envelope policy encryption/decryption for Protegrity.

        Secrets Manager

        Provides secrets management for the ESA credentials .

        S3

        Intermediate storage location for the encrypted ESA policy layer.

        Kinesis

        Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

        VPC & NAT Gateway

        Optional. Provides a private subnet to communicate with an on-prem ESA.

        CloudWatch

        Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

        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

        Requirement

        Detail

        Protegrity distribution and installation scripts

        These artifacts are provided by Protegrity

        Protegrity ESA 10.0+

        The Cloud VPC must be able to obtain network access to the ESA

        AWS Account

        Recommend creating a new sub-account for Protegrity Serverless

        Required Skills and Abilities

        Role / Skillset

        Description

        AWS Account Administrator

        To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

        Protegrity Administrator

        The ESA credentials required to extract the policy for the Policy Agent

        Network Administrator

        To open firewall to access ESA and evaluate AWS network setup

        Cheat Sheet Recommendation

        AWS Account ID: ___________________

        AWS Region (AwsRegion): ___________________

        S3 Bucket name (ArtifactS3Bucket): ___________________

        KMS Key ARN (AWS_KMS_KEY_ID): ___________________

        ProtectLambdaPolicyName: __________________

        Role ARN (LambdaExecutionRoleArn): ___________________

        ApiGatewayId: ________________________________

        ProtectFunctionName: __________________________

        ProtectLayerName: _____________________________

        ESA IP address: ___________________

        VPC name: ___________________

        Subnet name: ___________________

        Policy Agent Security Group Id: ___________________

        ESA Credentials Secret Name: ___________________

        Policy Name: ___________________

        Agent Lambda IAM Execution Role Name: ___________________

        What’s Next

        1.1.3.2 - Pre-Configuration

        Configuration steps before installing the protector.

          Provide AWS sub-account

          Identify or create an AWS account where the Protegrity solution will be installed. It is recommended that a new AWS sub-account be created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some subsequent installation steps.

          AWS Account ID: ___________________

          AWS Region (AwsRegion): ___________________

          Create S3 bucket for Installing Artifacts

          This S3 bucket will be used for the artifacts required by the CloudFormation installation steps. This S3 bucket must be created in the region that is defined in Provide AWS sub-account

          1. Sign in to the AWS Management Console and open the Amazon S3 console.

          2. Change region to the one determined in Provide AWS sub-account

          3. Click Create Bucket.

          4. Enter a unique bucket name:

            For example, protegrity-install.us-west-2.example.com

          5. Upload the installation artifacts to this bucket. Protegrity will provide the following three artifacts:

            • protegrity-protect-<version>.zip
            • protegrity-agent-<version>.zip
            • protegrity-external-extension-<version>.zip
            • protegrity-sample-policy-<version>.zip

            S3 Bucket name (ArtifactS3Bucket): ___________________

          Create KMS Key

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

          To create KMS key:

          1. In the AWS sub-account where the KMS key will reside, select the region.

          2. Navigate to Key Management Service > Create Key.

          3. Configure the key settings:

            • Key type: Asymmetric
            • Key usage: Encrypt and decrypt
            • Key spec: RSA_4096
            • Click Next
          4. Create alias and optional description, such as, Protegrity-Serverless and click Next.

          5. Define key administrative permissions, the IAM user who will administrate the key.

          6. Click Next.

          7. Define the key usage permissions.

          8. In Other AWS accounts, enter the AWS account id used for the Protegrity Serverless installation.

          9. Continue on to create the key. If there is a concern this permission is overly broad, then you can return later to restrict access to the role of two Protegrity Serverless Lambda as principals. Click to open the key in the list and record the ARN.

            KMS Key ARN (AWS_KMS_KEY_ID): ___________________

          10. Download the public key from the KMS key. Navigate to the key in KMS console, select the Public key tab, and click Download. Save the PEM file. This public key will be added to the ESA data store as an export key. Refer to Exporting Keys to Datastore for instructions on adding the public key to the data store.

            KMS Public Key PEM file: ___________________

          What’s Next

          1.1.3.3 - Protect Service Installation

          Install the protect service.

            Protect Service Installation

            The following sections install the Cloud Protect serverless Lambda function.

            Preparation

            Ensure that all the steps in Pre-Configuration are performed.

            1. Login to the AWS sub-account console where Protegrity will be installed.

            2. Ensure that the required CloudFormation templates provided by Protegrity are available on your local computer.

            Create Protect Lambda IAM Execution Policy

            This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

            Perform the following steps to create the Lambda execution role and required policies:

            1. From the AWS IAM console, select Policies > Create Policy.

            2. Select the JSON tab and copy the following sample policy.

              {
                "Version": "2012-10-17",
                "Statement": [
                  {
                    "Sid": "CloudWatchWriteLogs",
                    "Effect": "Allow",
                    "Action": [
                      "logs:CreateLogGroup",
                      "logs:CreateLogStream",
                      "logs:PutLogEvents"
                    ],
                    "Resource": "*"
                  },
                  {
                    "Sid": "KmsDecrypt",
                    "Effect": "Allow",
                    "Action": [
                      "kms:Decrypt"
                    ],
                    "Resource": [
                      "arn:aws:kms:*:*:key/*"
                    ]
                  }
                ]
              }
              
            3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

            4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

              ProtectLambdaPolicyName:__________________

            Create Protect Lambda IAM Role

            The following steps create the role to utilize the policy defined in Create Protect Lambda IAM Execution Policy.

            To create protect lambda IAM execution role:

            1. From the AWS IAM console, select Roles > Create Role.

            2. Select AWS Service > Lambda > Next.

            3. In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.

            4. Click Next

            5. Type the role name, for example, ProtegrityProtectRole

            6. Click Create role

            7. Record the role ARN.

              Role ARN (LambdaExecutionRoleArn): ___________________

            Install through CloudFormation

            The following steps describe the deployment of the Lambda function.

            1. Access CloudFormation and select the target AWS Region in the console.

            2. Click Create Stack and choose With new resources.

            3. Specify the template.

            4. Select Upload a template file.

            5. Upload the Protegrity-provided CloudFormation template called pty_protect_api_cf.json and click Next.

            6. Specify the stack details. Enter a stack name.

            7. Enter the required parameters. All the values were generated in the pre-configuration steps.

              Parameter

              Description

              Default Value

              ArtifactS3Bucket

              The name of S3 bucket created during the pre-configuration steps

               

              LambdaExecutionRoleArn

              The ARN of Lambda role created in the prior step

               

              MinLogLevel

              The minimum log level for the protect function.

              Supported values: [off, severe, warning, info, config, all]

              severe

              AllowAssumeUser (Optional)

              If 0 is set, the user in the request body will be ignored and the REST API authenticated user will be the acting user.

              Supported values: [0, 1]

              0

              LambdaAuthorization (Optional)

              If “jwt” is set, then Authorization header for JWT will be required in the AWS Protect Lambda request. Any other value is ignored and effective policy user is taken from request payload.

              Supported values: [“jwt”, “”]

              ""

              jwtUsernameClaim (Optional)

              The JWT claim with username.

              Common claims: name, preferred_username, cognito:username

              Also accepts ordered list of claim names in JSON array format, e.g. [“username”, “email”]

              cognito:username

              jwtVerify (Optional)

              If 1 is set, then jwtSecretBase64 is required. Only applicable when LambdaAuthorization is set to “jwt”. Supported JWT algorithms are: RS256, RS384, RS512. While algorithms HS256, HS384, HS512 are supported, they are not recommended for use.

              0

              jwtSecretBase64 (Optional)

              Required when jwtVerify is set to 1 and Authorization is set to “jwt”. The secret must be provided in base64 encoding. It is recommended to only use public key (asymmetric algorithm).

              ""

            8. The log forwarder parameters can be provided later after log forwarder is deployed. If you are not planning to deploy log forwarder you can skip this step.

              ParameterDescription
              KinesisLogStreamArnThe ARN of the AWS Kinesis stream where audit logs will be sent for aggregation
              AuditLogFlushIntervalTime interval in seconds used to accumulate audit logs before sending to Kinesis. Default value: 30. See Log Forwarder Performance section for more details.
            9. Click Next with defaults to complete CloudFormation.

            10. After CloudFormation is completed, select the Outputstab in the stack.

            11. Record the following values:

              ApiGatewayId: ________________________________

              ProtectFunctionName: __________________________

              ProtectFunctionProductionAlias: __________________________

              ProtectLayerName: _____________________________

            Test Connectivity

            Perform the following steps to verify if the API Gateway is working correctly with the Protegrity product.

              1. In the AWS console Access API Gateway.
            1. Search for API (CloudFormation output ApiGatewayId value).

            2. Select Resources > /v1/unprotect POST.

            3. Click on Test tab.

            4. Provide the following input in Headers.

              Authorization:
              
            5. Provide the following input in Request body.

              {"user": "test_user", "data_element": "alpha", "data": ["UtfVk UHgcD!"]}
              
            6. Click Test.

            7. Verify the response Status is 200 and the Response Body is as follows:

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

              For example:

            Troubleshooting

            Error

            Action

            5xx error

            1. Try running the Lambda directly. Open the Lambda function and create the following test case:
            {
                "body": "{\"user\":\"test_user\",\"data_element\": \"alpha\", \"data\": [\"UtfVk UHgcD!\"]}",
                "path": "/unprotect",
                "headers": {
                    "Authorization": ""
                }
            }
            

            If this step fails, then check the console for the meaningful error.

            Setting up Authentication

            This step describes how to setup an AWS API Gateway Authorization.

            By default, the API Gateway is configured to use AWS_IAM Authorization.

            1. From AWS console access API Gateway.
            2. If you are using AWS API Gateway Authorizer, ensure that the Authorizer is configured in Authorizers.
            3. Go to Resources > /v1/protect POST > Method Request tab > Click Edit button
            4. Select from Authorization. dropdown.
            5. Click Save button.
            6. Click Deploy API button to deploy to pty stage.

            Protect Lambda Configuration

            After Cloud Formation stack is deployed, Protector Lambda can be reconfigured based on the authentication selected in previous stage. From your AWS console navigate to lambda and select following lambda: Protegrity_Protect_RESTAPI_<STACK_NAME>. Scroll down to Environment variables section, select Edit and replace the entries based on the following information.

            Environment Variable

            Description

            Notes

            authorization

            If “jwt” is set, Authorization header with JWT will be required in the AWS Protect Lambda request. Any other value is ignored and effective policy user is taken from request payload.

            Supported Values: [“jwt”, “”]

            If “jwt” is set, any request without valid JWT in the Authorization header, will result in error from API Gateway: 502 Bad Gateway.

            Default Value: ""

            allow_assume_user

            If 0 is set, API Gateway user will not be used, and the effective user is the JWT user.

            Supported Values: [0, 1]

            Applicable when authorization is set to “jwt”.

            Default Value: 0

            jwt_user_claim

            The JWT claim with username. Common claims: name, preferred_username, cognito:username

            Applicable when authorization is set to “jwt”

            Default Value: cognito:username

            jwt_verify

            If 1 is set, jwt_secret_base64 is required. Only applicable when authorization is set to “jwt”. Supported JWT algorithm RS256, RS384, RS512. While algorithms HS256, HS384, HS512 are supported, they are not recommended for use.

            Applicable when authorization is set to “jwt”

            jwt_secret_base64

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

            Applicable when authorization is set to “jwt” and jwt_verify is set to 1

            service_user

            If set, it will be used as effective policy user.

            service_user should be used when the Cloud API should always run as single service user or account no matter what user is in the request. service_user will always take priority over users in the payload and in the JWT header.

            USERNAME_REGEX

            If set, the effective policy user will be extracted from the user in the request using supplied regular expression.

            See Configuring Regular Expression to Extract Policy Username to learn how to extract username from the request

            What’s Next

            1.1.3.4 - Policy Agent Installation

            Install the policy agent.

              The following sections will install the Policy Agent. The Policy Agent polls the ESA and deploys the policy to Protegrity Serverless as a static resource. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity Professional Services for further guidance on configuration alternatives in the Cloud.

              ESA Server

              Policy Agent Lambda requires ESA server running and accessible on TCP port 443.

              Note down ESA IP address:

              ESA IP Address (EsaIpAddress): ___________________

              Certificates on ESA

              Whether your ESA is configured with default self-signed certificate or your corporate CA certificate, Policy Agent can validate authenticity of ESA connection using CA certificate. The process for both scenarios is the same:

              • Obtain CA certificate
              • Convert CA certificate to a value accepted by Policy Agent
              • Provide converted CA certificate value to Policy Agent

              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. To convert downloaded CA certificate to a value accepted by Policy Agent, open the downloaded 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 or PTY_ESA_CA_SERVER_CERT_SECRET Lambda variable in section Policy Agent Lambda Configuration

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

              Identify or Create a new VPC

              Establish a VPC where the Policy Agent will be hosted. This VPC will need connectivity to the ESA. The VPC should be in the same account and region established in Pre-Configuration.

              VPC name: ___________________

              VPC Subnet Configuration

              Identify or create a new subnet in the VPC where tha Lambda function will be connected to. It is recommended to use a private subnet.

              Subnet name: ___________________

              NAT Gateway For ESA Hosted Outside AWS Network

              If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

              VPC Endpoints Configuration

              If an internal VPC was created, then add VPC Endpoints, which will be used by the Policy Agent to access AWS services. Policy Agent needs access to the following AWS services:

              Type

              Service name

              Interface

              com.amazonaws.{REGION}.secretsmanager

              Interface

              com.amazonaws.{REGION}.kms

              Gateway

              com.amazonaws.{REGION}.s3

              Interface

              com.amazonaws.{REGION}.lambda

              Identify or Create Security Groups

              Policy Agent and cloud-based ESA appliance use AWS security groups to control traffic that is allowed to leave and reach them. Policy Agent runs on schedule and is mostly concerned with allowing traffic out of itself to ESA and AWS services it depends on. ESA runs most of the time and it must allow Policy Agent to connect to it.

              Policy Agent security group must allow outbound traffic using rules described in the table below. To edit security group navigate:

              From VPC > Security Groups > Policy Agent Security Group configuration.

              TypeProtocolPort RangeDestinationReason
              Custom TCPTCP443Policy Agent Lambda SGESA Communication
              HTTPSTCP443AnyAWS Services

              Record Policy Agent security group ID:

              Policy Agent Security Group Id: ___________________

              Policy Agent will reach out to ESA on port 443. Create following inbound security group rule for cloud-based ESA appliance to allow connections from Policy Agent:

              TypeProtocolPort RangeSource
              Custom TCPTCP443Policy Agent Lambda SG

              Creating ESA Credentials

              Policy Agent Lambda requires ESA credentials to be provided as one of the three options.

              Option 1: Secrets Manager

              Creating secrets manager secret with ESA username and password.

              1. From the AWS Secrets Manager Console, select Store New Secret.

              2. Select Other Type of Secrets.

              3. Specify the username and password key value pair.

              4. Select the encryption key or leave default AWS managed key.

              5. Specify the Secret Name and record it.

                ESA Credentials Secret Name: __________________

              Option 2: KMS Encrypted Password

              ESA password is encrypted with AWS KMS symmetric key.

              1. Create AWS KMS symmetric key which will be used to encrypt ESA password. See Create KMS Key for instructions on how to create KMS symmetric key using AWS console.

              2. Record KMS Key ARN.

                ESA PASSWORD KMS KEY ARN: __________________

              3. Run AWS CLI command to encrypt ESA password. Below you can find sample Linux aws cli command. Replace <key_arn> with KMS symmetric key ARN.

                aws kms encrypt --key-id <key_arn> --plaintext $(echo '<esa_password>' | base64 )
                
              4. Sample output.

                {
                  "CiphertextBlob": "esa_encrypted_password",
                  "KeyId": "arn:aws:kms:region:aws_account:key/key_id ",
                  "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
                }
                
              5. Record ESA username and encrypted password.

                ESA USERNAME: __________________

                ESA ENCRYPTED PASSWORD: __________________

              Option 3: Custom AWS Lambda function

              With this option ESA username and password are returned by a custom AWS Lambda function. This method may be used to get the username and password from external vaults.

              1. Create AWS Lambda in any AWS supported runtime.

                1. There is no input needed.

                2. The Lambda function must return the following response schema.

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

                  For example,

                  example output: {"username": "admin", "password": "Password1234"}
                  
                3. Sample AWS Lambda function in Python:

                  import json
                  
                  def lambda_handler(event, context):
                  
                      return {"username": "admin", "password": "password1234"}
                  
              2. Record the Lambda name:

                Custom AWS lambda for ESA credentials: _______________

              Create Agent Lambda IAM Policy

              Follow the steps below to create Lambda execution policies.

              Create Agent Lambda IAM policy

              1. From AWS IAM console, select Policies > Create Policy.

              2. Select JSON tab and copy the following snippet.

                {
                  "Version": "2012-10-17",
                  "Statement": [
                    {
                      "Sid": "EC2ModifyNetworkInterfaces",
                      "Effect": "Allow",
                      "Action": [
                        "ec2:CreateNetworkInterface",
                        "ec2:DescribeNetworkInterfaces",
                        "ec2:DeleteNetworkInterface"
                      ],
                      "Resource": "*"
                    },
                    {
                      "Sid": "CloudWatchWriteLogs",
                      "Effect": "Allow",
                      "Action": [
                        "logs:CreateLogGroup",
                        "logs:CreateLogStream",
                        "logs:PutLogEvents"
                      ],
                      "Resource": "*"
                    },
                    {
                      "Sid": "LambdaUpdateFunction",
                      "Effect": "Allow",
                      "Action": [
                        "lambda:UpdateFunctionConfiguration"
                      ],
                      "Resource": [
                        "arn:aws:lambda:*:*:function:*"
                      ]
                    },
                    {
                      "Sid": "LambdaReadLayerVersion",
                      "Effect": "Allow",
                      "Action": [
                        "lambda:GetLayerVersion",
                        "lambda:ListLayerVersions"
                      ],
                      "Resource": "*"
                    },
                    {
                      "Sid": "LambdaDeleteLayerVersion",
                      "Effect": "Allow",
                      "Action": "lambda:DeleteLayerVersion",
                      "Resource": "arn:aws:lambda:*:*:layer:*:*"
                    },
                    {
                      "Sid": "LambdaPublishLayerVersion",
                      "Effect": "Allow",
                      "Action": "lambda:PublishLayerVersion",
                      "Resource": "arn:aws:lambda:*:*:layer:*"
                    },
                    {
                      "Sid": "S3GetObject",
                      "Effect": "Allow",
                      "Action": [
                        "s3:GetObject"
                      ],
                      "Resource": "arn:aws:s3:::*/*"
                    },
                    {
                      "Sid": "S3PutObject",
                      "Effect": "Allow",
                      "Action": [
                        "s3:PutObject"
                      ],
                      "Resource": "arn:aws:s3:::*/*"
                    },
                    {
                      "Sid": "KmsEncrypt",
                      "Effect": "Allow",
                      "Action": [
                        "kms:GetPublicKey"
                      ],
                      "Resource": [
                        "arn:aws:kms:*:*:key/*"
                      ]
                    },
                    {
                      "Sid": "SecretsManagerGetSecret",
                      "Effect": "Allow",
                      "Action": [
                        "secretsmanager:GetSecretValue"
                      ],
                      "Resource": [
                        "arn:aws:secretsmanager:*:*:secret:*"
                      ]
                    },
                    {
                      "Sid": "LambdaGetConfiguration",
                      "Effect": "Allow",
                      "Action": [
                          "lambda:GetFunctionConfiguration"
                      ],
                      "Resource": [
                          "arn:aws:lambda:*:*:function:*"
                      ]
                    }
                  ]
                }
                
              3. Replace wildcard * with the region, account, and resource name information where required.

              4. This step is required if KMS is used to encrypt ESA password.

                Add policy entry below. Replace ESA PASSWORD KMS KEY ARN with the value recorded in Option 2: KMS Encrypted Password.

                
                  {
                    "Sid": "KmsDecryptEsaPassword",
                    "Effect": "Allow",
                    "Action": [
                      "kms:Decrypt"
                    ],
                    "Resource": [
                      "**ESA PASSWORD KMS KEY ARN**"
                    ]
                  }
                
              5. Select Next type in the policy name and Create Policy. Record policy name:

                Policy Name: ___________________

              Create Agent Lambda IAM Role

              Perform the following steps to create Agent Lambda execution IAM role.

              To create agent Lambda IAM role:

              1. From AWS IAM console, select Roles > Create Role.

              2. Select AWS Service > Lambda > Next.

              3. Select the policy created in Create Agent Lambda IAM policy.

              4. Proceed to Name, Review and Create.

              5. Type the role name, for example, ProtegrityAgentRole and click Confirm.

              6. Select Create role.

              7. Record the role ARN.

                Agent Lambda IAM Execution Role Name: ___________________

              Corporate Firewall Configuration

              If an on-premise firewall is used, then the firewall must allow access from the NAT Gateway to an ESA. The firewall must allow access from the NAT Gateway IP to ESA via port 443 and 443.

              CloudFormation Installation

              Create the Policy Agent in the VPC using the CloudFormation script provided by Protegrity.

              1. Access the CloudFormation service.

              2. Select the target installation region.

              3. Create a stack with new resources.

              4. Upload the Policy Agent CloudFormation template (file name: pty_agent_cf.json).

              5. Specify the following parameters for Cloud Formation:

                ParameterDescriptionNote
                VPCVPC where the Policy Agent will be hostedIdentify or Create a new VPC
                SubnetSubnet where the Policy Agent will be hostedVPC Subnet Configuration
                PolicyAgentSecurityGroupIdSecurity Group Id, which allows communication between the Policy Agent and the ESAIdentify or Create Security Groups
                LambdaExecutionRoleArnAgent Lambda IAM execution role ARN allowing access to the S3 bucket, KMS encryption Key, Lambda and Lambda LayerCreate Agent Lambda IAM Role
                ArtifactS3BucketS3 bucket name with deployment package for the Policy AgentUse S3 Bucket name recorded in Create S3 bucket for Installing Artifacts
                CreateCRONJobSet to True to create a CloudWatch schedule for the agent to run.Default: False

              Policy Agent Lambda Configuration

              After the CloudFormation stack is deployed, the Policy Agent Lambda must be configured with parameters recorded in earlier steps. From your AWS Console, navigate to lambda and select the following Lambda.

              Protegrity_Agent<STACK_NAME>_

              Select Configuration tab and scroll down to the Environment variables section. Select Editand replace all entries with the actual values.

              Parameter

              Description

              Notes

              PTY_ESA_IP

              ESA IP address or hostname

              ESA Server

              PTY_ESA_CA_SERVER_CERT

              ESA self-signed CA certificate or your corporate CA certificate used by policy Agent Lambda 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.

              PTY_ESA_CA_SERVER_CERT_SECRET

              This configuration option fulfills the same function as PTY_ESA_CA_SERVER_CERT but supports larger configuration values, making it the recommended choice. The value should specify the name of the AWS Secrets Manager secret containing the ESA self-signed CA certificate. The secret value should be set to the json with “PTY_ESA_CA_SERVER_CERT” key and PEM formated CA certificate content value as shown below.

              {
                "PTY_ESA_CA_SERVER_CERT":"-----BEGIN CERTIFICATE----- MIIF..."
              }
              

              Recorded in step Certificates on ESA

              In case ESA is configured with publicly signed certificates, the PTY_ESA_CA_SERVER_CERT_SECRET configuration will be ignored. When both PTY_ESA_CA_SERVER_CERT and PTY_ESA_CA_SERVER_CERT_SECRET are configured the PTY_ESA_CA_SERVER_CERT_SECRET takes precedence.

              PTY_ESA_CREDENTIALS_SECRET

              ESA username and password (encrypted value by AWS Secrets Manager)

              Option 1: Secrets Manager

              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.

              AWS_KMS_KEY_ID

              KMS key id or full ARN e.g. arn:aws:kms:us-west-2:112233445566:key/bfb6c4fb-509a-43ac-b0aa-82f1ca0b52d3

              Create KMS Key

              AWS_POLICY_S3_BUCKET

              S3 bucket where the encrypted policy will be written

              S3 bucket of your choice

              AWS_POLICY_S3_FILENAME

              Filename of the encrypted policy stored in S3 bucket

              Default: protegrity-policy.zip

              AWS_PROTECT_FN_NAME

              Comma separated list of Protect function names or ARNs

              ProtectFunctionName(s), recorded in CloudFormation Installation

              DISABLE_DEPLOY

              This flag can be either 1 or 0. If set to 1, then the agent will not update PTY_PROTECT lambda with the newest policy. Else, the policy will be saved in the S3 bucket and deployed to the Lambda Layer

              Default: 0

              AWS_POLICY_LAYER_NAME

              Lambda layer used to store the Protegrity policy used by the PTY_PROTECT function

               

              POLICY_LAYER_RETAIN

              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: 2

              POLICY_PULL_TIMEOUT

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

              Default: 20s

              ESA_CONNECTION_TIMEOUT

              Time in seconds to wait for the ESA response

              Default: 5s

              LOG_LEVEL

              Application and audit logs verbiage level

              Default: INFO

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

              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

              PTY_CORE_CASESENSITIVE

              Specifies whether policy usernames should be case sensitive

              Default: no

              Allowed values:

              yes

              no

              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_ESA_USERNAME

              Plaintext ESA username which is used together with PTY_ESA_ENCRYPTED_PASSWORD as an optional ESA credentials

              Option 2: KMS Encrypted Password

              Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

              PTY_ESA_ENCRYPTED_PASSWORD

              ESA password encrypted with KMS symmetric key.

              Example AWS cli command to generate the value:

              aws kms encrypt --key-id <your key ARN> --plaintext '<your-esa-password-base64>'

              Option 2: KMS Encrypted Password

              Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

              Value must be base64 encoded

              EMPTY_POLICY_S3

              This flag can be either 1 or 0. If set to 1, then the agent will remove the content of the policy file in S3 bucket, but will keep the checksum in the metadata. Else, the policy will be saved in the S3 bucket and not removed.

              Default: 0

              PTY_ESA_CREDENTIALS_LAMBDA

              Lambda function to return ESA credentials

              Recorded in step Option 3: Custom AWS Lambda function LAMBDA FOR ESA CREDENTIALS. Presence of PTY_ESA_USERNAME, or PTY_ESA_CREDENTIALS_SECRET will cause this value to be ignored.

              The Policy Agent Lambda must have network access and IAM permissions to invoke the custom ESA Credentials Lambda you have created in Option 3: Custom AWS Lambda function.

              Test Installation

              Open the Lambda and configure Test to execute the lambda and specify the default test event. Wait for around 20 seconds for the Lambda to complete. If policy is downloaded successfully, then a success message appears.

              Navigate to the AWS_POLICY_S3_BUCKET bucket and verify that the AWS_POLICY_S3_FILENAME file was created.

              Troubleshooting

              Lambda Error

              Example Error

              Action

              Task timed out after x seconds

              2020-10-06T23:40:54.121Z 2dc84942-b5cc-4be9-aa4c-965f322307e4 Task timed out after 90.09 seconds
              
              1. Ensure that there is network connectivity between the Lambda and ESA. Check the Security groups and/or Network firewall configuration
              2. When using internal VPC, AWS Lambda needs to have access to AWS Network. The Policy Agent Lambda can start using Secrets Manager with Amazon VPC endpoints by creating an Amazon VPC endpoint for Secrets Manager.

              ESA connection error. Failed to download certificates

              Policy Pull takes a long time

              {
                "errorMessage": "Timeout! Unable to download policy in 20 seconds.",
                "errorType": "Exception",
                "stackTrace": [...]
              }
              
              1. Increase POLICY_PULL_TIMEOUT.
              2. Ensure that there is at least 1 policy with datastore matching the Lambda Policy Agent. Other considerations:
                1. Policy has default datastore.
                2. Policy has datastores matching AWS lambda IP range (check the subnet IP Range).
                3. Lambda function has static IP, and at least one Data store has matching IP.

              ESA connection error. Failed to download certificates. HTTP response code: 401

              {
                "errorMessage": "ESA connection error. Failed to download certificates. HTTP response code: 401.",
                "errorType": "ConnectionError",
                "stackTrace": [...]
              }
              

              Ensure that the PTY_ESA_CREDENTIALS_SECRET has correct ESA username and password

              An error occurred (AccessDeniedException) when calling xyz operation

              xyz Access Denied: Exception
              Traceback (most recent call last):
                … Exception: xyz Access Denied
              

              Ensure that the Lambda execution role has permission to call the xyz operation

              Access Denied to Secret Manager.

              Secrets Manager Access Denied: Exception
              Traceback (most recent call last):
                … Exception: Secrets Manager Access Denied
              
              1. Ensure that the Lambda execution role has permissions to get the Secret Manager secret name.
              2. Ensure that the Lambda execution role has permission to get the Secret Manager secret Encryption Key.

              Master Key xyz unable to generate data key

              Ensure that the Lambda can access xyz CMK key

              The S3 bucket server-side encryption is enabled, the encryption key type is SSE-KMS but the Policy Agent execution IAM role doesn’t have permissions to encrypt using the KMS key .

              [ERROR] PolicyAgentException: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
              

              Add the following permissions to the Policy Agent excution role.

              kms:Decrypt
              kms:GenerateDatakey
              

              The S3 bucket has bucket policy to only allow access from within the VPC.

              An error occurred (AccessDeniedException) when calling the PublishLayerVersion operation: Your access has been denied by S3,
              please make sure your request credentials have permission to GetObject for BUCKET_NAME/FILENAME. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
              

              The Policy Agent publishes a new Lambda Layer version, and the Lambda Layer service uploads the policy file from the s3 bucket and the upload request is originated from the AWS service outside the Policy Agent Lambda VPC. Update the S3 bucket resource policy to allow access from AWS Service. Sample security policy to lock down access to the vpc:

              {
                "Version": "2012-10-17",
                "Statement": [
                  {
                    "Sid": "VpcRestrictions",
                    "Effect": "Deny",
                    "Principal": {
                      "AWS": "*"
                    },
                    "Action": "s3:*Object",
                    "Resource": [
                      "arn:aws:s3:::<s3_bucket_name>/*",
                      "arn:aws:s3:::<s3_bucket_name>"
                    ],
                    "Condition": {
                      "Bool": {
                        "aws:ViaAWSService": "false"
                      },
                      "StringNotEquals": {
                        "aws:sourceVpc": "<vpc_id>"
                      }
                    }
                  }
                ]
              }
              

              Additional Configuration

              Strengthen the KMS IAM policy by granting access only to the required Lambda function(s).

              Finalize the IAM policy for the Lambda Execution Role. Ensure to replace wildcard * with the region, account, and resource name information where required.

              For example,

              "arn:aws:lambda:*:*:function:*" -> "arn:aws:lambda:us-east-1:account:function:function_name"
              

              Policy Agent Schedule

              If specified in CloudFormation Installation, the agent installation created a CloudWatch event rule, which checks for policy update on an hourly schedule. This schedule can be altered to the required frequency.

              Under CloudWatch > Events > Rules, find Protegrity_Agent_{stack_name}. Click Action > Edit Set the cron expression. A cron expression can easily be defined using CronMaker, a free online tool. Refer to http://www.cronmaker.com.

              What’s Next

              1.1.3.5 - Audit Log Forwarder Installation

              Install the audit log forwarder.

                The following sections show steps how to install Audit Log Forwarder component in the AWS Cloud. The Log Forwarder deployment allows for the audit logs generated by Protector to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protector Service to work properly. See Log Forwarding Architecture section in this document for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. C ontact Protegrity for further guidance on configuration alternatives in the Cloud.

                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 (Audit Store) or 24284 (td-agent).

                2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                Certificates on ESA

                By default, ESA is configured with self-signed certificates, which can optionally be validated using a self-signed CA certificate supplied in the Log Forwarder configuration. If no CA certificate is provided, the Log Forwarder will skip server certificate validation.

                If ESA is configured with publicly signed certificates, this section can be skipped since the forwarder Lambda will use the public CA to validate ESA certificates.

                To obtain the 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 PtyEsaCaServerCert cloudformation parameter in section Install through CloudFormation

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

                AWS VPC Configuration

                Log forwarder Lambda function requires network connectivity to ESA, similar to Policy Agent Lambda function. Therefore, it can be hosted in the same VPC as Policy Agent.

                Separate VPC can be used, as long as it provides network connectivity to ESA.

                VPC Name: ___________________

                VPC Subnet Configuration

                Log Forwarder can be connected to the same subnet as Policy Agent or separate one as long as it provides connectivity to ESA.

                Subnet Name: ___________________

                NAT Gateway For ESA Hosted Outside AWS Network

                If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                VPC Endpoint Configuration

                Log Forwarder Lambda function requires connectivity to Secrets Manager AWS service. If the VPC identified in the steps before has no connectivity to public internet through the NAT Gateway, then the following service endpoint must be configured:

                • com.amazonaws.{REGION}.cloudwatch
                • com.amazonaws.{REGION}.secretsmanager
                • com.amazonaws.{REGION}.kms

                Security Group Configuration

                Security groups restrict communication between Log Forwarder Lambda function and the ESA appliance. The following rules must be in place for ESA and Log Forwarder Lambda function.

                From VPC > Security Groups > Log Forwarder Security Group configuration.

                TypeProtocolPort RangeDestinationReason
                Custom TCPTCP9200Log Forwarder Lambda SGESA Communication

                Record the name of Log Forwarder security group name.

                Log Forwarder Security Group Id: ___________________

                The following port must be open for the ESA. If the ESA is running in the Cloud, then create the following security.

                ESA Security Group configuration

                TypeProtocolPort RangeSource
                Custom TCPTCP9200Log Forwarder Lambda SG

                Configure ESA Audit Store Credentials

                Audit Log Forwarder can optionally authenticate with ESA using certificate-based authentication with a client certificate and certificate key. If used, both the certificate and certificate key will be stored in AWS Secrets Manager.

                Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                • client.key
                • client.pem

                After certificates are downloaded, open each 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 commands below depending on your operating system.

                Linux Bash:

                awk 'NF {printf "%s\\n",$0;}' client.key > private_key.txt
                awk 'NF {printf "%s\\n",$0;}' client.pem > public_key.txt
                

                Windows PowerShell:

                (Get-Content '.\client.key') -join '\n' | Set-Content 'private_key.pem'
                (Get-Content '.\client.pem') -join '\n' | Set-Content 'public_key.pem'
                

                For more information on how to configure client certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                To create secret with ESA client certificate/key pair in AWS Secrets Manager.

                1. From the AWS Secrets Manager Console, select Store New Secret.

                2. Select Other Type of Secrets.

                3. Specify the private_key and public_key value pair.

                4. Select the encryption key or leave default AWS managed key.

                5. Specify the Secret Name and record it below.

                  ESA Client Certificate/Key Pair Secret Name: ___________________

                  This value will be used to set PtyEsaClientCertificatesSecretId cloudformation parameter in section Install through CloudFormation

                Create Audit Log Forwarder IAM Execution Policy

                This task defines a policy used by the Protegrity Log Forwarder Lambda function to write CloudWatch logs, access the KMS encryption key to decrypt the policy and access Secrets Manager for log forwarder user credentials.

                Perform the following steps to create the Lambda execution role and required policies:

                1. From the AWS IAM console, select Policies > Create Policy.

                2. Select the JSON tab and copy the following sample policy.

                  {
                    "Version": "2012-10-17",
                    "Statement": [
                      {
                        "Sid": "EC2ModifyNetworkInterfaces",
                        "Effect": "Allow",
                        "Action": [
                          "ec2:CreateNetworkInterface",
                          "ec2:DescribeNetworkInterfaces",
                          "ec2:DeleteNetworkInterface"
                        ],
                        "Resource": "*"
                      },
                      {
                        "Sid": "CloudWatchWriteLogs",
                        "Effect": "Allow",
                        "Action": [
                          "logs:CreateLogGroup",
                          "logs:CreateLogStream",
                          "logs:PutLogEvents"
                        ],
                        "Resource": "*"
                      },
                      {
                        "Sid": "KmsDecrypt",
                        "Effect": "Allow",
                        "Action": [
                          "kms:Decrypt"
                        ],
                        "Resource": [
                          "arn:aws:kms:*:*:key/*"
                        ]
                      },
                      {
                          "Sid": "KinesisStreamRead",
                          "Effect": "Allow",
                          "Action": [
                              "kinesis:GetRecords",
                              "kinesis:GetShardIterator",
                              "kinesis:DescribeStream",
                              "kinesis:DescribeStreamSummary",
                              "kinesis:ListShards",
                              "kinesis:ListStreams"
                          ],
                          "Resource": "*"
                      },
                      {
                        "Sid": "SecretsManagerGetSecret",
                        "Effect": "Allow",
                        "Action": [
                          "secretsmanager:GetSecretValue"
                        ],
                        "Resource": [
                          "arn:aws:secretsmanager:*:*:secret:*"
                        ]
                      }
                    ]
                  }
                  
                3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                4. Select Review policy, type in a policy name, for example, ProtegrityLogForwarderLambdaPolicy and Confirm. Record the policy name:

                  LogForwarderLambdaPolicyName:__________________

                Create Log Forwarder IAM Role

                Perform the following steps to create Log Forwarder execution IAM role.

                To create Log Forwarder IAM role:

                1. From AWS IAM console, select Roles > Create Role.

                2. Select AWS Service > Lambda > Next.

                3. Select the policy created in Create Audit Log Forwarder IAM Execution Policy.

                4. Proceed to Name, Review and Create.

                5. Type the role name, for example, ProtegrityForwarderRole and click Confirm.

                6. Record the role ARN.

                  Log Forwarder IAM Execution Role Name: ___________________

                Installation Artifacts

                Audit Log Forwarder installation artifacts are part of the same deployment package as the one used for protect and policy agent services. Follow the steps below to ensure the right artifacts are available for log forwarder installation.

                1. Verify that the Protegrity deployment package is available on your local system, if not, you can download it from the Protegrity portal.

                2. Extract the pty_log_forwarder_cf.json cloud formation file from the deployment package.

                3. Check the S3 deployment bucket identified in section Create S3 bucket for Installing Artifacts. Make sure that all Protegrity deployment zip files are uploaded to the S3 bucket.

                Install through CloudFormation

                The following steps describe the deployment of the Audit Log Forwarder AWS cloud components.

                1. Access CloudFormation and select the target AWS Region in the console.

                2. Click Create Stack and choose With new resources.

                3. Specify the template.

                4. Select Upload a template file.

                5. Upload the Protegrity-provided CloudFormation template called pty_log_forwarder_cf.json and click Next.

                6. Specify the stack details. Enter a stack name.

                7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                Parameter

                Description

                Default Value

                Required

                LogForwarderSubnets

                Subnets where the Log Forwarder will be hosted.

                 

                 

                LogForwarderSecurityGroups

                Security Groups, which allow communication between the Log Forwarder and ESA.

                 

                X

                LambdaExecutionRoleArn

                The ARN of Lambda role created in the prior step.

                 

                X

                ArtifactS3Bucket

                Name of S3 bucket created in the pre-configuration step.

                 

                X

                LogDestinationEsaIp

                IP or FQDN of the ESA instance or cluster.

                 

                X

                AuditLogOutput

                Audit log processor to target on ESA. Allowed values: audit-store, td-agent

                audit-store

                X

                PtyEsaClientCertificatesSecretId

                AWS Secrets Manager secret id containing client certificates used for authentication with ESA Audit Store. It is expected that the public key will be stored in a field public_key and the private key in a field named private_key.

                This parameter is optional. If not provided, Log Forwarder will connect to ESA without client certificate authentication.

                EsaTlsDisableCertVerify

                Disable certificate verification when connecting to ESA if set to 1. This is only for dev purposes, do not disable in production environment.

                0

                X

                PtyEsaCaServerCert

                ESA self-signed CA certificate used by log forwarder Lambda to ensure ESA is the trusted server.

                Recorded in step Certificates on ESA

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

                 

                EsaConnectTimeout

                Time in seconds to wait for the ESA response. Minimum value: 1.

                5

                X

                EsaVirtualHost

                ESA virtual hostname. This configuration is optional and it can be used when proxy server is present and supports TLS SNI extension.

                 

                 

                KinesisLogStreamRetentionPeriodHours

                The number of hours for the log records to be stored in Kinesis Stream in case log destination server is not available. Minimum value: 24. See Log Forwarder Performance section for more details.

                24

                X

                KinesisLogStreamShardCount

                The number of shards that the Kinesis log stream uses. For greater provisioned throughput, increase the number of shards. Minimum value: 1. See Log Forwarder Performance section for more details.

                10

                X

                MinLogLevel

                Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                severe

                X

                1. Click Next with defaults to complete CloudFormation.

                2. After CloudFormation is completed, select the Outputstab in the stack.

                3. Record the following values

                  KinesisLogStreamArn: ________________________________

                Add Kinesis Put Record permission to the Protect Function IAM Role

                1. Login to the AWS account that hosts the Protect Lambda Function.

                2. Search for Protect Lambda Function IAM Execution Role Name created in Create Protect Lambda IAM role.

                3. Under Permissions policies, select Add Permissions > Create inline policy.

                4. In Specify permissions view, switch to JSON.

                5. Copy the policy json from below replacing the placeholder value indicated in the following snippet as <Audit Log Kinesis Stream ARN> with the value recorded in the previous step.

                  {
                  	"Version": "2012-10-17",
                  	"Statement": [
                  		{
                  			"Sid": "KinesisPutRecords",
                  			"Effect": "Allow",
                  			"Action": "kinesis:PutRecords",
                  			"Resource": "<Audit Log Kinesis Stream ARN>"
                  		}
                  	]
                  }
                  
                6. When you are finished, choose Next.

                7. On the Review and create page, type a Name, then choose Create policy.

                Test Log Forwarder Installation

                Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                1. Navigate to the log forwarder lambda function.

                2. Select the Test tab.

                3. Copy the json test event into the Event JSON pane.

                  {
                      "Records": [
                          {
                              "kinesis": {
                                  "kinesisSchemaVersion": "1.0",
                                  "partitionKey": "041e96d78c778677ce43f50076a8ae3e",
                                  "sequenceNumber": "49620336010289430959432297775520367512250709822916263938",
                                  "data": "eyJpbmdlc3RfdGltZV91dGMiOiIyMDI2LTAzLTI3VDEzOjIzOjEyLjkwNFoiLCJhZGRpdGlvbmFsX2luZm8iOnsiZGVzY3JpcHRpb24iOiJEYXRhIHVucHJvdGVjdCBvcGVyYXRpb24gd2FzIHN1Y2Nlc3NmdWwuIn0sImNsaWVudCI6e30sImNudCI6NCwiY29ycmVsYXRpb25pZCI6InJzLXF1ZXJ5LWlkOjEyMzQiLCJsZXZlbCI6IlNVQ0NFU1MiLCJsb2d0eXBlIjoiUHJvdGVjdGlvbiIsIm9yaWdpbiI6eyJob3N0bmFtZSI6IlBSTy1VUy1QRjNSSEdGOSIsImlwIjoiMTAuMTAuMTAuMTAiLCJ0aW1lX3V0YyI6MTcxMTU1OTEwMH0sInByb2Nlc3MiOnsiaWQiOjJ9LCJwcm90ZWN0aW9uIjp7ImF1ZGl0X2NvZGUiOjgsImRhdGFlbGVtZW50IjoiYWxwaGEiLCJkYXRhc3RvcmUiOiJTQU1QTEVfUE9MSUNZIiwibWFza19zZXR0aW5nIjoiIiwib2xkX2RhdGFlbGVtZW50IjpudWxsLCJvcGVyYXRpb24iOiJVbnByb3RlY3QiLCJwb2xpY3lfdXNlciI6IlBUWURFViJ9LCJwcm90ZWN0b3IiOnsiY29yZV92ZXJzaW9uIjoiMS4yLjErNTUuZzU5MGZlLkhFQUQiLCJmYW1pbHkiOiJjcCIsInBjY192ZXJzaW9uIjoiMy40LjAuMTQiLCJ2ZW5kb3IiOiJyZWRzaGlmdCIsInZlcnNpb24iOiIwLjAuMS1kZXYifSwic2lnbmF0dXJlIjp7ImNoZWNrc3VtIjoiN0VCMkEzN0FDNzQ5MDM1NjQwMzBBNUUxNENCMTA5QzE0OEJGODYwRjE3NEVCMjMxMTAyMEI3RkE1QTY4MjdGQyIsImtleV9pZCI6ImM0MjQ0MzZhLTExMmYtNGMzZi1iMmRiLTEwYmFhOGI1NjJhNyJ9fQ==",
                                  "approximateArrivalTimestamp": 1626878559.213
                              },
                              "eventSource": "aws:kinesis",
                              "eventVersion": "1.0",
                              "eventID": "shardId-000000000000:49620336010289430959432297775520367512250709822916261234",
                              "eventName": "aws:kinesis:record",
                              "invokeIdentityArn": "arn:aws:iam::555555555555:role/service-role/TestRole",
                              "awsRegion": "us-east-1",
                              "eventSourceARN": "arn:aws:kinesis:us-east-1:555555555555:stream/CloudProtectEventStream"
                          }
                      ]
                  }
                  
                4. Select Test to execute the test event.

                5. Test is successful if the Log Output of test results contains the following log:

                  [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                  

                  If the log is not present, please consult the Troubleshooting section for common errors and solutions.

                Update Protector With Kinesis Log Stream

                In this section, Kinesis log stream ARN will be provided to the Protect Function installation.

                1. Navigate to the Protector CloudFormation stack created in the protector installation section.

                2. Select Update.

                3. Choose Use existing template > Next.

                4. Set parameter KinesisLogStreamArn to the output value recorded in Install through CloudFormation.

                5. Proceed with Next and Submit the changes.

                6. Continue to the next section once stack status indicates UPDATE_COMPLETE.

                Update Policy Agent With Log Forwarder Function Target

                Log Forwarder Lambda function requires a policy layer which is in sync with the Protegrity Protector. This section will describe the steps to update the policy agent to include updating Log Forwarder Lambda function.

                1. Navigate to the Policy Agent Function created in Policy Agent Installation

                2. Select Configuration > Environment variables > Edit

                3. Edit the value for environment variable AWS_PROTECT_FN_NAME to include the log forwarder function name/arn in the comma separated list of Lambda functions.

                4. Save the changes and continue when update completes

                5. Navigate to Test tab

                6. Add an event {} and select Test to run the Policy Agent function

                7. Verify Log forwarder function was updated to use the policy layer by inspecting the log output. Logs should include the following:

                  
                  [INFO] 2024-07-09 18:58:04,793.793Z 622d374b-1f73-4123-9a38-abc61973adef iap_agent.policy_deployer:Updating lambda [Protegrity_LogForwarder_<stack ID>] to use layer version [arn:aws:lambda:<aws region>:<aws account number>:layer:Protegrity_Layer_<layer name>:<layer version>]
                  

                Test Full Log Forwarder Installation

                Install and configure Protegrity Agent, Protector, and Log Forwarder components.

                1. Send a protect operation to the protector using a data element or user which will result in audit log generation

                2. Navigate to the CloudWatch log group for the Protect function

                3. Select the log stream for the test operation and scroll to the latest logs

                4. Expect to see a log similar to the below:

                  
                  [2024-07-09T19:28:23.158] [INFO] [kinesis-external-sink.cpp:51] Sending 2 logs to Kinesis ...
                  [2024-07-09T19:28:23.218] [INFO] [aws-utils.cpp:206] Kinesis send time: 0.060s
                  
                5. Navigate to the CloudWatch log group for the Log Forwarder function

                6. Expect to see a new log stream - it may take several minutes for the stream to start

                7. Select the new stream and scroll to the most recent logs in the stream

                8. Expect to see a log similar to the below:

                  
                  [2024-07-09T19:32:31.648] [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                  

                Troubleshooting

                Error

                Action

                Log forwarder log contains severe level secrets permissions error:

                [SEVERE] User: <arn> is not authorized to perform: secretsmanager:
                GetSecretValue on resource: <secret name> because no identity-based
                policy allows the secretsmanager:GetSecretValue action
                
                1. Verify the permission policy/role attached to the log forwarder function has secretsmanager:GetSecretValue permission for the insights esa user credentials secret.
                2. Consult sections Configure ESA Audit Store Credentials and Create Audit Log Forwarder IAM Execution Policy

                When testing log forwarder as described in Test Log Forwarder Installation, response contains policy decryption error:

                
                {
                  "error_msg": "Failed to decrypt the policy. Please verify
                    that the function has access to the key service and the key.",
                  "success": false
                }
                
                1. Verify the permission policy/role attached to the log forwarder function has kms:Decrypt permission for KMS key used to encrypt the Protegrity security policy.
                2. Consult section Create Audit Log Forwarder IAM Execution Policy

                Cloudformation stack creation fails with error:

                
                The provided execution role does not have permissions to call
                [CreateNetworkInterface|DescribeNetworkInterfaces|DeleteNetworkInterface]
                on EC2 (Service: Lambda, Status Code: 400, Request ID: <request id>)"
                (RequestToken: <request token>, HandlerErrorCode: InvalidRequest)
                
                1. Verify the permission policy/role attached to the log forwarder function has ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, ec2:DeleteNetworkInterface permissions
                2. Consult section Create Audit Log Forwarder IAM Execution Policy

                Severe level kinesis permissions log message in protector function:

                
                [SEVERE] Kinesis stream client returned 400 error with error message:
                User: <function arn> is not authorized to perform: kinesis:PutRecords
                on resource: <kinesis stream arn> because no identity-based policy
                allows the kinesis:PutRecords action
                
                1. Verify the permission policy/role attached to the protector function has kinesis:PutRecords permission
                2. Consult section Add Kinesis Put Record permission to the Protect Function IAM Role

                TLS errors reported in log forwarder function logs:

                
                [error] [tls] <error message>
                
                1. If ESA is using self-signed certificate, verify the correct ESA certificate has been given in the format described in Certificates on ESA

                1.1.3.6 -

                Cheat Sheet Recommendation

                AWS Account ID: ___________________

                AWS Region (AwsRegion): ___________________

                S3 Bucket name (ArtifactS3Bucket): ___________________

                KMS Key ARN (AWS_KMS_KEY_ID): ___________________

                ProtectLambdaPolicyName: __________________

                Role ARN (LambdaExecutionRoleArn): ___________________

                ApiGatewayId: ________________________________

                ProtectFunctionName: __________________________

                ProtectLayerName: _____________________________

                ESA IP address: ___________________

                VPC name: ___________________

                Subnet name: ___________________

                Policy Agent Security Group Id: ___________________

                ESA Credentials Secret Name: ___________________

                Policy Name: ___________________

                Agent Lambda IAM Execution Role Name: ___________________

                1.1.3.7 -

                Prerequisites

                Requirement

                Detail

                Protegrity distribution and installation scripts

                These artifacts are provided by Protegrity

                Protegrity ESA 10.0+

                The Cloud VPC must be able to obtain network access to the ESA

                AWS Account

                Recommend creating a new sub-account for Protegrity Serverless

                1.1.3.8 -

                AWS Services

                The following table describes the AWS services that may be a part of your Protegrity installation.

                Service

                Description

                Lambda

                Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                API Gateway

                Provides the endpoint and access control.

                KMS

                Provides secrets for envelope policy encryption/decryption for Protegrity.

                Secrets Manager

                Provides secrets management for the ESA credentials .

                S3

                Intermediate storage location for the encrypted ESA policy layer.

                Kinesis

                Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                VPC & NAT Gateway

                Optional. Provides a private subnet to communicate with an on-prem ESA.

                CloudWatch

                Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                1.1.3.9 -

                Required Skills and Abilities

                Role / Skillset

                Description

                AWS Account Administrator

                To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

                Protegrity Administrator

                The ESA credentials required to extract the policy for the Policy Agent

                Network Administrator

                To open firewall to access ESA and evaluate AWS network setup

                1.1.4 - REST API

                Reference for Cloud API authorization and specification

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

                Base URL:

                https://{ApiGatewayId}.execute-api.{Region}.amazonaws.com/pty/v1
                

                Once Protegrity Serverless REST API is installed, you can export the OpenAPI documentation file from API Gateway Export API, located in the AWS API Gateway Control Service.

                https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html

                For testing the REST API, we recommend using tools, such as, Postman.

                1.1.4.1 - Authorization

                Describes the available authorization methods

                  Policy Users

                  Protegrity Policy roles defines the unique data access privileges for every member. The Protegrity Lambda protects the data with the username sent in either the JWT-formatted authorization header or the request body.

                  The lambda behavior can be set in the Lambda environment variables as described in Protect Lambda Configuration

                  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.

                  JWT Verification

                  To ensure the integrity of the user, the lambda protect can verify the JWT.

                  1. From your AWS console, navigate to lambda and select the following Lambda: Protegrity_Protect_RESTAPI_<STACK_NAME>
                  2. Scroll down to the Environment variables section, select Edit to replace the entries.

                  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.1.4.2 - HTTP Status Codes

                  Describes the Status Codes returned by Cloud API

                  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 AWS Lambda’s CloudWatch logs.

                  For example, the following error appears.

                  Authorization header was not found.
                  
                  1. Required attribute is missing /user, when env authorization is None or empty.
                  2. User is missing, check JWT payload for user attribute
                  3. Malformed authorization header
                  4. Basic Not supported in header: authorization

                  403

                  {
                      "error_msg": "token expired",
                      "success": false
                  }
                  
                  {
                      "error_msg": "invalid signature",
                      "success": false
                  }
                  {
                      "error_msg": " unknown algorithm error",
                      "success": false
                  }
                  
                  1. JWT is invalid because secret is wrong or expired.
                  2. Get A new JWT or check the base64 secret in AWS Lambda environment variable.
                  3. Secret doesn’t match the algorithm type in the JWT header. Secret is symmetric but Algorithm is asymmetric.

                  500

                  {
                      "error_msg": "Invalid json array in jwt_user_claim",
                      "success": false
                  }
                  
                  {    "error_msg": "jwt secret is missing ",
                      "success": false
                  }
                  
                  1. Configuration error in AWS Lambda.

                  Authorization is to JWT and jwt _user_claim is not a valid json array. Example valid input: [“username”, “firstname”].

                  1. JWT is set to verify and jwt_secret_base64 is missing.

                  1.1.4.3 - Payload Encoding

                  Describes the request/response payload encoding

                  Payload Encoding

                  The following encoding formats are supported in the REST API.

                  For every encoding, the resultant protected data is returned in the same encoding. For example, if request is hex-encoded, the response is also hex-encoded.

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

                  Encoding

                  Supported by data elements

                  Notes

                  utf8

                  All except binary data elements.

                  Default encoding if encoding is not specified.

                  hex

                  All

                  Default encoding for binary data elements.

                  base64

                  All

                  base64_mime

                  All

                  • Uses RFC 2045 Alphabet.
                  • Accepts input on multiple lines.
                  • Lines can be separated by any combination of CR and LF characters.
                  • Lines must not be longer than 76 characters long.
                  • Response lines are separated by CRLF characters.
                  • Optional padding.
                  • Does not accept any non-base64 characters.

                  base64_pem

                  All

                  • Uses RFC 1421 Alphabet.
                  • Accepts input on multiple lines.
                  • Lines can be separated by any combination of CR and LF characters.
                  • Lines must not be longer than 64 characters long.
                  • Response lines are separated by CRLF characters.
                  • Optional padding.
                  • Does not accept any non-base64 characters.

                  base64_url

                  All

                  The following sections provide the payload schema and its examples.

                  1.1.4.4 - TLS Mutual Authentication

                  Describes the TLS Mutual Authentication setup for AWS API Gateway

                  By default, AWS API Gateway supports HTTPS endpoint and doesn’t allow HTTP protocol.

                  For an additional layer of security, you can configure AWS API Gateway TLS Mutual Authentication.

                  AWS API Gateway will ensure that the clients with a valid certificate only can call the REST API. Protegrity recommends to setup TLS Mutual Authentication in AWS API Gateway. For more information on how to set AWS API Gateway Mutual TLS go to the following link.

                  https://docs.aws.amazon.com/apigateway/latest/developerguide/rest-api-mutual-tls.html

                  1.1.4.5 - v1 Specification

                  Describes the v1 REST API specification

                  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.

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

                  Legacy documentation can be downloaded from AWS console, API, Models, prefix Legacy.

                  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.1.5 - Performance

                  Benchmarks and performance tuning

                    Performance Considerations

                    The following factors may cause variation in real performance versus benchmarks:

                    1. Cold startup: The Lambda 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 Lambda is initialized, subsequent “warm executions” should process quickly.
                    2. Noisy neighbors: There are many multi-tenant components in the Cloud. The same request may differ by 50% between runs regardless of Protegrity. A single execution may not be the best predictor of average performance.
                    3. Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                    4. Lambda memory: AWS provides more virtual cores based on the memory configuration. The initial configuration of 1728MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual case.
                    5. Number of protect, unprotect and reprotect security operations.
                    6. Lambda Concurrent and Burst quotas: AWS limits the number of concurrent executions and how quickly lambda can scale to meet demand. This is discussed in an upcoming section of the document.
                    7. Size of data element. Operations on larger text may take more time.
                    8. API Gateway Authentication. API Gateway support different authorizers and authentication method, which may differ.

                    Lambda Tuning

                    AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region.

                    The concurrent executions quota cap is the maximum number of Lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                    The Burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. After the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response.

                    The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended to select an AWS region with the highest burst limits.

                    API Gateway Tuning

                    AWS maintains a Throttle quota for the API Gateway. By default, API Gateway limits concurrent requests to 10,000 requests per second and throttles subsequent traffic with a 429 Too Many Requests error response. This quota applies across all APIs in an account and region.

                    The API Gateway default quota may need to be increased based on the Concurrency table. Keep in mind that hitting quota limits effectively throttles any other API services in the region.

                    The API Gateway also limits burst. Burst is the maximum number of concurrent requests that API Gateway can fulfill at any instant without returning 429 Too Many Requests error responses. This limit can be increased by AWS, but is not adjustable.

                    Enable CloudWatch metrics within the API Gateway to monitor max concurrency and investigate throttling errors. See the Concurrency Troubleshooting section on interpreting CloudWatch metrics.

                    Quotas adjustments are applied for region and account. Throttling is also enabled by default in the API Gateway stage used by the Protegrity Lambda function. The stage configuration throttling must be adjusted if the quota is modified. Stage throttling is shown in the following image.

                    For example, the REST Client makes over 20,000 requests/sec to execute the given query. Using API Gateway’s default settings, the requests exceeding 10,000 requests/sec will be throttled. Therefore, this query may fail intermittently due to a high number of throttling errors.

                    Concurrency Troubleshooting

                    Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a client query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your API Gateway or Lambda services in the region.

                    CloudWatch Metrics can be manually enabled on the API Gateway to reveal if quotas are being reached. Metrics aggregate errors into two buckets that are 4xx and 5xx. CloudWatch logs can be used to access the actual error code. The following table describes how to interpret the CloudWatch metrics.

                    Error TypePossible issueRemedy
                    4xx errorsAPI Gateway burst or throttle quota exceededRequest an increase to the API Gateway throttle quota.
                    5xx errorsLambda concurrent requests or burst quota exceeded. Verify 4xx errors in Lambda Metrics.Request an increase the Lambda concurrent request quota

                    The following screenshot shows an example of searching CloudWatch Logs using Log Insights:

                    Cold-Start Performance

                    Cold-start vs warm execution refers to the state of the Lambda when a request is received. A cold-start undergoes additional initialization, such as, loading the security policy. Warm execution applies to all subsequent requests served by the Lambda.

                    The following table shows an example how these states impact latency and performance:

                    Execution stateAvg. Execution DurationAvg. Total (w/ network latency)
                    Cold execution438 ms522 ms
                    Warm execution< 2ms84 ms

                    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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Amazon Kinesis Stream where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated. 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 Cloud Formation Parameters

                      • AuditLogFlushInterval: Determines the minimum amount of time required for the audit log to be sent to Amazon Kinesis. Changing flush interval may affect the level of aggregation, which in turn may result in different number of connections and different data rates to Amazon Kinesis. Default value is 30 seconds.

                        Increasing the flush interval may result in higher aggregation of audit logs, in fewer connections to Amazon Kinesis, in higher latency of audit logs arriving to ESA and in higher data throughput.

                        Lowering the flush interval may result in lower aggregation of audit logs, in more connections to Amazon Kinesis, in lower latency of audit logs arriving to ESA and in lower data throughput.

                        It is not recommended to reduce the flush interval from default value in production environment as it may overload the Amazon Kinesis service. However, it may be beneficial to reduce flush interval during testing to make audit records appear on ESA faster.

                          

                    • Log Forwarder Cloud Formation Parameters

                      • Amazon KinesisLogStreamShardCount: The number of shards represents the level of parallel streams in the Amazon Kinesis and it is proportional to the throughput capacity of the stream. If the number of shards is too low and the volume of audit logs is too high, Amazon Kinesis service may be overloaded and some audit records sent from protect function may be lost.

                        Default value is 10, however you are advised to test with a production-like load to determine whether this is sufficient or not.

                      • Amazon KinesisLogStreamRetentionPeriodHours: The time for the audit records to be retained in Amazon Kinesis log stream in cases where log forwarder function is unable to read records from the Kinesis stream or send records to ESA, for example due to a connectivity outage. Amazon Kinesis will retain failed audit records and retry periodically until connectivity with ESA is restored or retention period expires.

                        Default value is 24 hours, however you are advised to review this value to align it with your Recovery Time Objective and Recovery Point Objective SLAs.

                          

                    • Monitoring Log Forwarder Resources

                      • Amazon Kinesis Stream Metrics: Any positive value in Amazon Kinesis PutRecords throttled records metric indicates that audit logs rate from protect function is too high. The recommended action is to increase the Amazon KinesisLogStreamShardCount or optionally increase the AuditLogFlushInterval.

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

                        [SEVERE] Dropped records: x.
                        
                      • Protect Function CloudWatch Logs: If protect function is unable to send logs to Amazon Kinesis, it will log the following message:

                        [SEVERE] Amazon Kinesis error, retrying in x ms (retry: y/z) ..."
                        

                        Any dropped audit log records will be reported with the following log message:

                        [SEVERE] Failed to send x/y audit logs to Amazon Kinesis.
                        

                    1.1.6 - Audit Logging

                    Audit log description/formatting

                      Audit Logging

                      Audit records and application logs stream to Amazon CloudWatch Logs or optionally be sent to ESA. 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 Amazon CloudWatch. Third-party solutions may be used if they are supported by Amazon Cloudwatch or AWS Lambda logging extensions. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Amazon CloudWatch, refer to the Amazon CloudWatch User Guide.

                      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

                      Example Audit Records

                      The following are sample audit messages:

                      Protect Success:

                      {
                            "additional_info": {
                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                              "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",
                              "ip": "127.0.0.1",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 6,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            process":{
                              "name":"protect",
                              "id":"13",
                              "module":"coreprovider",
                              "thread_id":"573580544",
                              "user":"sbx_user1051",
                              "platform":"\"Linux_x64\"",
                              "version":"UNKNOWN"
                            },
                            "client": {
                              "ip":"169.254.62.117"
                            },
                            "protector": {
                              "family": "cp",
                              "version": "4.0.0.102",
                              "vendor": "aws.snowflake",
                              "datastore":"SAMPLE_POLICY",
                              "pcc_version": "4.0.0.9",
                              "core_version": "2.1.4+0.g93016.2.1",
                              "lambda_version":"4.0.1"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      User permission denied:

                      {
                            "additional_info": {
                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                              "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",
                              "ip": "127.0.0.1",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 3,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            process":{
                              "name":"protect",
                              "id":"13",
                              "module":"coreprovider",
                              "thread_id":"573580544",
                              "user":"sbx_user1051",
                              "platform":"\"Linux_x64\"",
                              "version":"UNKNOWN"
                            },
                            "client": {
                              "ip":"169.254.62.117"
                            },
                            "protector": {
                              "family": "cp",
                              "version": "4.0.0.102",
                              "vendor": "aws.snowflake",
                              "datastore":"SAMPLE_POLICY",
                              "pcc_version": "4.0.0.9",
                              "core_version": "2.1.4+0.g93016.2.1",
                              "lambda_version":"4.0.1"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      Data element not found:

                      {
                            "additional_info": {
                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                              "description": "The data element could not be found in the policy.",
                              "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",
                              "ip": "127.0.0.1",
                              "time_utc": 1635363966
                            },
                            "protection": {
                              "dataelement": "deAddress",
                              "operation": "Protect",
                              "audit_code": 2,
                              "datastore": "SAMPLE_POLICY",
                              "policy_user": "test_user"
                            },
                            process":{
                              "name":"protect",
                              "id":"13",
                              "module":"coreprovider",
                              "thread_id":"573580544",
                              "user":"sbx_user1051",
                              "platform":"\"Linux_x64\"",
                              "version":"UNKNOWN"
                            },
                            "client": {
                              "ip":"169.254.62.117"
                            },
                            "protector": {
                              "family": "cp",
                              "version": "4.0.0.102",
                              "vendor": "aws.snowflake",
                              "datastore":"SAMPLE_POLICY",
                              "pcc_version": "4.0.0.9",
                              "core_version": "2.1.4+0.g93016.2.1",
                              "lambda_version":"4.0.1"
                            },
                            "signature": {
                              "key_id": "95f5a194-b0a4-4351-a",
                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                            }
                          }
                      

                      1.1.7 - No Access Behavior

                      Describes the result of various policy configurations with no access operations

                      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.1.8 - Known Limitations

                      Known product limitations.

                      Known Limitations

                      Known product limitations:

                      • FPE is supported only for ASCII values.

                      1.1.9 - Upgrading To The Latest Version

                      Instructions for upgrading the protector.

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

                        After downloading the deployment package from the Protegrity Portal, unzip the package to extract the artifact files. In the AWS Console, navigate to the S3 bucket that was previously created to upload deployment artifacts (see: Create S3 bucket for Installing Artifacts).

                        Upload the following artifacts to the S3 bucket:

                        - -
                        • protegrity-protect-<version>.zip
                        • protegrity-agent-<version>.zip
                        • protegrity-external-extension-<version>.zip
                        • protegrity-sample-policy-<version>.zip
                        • protegrity-protect-<version>.zip
                        • protegrity-agent-<version>.zip
                        • protegrity-external-extension-<version>.zip
                        • protegrity-sample-policy-<version>.zip
                        • protegrity-protect-<version>.zip
                        • protegrity-agent-<version>.zip
                        • protegrity-external-extension-<version>.zip
                        • protegrity-sample-policy-<version>.zip
                        • protegrity-athena-protect-udfs-<version>.jar
                        • protegrity-external-extension-<version>.zip
                        • protegrity-agent-<version>.zip
                        • protegrity-sample-policy-<version>.zip

                        If the release version matches your existing deployment, you don’t need to upload it again. Save the following artifacts on your local system so that you have them available during the next steps:

                        - -
                        • pty_protect_cf.json
                        • pty_agent_cf.json
                        • pty_protect_cf.json
                        • pty_agent_cf.json
                        • pty_protect_api_cf.json
                        • pty_agent_cf.json
                        • pty_log_forwarder_cf.json
                        • pty_athena_protect_cf.json
                        • pty_agent_cf.json

                        Perform the following steps to upgrade the Agent Lambda and Protect Lambda separately.

                        Disable Protegrity Agent Function CloudWatch Event Rule

                        Cloud Watch Event Rule is used to periodically run Protegrity Agent Function to synchronize policy from ESA. This functionality is optional when deploying Protegrity Serverless Solution. If the Event Rule is enabled, it must be disabled temporarily for the time of the upgrade process.

                        Follow the steps below to determine if your deployment uses Event Rule and disable it.

                        1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                        2. Select Resources tab from the top portion of the screen.

                        3. Check if there is a resource with ScheduledRule LogicalID. If there is no such resource you can skip to Upgrading Policy Agent Lambda section. If the scheduled rule is there, continue with the next steps in this section.

                        4. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                        5. Select Disable from the top-right portion of the screen. This will disable the rule. You will re-enable it after the upgrade process is complete.

                        Upgrading Policy Agent Lambda

                        1. Go to AWS Lambda console and select existing Protegrity Agent Lambda.

                        2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish. The version of Agent Lambda you just created will serve as restore point in the case you needed to rollback the upgrade.

                        3. Go to Lambda Configuration > Environment variables.

                        4. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                          aws lambda get-function-configuration --function-name \
                          arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                          --query Environment > <function_name>_env_config.json
                          
                        5. Go to AWS Cloud Formation and select existing Protegrity Agent deployment stack.

                        6. Select Update. Check Replace current template > Upload a template file.

                        7. Upload pty_agent_cf.json file and select Next.

                        8. Click Next until Review window and then select Update stack.

                        9. Wait for the Cloud Formation to complete.

                        10. Navigate back to Agent Lambda Function.

                        1. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                          aws lambda update-function-configuration --function-name \
                          arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                          --environment file://./<function_name>_env_config.json
                          
                        2. If you are upgrading from versions prior to v3.0, backup and remove existing policy from the bucket defined by AWS_POLICY_S3_BUCKET property, so that the policy can be re-downloaded and re-encrypted with new ‘key commitment’ feature.

                        3. If you are upgrading from version prior to 1.6.1 please follow the steps below, otherwise the upgrade process is completed.

                        4. From AWS Console, navigate to IAM > Policies

                        5. Search for the Agent Lambda IAM Policy created in Create Agent Lambda IAM policy

                        6. Click on the policy, then select Edit Policy. Select JSON tab.

                        7. Add the following statement to the list of policy statements.

                          
                          {
                            "Sid": "LambdaGetConfiguration",
                            "Effect": "Allow",
                            "Action": [
                                "lambda:GetFunctionConfiguration"
                            ],
                            "Resource": [
                                "arn:aws:lambda:*:*:function:*"
                            ]
                          }
                          
                        8. Click Review Policy, then Save Changes. Wait for the changes to save.

                        Upgrading Log Forwarder Lambda

                        • Publish Log Forwarder Lambda Version

                          Publishing a version of the Log Forwarder Lambda allows to roll-back to pre-existing version if upgrade fails

                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                          2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                          3. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                            Log Forwarder Lambda version number for roll-backs: ___________________

                        • Disable Kinesis Trigger

                          Disabling Kinesis trigger ensures there are no unprocessed or re-processed events while function is upgraded.

                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                          2. Select Configuration tab > Triggers
                          3. Check Kinesis trigger and click Edit button
                          4. Uncheck Activate trigger and click Save
                          5. Wait for function to stop processing events by monitoring function in Monitor tab
                        • Upgrade Forwarder Lambda Version

                          Upgrade Log Forwarder function with new code

                          1. Go to AWS Cloud Formation and select existing Protegrity Log Forwarder deployment stack.
                          2. Select Update Stack > Make a direct update.
                          3. Select Replace existing template > Upload a template file.
                          4. Upload pty_log_forwarder_cf file and select Next.
                          5. Click Next until Review window and then select Update stack.
                          6. Wait for the Cloud Formation to complete.
                        • Enable Kinesis Trigger

                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                          2. Select Configuration tab > Triggers
                          3. Check Kinesis trigger and click Edit button
                          4. Check Activate trigger and click Save Log Forwarder function will now start processing events from where it left off when Kinesis trigger was disabled.
                        • Monitor and roll-back

                          Monitor Log Forwarder function for errors in its CloudWatch logs and in Montior tab. To roll back function to the previous version if any errors occur follow these steps:

                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                          2. Select Configuration tab > Triggers

                          3. Expand Details section of Kinesis trigger and record UUID value

                          4. Execute the following AWS CLI command to move Kinesis trigger to previous version of Log Forwarder Lambda that was created earlier and recorded as Log Forwarder Lambda version number for roll-backs. Substitute kinesis-mapping-uuid, log-forwarder-function-name, version-for-roll-backs with your values:

                            
                            aws lambda update-event-source-mapping --uuid <kinesis-mapping-uuid> --function-name <log-forwarder-function-name>:<version-for-roll-backs>
                            
                          5. Find Kinesis trigger attached to previous version of Log Forwarder Lambda by navigating Versions tab > Version number link in the Versions column Kinesis trigger is now moved to previous version of Log Forwarder Lambda function.

                        Upgrading Protect Lambda

                        Diagram below illustrates upgrade steps.

                        Snowflake Function Upgrade Steps

                        Redshift Function Upgrade Steps

                        Cloud API Function Upgrade Steps

                        Athena Function Upgrade Steps

                        • Publish Protect Lambda Version

                          Publishing a version of the Protect Lambda allows updating it without interruptions to the existing traffic.

                          1. Go to AWS Lambda console and select existing Protegrity Protect Lambda.

                          2. Go to Lambda Configuration > Environment variables.

                          3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                            aws lambda get-function-configuration --function-name \
                            arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                            --query Environment > <function_name>_env_config.json
                            
                          4. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                          5. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                            Protect Lambda version number: ___________________

                          6. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                            CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                RETURNS varchar
                                VOLATILE lambda
                                'Protegrity_Protect_test:<protect_lambda_version_number>' iam_role
                                'arn:aws:iam::123456789212:role/example_role';
                            
                        • Run protect service upgrade

                          In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                          1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                          2. Select Update. Check Replace current template > Upload a template file.

                          3. Upload pty_protect_cf.json file and select Next.

                          4. Update ProtectFunctionProductionVersion parameter with Protect Lambda version number recorded in step 3.

                          5. Click Next until Review window and then select Update stack.

                          6. Wait for the Cloud Formation to complete.

                          7. Go back to Lambda console and select Protect Lambda.

                          8. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                            aws lambda update-function-configuration --function-name \
                            arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                            --environment file://./<function_name>_env_config.json
                            
                          9. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                          10. The upgraded Protect Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.

                        • Finalize upgrade

                          In this step, the Protect Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                          1. Go back to Protegrity AWS Cloud Formation deployment stack.

                          2. Select Update. Check Use Current template.

                          3. Update ProtectFunctionProductionVersion parameter with the following value: $LATEST.

                          4. Click Next until Review window and then select Update stack.

                          5. Go back to Lambda console and select Protect Lambda.

                          6. From the Lambda console, verify that Latest alias points to $LATEST version.

                          7. Test your function to make sure it works as expected.

                          8. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                            CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                RETURNS varchar
                                VOLATILE lambda
                                'Protegrity_Protect_test:Production' iam_role
                                'arn:aws:iam::123456789212:role/example_role';
                            
                          9. If you need to rollback to older version of Protect Lambda, you can re-run the cloud formation with ProtectFunctionProductionVersion parameter set to the previous version of Protect Lambda.

                        Re-enable Protegrity Agent Function CloudWatch Event Rule

                        If the Event Rule was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to re-enable Policy Agent Event rule.

                        1. Go to the Protegrity Agent Cloud Formation Stack.

                        2. Select Resources tab from the top portion of the screen.

                        3. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                        4. Select Enable from the top-right portion of the screen. This will enable the rule. You will re-enable it after the upgrade process is complete.

                        1.1.10 - Appendices

                        Additional references for the protector.

                        1.1.10.1 - ADFS Federation using AWS Cognito User Pools

                        Reference for integrating ADFS with API Gateway

                        ADFS Federation using AWS Cognito User Pools

                        Common use case for Protegrity Policy Member source integrates with customer’s Active Directory. The AWS API Gateway can integrate with ADFS using AWS Cognito. The following article describes the procedure.

                        https://aws.amazon.com/blogs/mobile/building-adfs-federation-for-your-web-app-using-amazon-cognito-user-pools/

                        1.1.10.2 - Installing the Policy Agent and Protector in Different AWS Accounts

                        Example steps to install Agent in a different AWS account than the Protector

                          The Policy Agent Lambda function and Protect Lambda functions can be installed in separate AWS accounts. However, additional configuration is required to authorize the Policy Agent to provision the security policy to a remote Protect Lambda function.

                          Create Agent Lambda IAM policy

                          1. Login to the AWS account that hosts the Protect Lambda function.

                          2. From the AWS IAM console, select Policies > Create Policy.

                          3. Select the JSON tab and copy the following snippet.

                            {
                              "Version": "2012-10-17",
                              "Statement": [
                                {
                                  "Sid": "LambdaUpdateFunction",
                                  "Effect": "Allow",
                                  "Action": [
                                    "lambda:UpdateFunctionConfiguration"
                                  ],
                                  "Resource": [
                                    "arn:aws:lambda:*:*:function:*"
                                  ]
                                },
                                {
                                  "Sid": "LambdaReadLayerVersion",
                                  "Effect": "Allow",
                                  "Action": [
                                    "lambda:GetLayerVersion",
                                    "lambda:ListLayerVersions"
                                  ],
                                  "Resource": "*"
                                },
                                {
                                  "Sid": "LambdaDeleteLayerVersion",
                                  "Effect": "Allow",
                                  "Action": "lambda:DeleteLayerVersion",
                                  "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                },
                                {
                                  "Sid": "LambdaPublishLayerVersion",
                                  "Effect": "Allow",
                                  "Action": "lambda:PublishLayerVersion",
                                  "Resource": "arn:aws:lambda:*:*:layer:*"
                                },
                                {
                                  "Sid": "S3GetObject",
                                  "Effect": "Allow",
                                  "Action": [
                                    "s3:GetObject"
                                  ],
                                  "Resource": "arn:aws:s3:::*/*"
                                },
                                {
                                  "Sid": "S3PutObject",
                                  "Effect": "Allow",
                                  "Action": [
                                    "s3:PutObject"
                                  ],
                                  "Resource": "arn:aws:s3:::*/*"
                                },
                                {
                                  "Sid": "LambdaGetConfiguration",
                                  "Effect": "Allow",
                                  "Action": [
                                      "lambda:GetFunctionConfiguration"
                                  ],
                                  "Resource": [
                                      "arn:aws:lambda:*:*:function:*"
                                  ]
                                }
                              ]
                            }
                            
                          4. Replace the wildcards (*) with the region, account, and resource name information where required.

                          5. Select Review policy, type in the policy name, and confirm. Record policy name:

                            Agent Lambda Cross Account Policy Name: ___________________

                          Create Policy Agent cross-account IAM Role

                          1. Login to the AWS account that hosts the Protect Lambda function.

                          2. From the AWS IAM console, select Roles > Create Role

                          3. Select AWS Service > Lambda . Proceed to Permissions.

                          4. Select Policy created in the step above. Proceed to Tags.

                          5. Specify Tag, proceed to the final screen. Type in policy name and confirm. Record the name.

                            Policy Agent Cross Account IAM Role Name: ___________________

                          Allow the Policy Agent Cross-Account Role to be Assumed by the Policy Agent IAM Role

                          1. Login to the AWS account that hosts the Protect Lambda function.

                          2. Navigate to the previously created IAM Role (Agent Lambda Cross-Account IAM Role Name).

                          3. Navigate to Trust Relationships > Edit Trust Relationships.

                          4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda IAM Execution Role ARN> with ARN of Agent Lambda IAM Role that was created in Agent Installation.

                            {
                              "Version": "2012-10-17",
                              "Statement": [
                                {
                                  "Effect": "Allow",
                            
                               "Principal": {
                            
                                        "AWS": "<Agent Lambda IAM Execution Role Name>"
                            
                                  },
                                  "Action": "sts:AssumeRole"
                                }
                              ]
                            }
                            
                          5. Click Update Trust Policy.

                          Add Assume Role to the Policy Agent Execution IAM Role

                          1. Login to the AWS account that hosts the Policy Agent.

                          2. Navigate to the Agent Lambda IAM Execution Role that was created in Agent Installation.

                            {
                              "Version": "2012-10-17",
                              "Statement": [
                                {
                                  "Effect": "Allow",
                            
                               "Principal": {
                            
                                        "AWS": "<Agent Lambda IAM Execution Role Name>"
                            
                                  },
                                  "Action": "sts:AssumeRole"
                                }
                              ]
                            }
                            
                          3. Add Inline Policy.

                          4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda Cross-Account IAM ARN> with the value recorded in Create Policy Agent cross-account IAM Role.

                            {
                              "Version": "2012-10-17",
                              "Statement": [
                                {
                                  "Effect": "Allow",
                                  "Action": [
                                    "sts:AssumeRole"
                                  ],
                                  "Resource": "<Agent Lambda Cross-Account IAM  ARN>."
                                }
                              ]
                            }
                            
                          5. When you are finished, choose Review Policy.

                          6. On the Review policy page, type a Name, then choose Create Policy.

                          Update the Policy Agent Lambda Configuration

                          1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                          2. Select Configuration tab | Environment variables.

                          3. Select Edit and add the following environment variables with the value from Agent Lambda Cross-Account IAM ARN:

                            ParameterValue
                            AWS_ASSUME_ROLEAgent Lambda Cross-Account IAM ARN
                          4. Ensure the values in the Parameters AWS_POLICY_S3_BUCKET, AWS_PROTECT_FN_NAME and AWS_POLICY_LAYER_NAME are all in the Protect Lambda Function AWS Account.

                          5. In case custom VPC hostname configuration is used, you will need to set the ENDPOINT_URL. Refer to Policy Agent - Custom VPC Endpoint Hostname Configuration.

                            AWS_VPC_ENDPOINT_URL

                            <AWS_VPC_ENDPOINT>

                          6. Click Save and Run the Lambda. The Lambda will now assume the Role in Protect Lambda Function AWS Account and update the policy cross accounts.

                          1.1.10.3 - 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.1.10.4 - Invoke Lambda Directly

                            Invoke protector lambda function directly (without API Gateway)

                            AWS Lambda can be invoked directly, such as from AWS SDK. This section contains information about request and response payloads with examples demonstrating direct invocation using AWS CLI and Python SDK (Boto3).

                            Request Payload

                            Lambda request payload for the direct invocation is defined as following

                            {
                              "body": "<rest-api-request-payload>",
                              "path": "/v1/<operation>",
                              "headers": {}
                            }
                            
                            • body - JSON string. Request schemas defined in Rest API Request.
                            • path - can be either ‘/v1/protect’ or ‘/v1/unprotect’.
                            • headers - can be used to pass authorization headers. See example below.

                            Example request:

                            {
                              "body": "{\"query_id\": \"3\",\"user\": \"user1\",\"data_element\": \"deAlpha\",\"data\": [\"data1\", \"data2\"]}",
                              "path": "/v1/protect",
                              "headers": {}
                            }
                            

                            Example Request with JWT authorization:

                            {
                              "body": "{\"query_id\": \"3\",\"user\": \"user1\",\"data_element\": \"deAlpha\",\"data\": [\"data1\", \"data2\"]}",
                              "path": "/v1/protect",
                              "headers": {
                                "authorization": "bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2MTM4NjIzNzEsImlkIjoiYS1iLWMtZC1lLWYtMS0yLTMiLCJ1c2VybmFtZSI6IlBhdWwgQXRyZWlkZXMifQ.R1NcJ43540HKdhEBOK9WaMMpjBOYSJetckQKrcPQdz0z6sx1EDwHXYngBP9DtHgUM-6Vf1VNjtFh_Nqfeepp1BavmigIXoe3ZbrxRI3DFKi2UuLmgn--EYrSGlWsQjnmjaz5qUkID9iY2MtsRunKSuolSvG9UsD1G32kv0KZYX0"
                              }
                            }
                            

                            Response Payload

                            Lambda response payload has the following structure

                            {
                              "body": "<rest-api-response-payload>"
                              "isBase64Encoded": false,
                              "statusCode": <http-status-code>,
                            }
                            
                            • body - JSON string. Response schemas defined in Rest API Response.
                            • isBase64Encoded - always set to false.
                            • statusCode - HTTP status code integer.

                            Success Response Payload Example:

                            {
                              "body": "{\"encoding\":\"utf8\",\"results\":[\"xcgd\", \"migs\"],\"success\":true}", 
                              "isBase64Encoded": false, 
                              "statusCode": 200
                            }
                            

                            Error Response

                            Cloud API Lambda returns following error responses depending on the error type

                            Cloud API Protection Operation Error
                                  Returned when invalid data element is used or user has insufficient permissions to execute security operation.

                            {
                              "body": "{\"error_msg\":\"Unprotect failed. Data element not found. Refer to audit log for details.\",\"success\":false}", 
                              "isBase64Encoded": false, 
                              "statusCode": 400
                            }
                            

                            Cloud API Invalid Request Error
                                  Missing fields in the incoming request or malformed request JSON.

                            {
                              "body": "Request format is not supported", 
                              "isBase64Encoded": false, 
                              "statusCode": 400
                            }
                            

                            Cloud API Unexpected Lambda Exception Error
                                  Caused by Lambda runtime exception, for instance due to too short timeout or not enough memory.

                            {
                              "errorMessage": "2023-01-18T16:42:19.593Z d0cf62d0-9eaf-427b-8ca5-1bdd8bd0b082 Task timed out after 10.25 seconds"
                            }
                            

                            Examples

                            Prerequisites:

                            • AWS SDK or Command Line
                            • AWS Access Key ID and AWS Access Key

                            See Request Payload for request payload examples.

                            AWS CLI command to invoke Cloud API Lambda function:

                            aws lambda invoke --function-name Protegrity_Protect_RESTAPI_{stackname} --payload
                                fileb://request_payload.json --log-type Tail output
                            

                                
                              

                            Sample Python code demonstrating Cloud API Direct Lambda Calls

                            import json
                            import logging
                            import boto3
                            lambda_client = boto3.client("lambda")
                            logging.basicConfig(format="%(message)s")
                            logger = logging.getLogger('pty_cloud_api_sample')
                            logger.setLevel(logging.DEBUG)
                            
                            
                            class ProtectClient(object):
                              """ 
                                Sample client demonstrating how to invoke Protegrity Cloud API Lambda
                            
                                  protect_fn: str - Name of the Cloud API Lambda (for example, Protegrity_Protect_RESTAPI_my_deployment)
                              """
                            
                              def __init__(self, protect_fn):
                                self.protect_fn = protect_fn
                            
                              def invoke_protect(self, values, data_element, operation, user, query_id,
                                          column_info=""):
                                """ 
                                Invokes Protegrity Cloud API Lambda to execute protect or unprotect operation
                            
                                  values: list[str] - List of values to be protected/unprotected
                                  data_element: str - Name of the policy data element to use with protect/unprotect operation
                                  operation: str - Either 'protect' or 'unprotect'
                                  user: str - Policy user
                                  query_id: str - Query id will be present in the audit log
                                  column_info: - Used for troubleshooting, for instance, when protecting values/rows from multiple database columns
                                """
                            
                                # Set authorization header here if JWT authorization is 
                                # enabled in Cloud API Function configuration
                                headers = {"Authorization": ""}
                                request_body = {
                                  "user": user,
                                  "data_element": data_element,
                                  "data": values,
                                  "query_id": query_id
                                }
                                payload = json.dumps({"body": json.dumps(request_body), "path": f"/v1/{operation}",
                                              "headers": headers})
                                logger.debug(f"Request payload: {payload}")
                                response = lambda_client.invoke(FunctionName=self.protect_fn, Payload=payload)
                                lambda_response_payload = json.loads(response["Payload"].read().decode())
                                logger.debug(f"Response payload: {lambda_response_payload}")
                                response_status_code = lambda_response_payload.get("statusCode")
                                response_body_string = lambda_response_payload.get("body")
                                if response_status_code == None or response_body_string == None:
                                  raise Exception(f"Unexpected Cloud API Lambda error: [{lambda_response_payload}]")
                                try:
                                  body_json = json.loads(response_body_string)
                                  if response_status_code == 200:
                                    return body_json.get("results", [])
                                  elif body_json.get("error_msg"):
                                    raise Exception(f"Cloud API Lambda error: [{response_status_code} - {body_json.get('error_msg')}]")
                                  raise Exception(f"Unexpected Cloud API Lambda error: [{lambda_response_payload}]")
                                except json.decoder.JSONDecodeError:
                                  # Cloud API may return error in the response body
                                  # For example, {"statusCode": 400, "body":"Error message"}
                                  raise Exception(f"Cloud API Lambda error: [{response_status_code} - {response_body_string}]")
                            
                            # Replace cloud-api-lambda-name with the name of the Cloud API Lambda
                            # For example, Protegrity_Protect_RESTAPI_my_deployment
                            protect_client = ProtectClient('cloud-api-lambda-name')
                            protected_data = ["UtfVk UHgcD!"]
                            logger.info(f"Protected data: {protected_data}")
                            unprotected_data = protect_client.invoke_protect(
                              values=protected_data, 
                              data_element='alpha', 
                              operation='unprrotect', 
                              user='test-user', 
                              query_id='1234')
                            logger.info(f"Unprotected data: {unprotected_data}")
                            

                            1.1.10.5 - Policy Agent - Custom VPC Endpoint Hostname Configuration

                            Custom vpc endpoint hostname configuration

                            The Policy Agent uses default endpoint hostnames to communicate with other AWS services (for example, secretsmanager.amazonaws.com). This configuration will only work in VPCs where Amazon-provided DNS is available (default VPC configuration with private DNS option enabled for the endpoint). If your VPC uses custom DNS, follow the instructions below to configure the Policy Agent Lambda to use custom endpoint hostnames.

                            Identify DNS Hostnames

                            To identify DNS hostnames:

                            1. From AWS console, select VPC > Endpoints.

                            2. Select Secrets Manager endpoint from the list of endpoints.

                            3. Under Details > DNS Names, note the private endpoint DNS names adding https:// at the beginning of the endpoint name.

                              For example, https://vpce-1234-4pzomrye.kms.us-west-1.vpce.amazonaws.com

                            4. Note down DNS names for the KMS and Lambda endpoints:

                              AWS_SECRETSMANAGER_ENDPOINT: https://_________________

                              AWS_KMS_ENDPOINT: https://_________________

                              AWS_LAMBDA_ENDPOINT: https://_________________

                            Update the Policy Agent Lambda configuration

                            To update policy agent lambda configuration:

                            1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                            2. Select the Configuration section and choose Environment variables.

                            3. Select Edit and add the following environment variables with the corresponding endpoint URLs recorded in steps 3-4:

                              ParametersValue
                              AWS_SECRETSMANAGER_ENDPOINT_URL<AWS_SECRETS_ENDPOINT>
                              AWS_KMS_ENDPOINT_URL<AWS KMS ENDPOINT>
                              AWS_LAMBDA_ENDPOINT_URL<AWS LAMBDA ENDPOINT>
                            4. Click Save and Run the Lambda. The Lambda will now use endpoints you have just configured.

                            1.1.10.6 - 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.1.10.7 - Configuring Regular Expression to Extract Policy Username

                            Extract the policy username from the AWS identity.

                            Configuring Regular Expression to Extract Policy Username

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

                            • USERNAME_REGEX Lambda Environment configuration

                              The USERNAME_REGEX configuration can be used to extract policy username from user in the request. The following are allowed values for USERNAME_REGEX:

                              • 1 - Default build-in regular expression is used:

                                ^arn:aws:(?:iam|sts)::[0-9]{12}:(?:role|user|group|assumed\-role|federated\-user)\/([\w\/+=,.\-]{1,1024}|[\w\/+=,.\-@]{1,1024})(?:@[a-zA-Z0-9\-]{1,320}(?:\.\w+)+)?$
                                
                              • ^User regex$ - Custom regex 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

                            arn:aws:iam::123456789012:user/juliet.snow

                            arn:aws:iam::123456789012:user/juliet.snow

                            arn:aws:sts::123456789012:assumed-role/TestSaml

                            arn:aws:sts::123456789012:assumed-role/TestSaml

                            1

                            arn:aws:iam::123456789012:user/juliet.snow

                            juliet.snow

                            arn:aws:sts::123456789012:assumed-role/TestSaml

                            TestSaml

                            ^arn:aws:(?:iam|sts)::[0-9]{12}:((?:role|user|group|assumed-role|federated-user).*)$
                            

                            arn:aws:iam::123456789012:user/juliet.snow

                            user/juliet.snow

                            arn:aws:sts::123456789012:assumed-role/TestSaml

                            assumed-role/TestSaml

                            1.1.10.8 - Associating ESA Data Store With Cloud Protect Agent

                            Configure ESA data store for Policy Agent.

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

                            The Lambda service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range of the VPC subnet the Lambda is associated with. By default, when agent lambda is contacting ESA to register node for policy download, ESA uses agent Lambda VPC 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 lambda, 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 VPC subnet IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent lambda config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                            169.254.144.8110.1.2.173No Proxytrueyes169.254.144.81
                            trueno10.1.2.173
                            falseyes
                            falseno
                            169.254.144.8110.1.2.17334.230.42.110trueyes169.254.144.81
                            trueno34.230.42.110
                            falseyes
                            falseno

                            1.2 - Athena

                            Protector with Athena on AWS.

                            This section describes the high-level architecture of Athena, installation procedures, and performance guidance. This section focuses on Protegrity specific aspects and should be consumed in conjunction with the corresponding AWS 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.2.1 - Overview

                            Solution overview and features.

                              Solution Overview

                              Athena Protector on AWS is a cloud native, serverless product for fine-grained data protection with Amazon Athena. It enables invocation of Protegrity data protection operations from Amazon Athena SQL.

                              The product provides data protection services invoked by External User Defined Functions (UDFs) within Amazon Athena. The UDFs act as a client transmitting micro-batches of data to a remote Protegrity Athena Protector. The protector runs inside a serverless AWS Lambda function. User queries from Amazon Athena may generate hundreds or thousands of parallel requests to perform security operations. Protegrity’s serverless solution is designed to scale and yield reliable query performance under such load.

                              The Amazon Athena Protector utilizes a data security policy from an Enterprise Security Administrator (ESA), similar to other Protegrity products.

                              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 Athena Protector on AWS service.

                              Features

                              Athena Protector on AWS 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.2 - Architecture

                              Deployment architecture and Athena connectivity.

                                Deployment Architecture

                                The Amazon Athena Protector should be deployed in the customer’s AWS account. The product incorporates Protegrity’s vaultless tokenizationengine within an AWS Lambda Function. The data security policy from an ESA is provisioned periodically as a static, encrypted resource through an AWS Lambda Layer. The policy is decrypted in memory at runtime within the Lambda. This architecture allows Protegrity to be highly available and scale very quickly without direct dependency on other Protegrity services.

                                The product exposes a remote data protection service invoked from external User Defined Functions (UDFs), a native feature of Amazon Athena.The UDFs is invoked by users through SQL queries. The Amazon Athena execution engine makes remote calls to the Protegrity product to perform protect and unprotect data operations. Each network request includes a micro-batch of data to process and a secure payload including the federated user (if available) and the data element type. The product applies the ESA security policy including user authorization and returns a corresponding response.

                                When used with an Enterprise Security Administrator (ESA) application, 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 additional envelope encryption using Amazon KMS, and deploys the policy into the Lambda Layer used by the serverless product. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. The policy takes effect immediately for all new requests. There is no downtime for users during this process.

                                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 to an Enterprise Security Administrator (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 Guide.

                                Log Forwarding Architecture

                                Audit logs are by default sent to CloudWatch as long as the function’s execution role has the necessary permissions. 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 Amazon Kinesis data stream and the forwarder Lambda function. Amazon Kinesis stream is used to batch audit records before sending them 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 Amazon Kinesis. Due to specifics of the Lambda runtime lifecycle, audit logs may take up to 15 minutes before being sent to Amazon Kinesis. Protector function exposes configuration to minimize this time 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 Amazon Kinesis 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 client certificate to authenticate calls to ESA.

                                To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instructions can be found in 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.

                                Athena Connectivity

                                Amazon Athena is an interactive, serverless query service that makes it easy to analyze data in Amazo n S3 using standard SQL. Athena is serverless, so there is no infrastructure to manage, and you pay only for the queries that you run.

                                Athena’s external UDF makes remote invocations to the Protegrity protector, a serverless Lambda function incorporating Protegrity libraries and the Athena Query Federation SDK.

                                Access and authorization between various AWS services involved in this architecture is achieved throu gh Identity Access Management (IAM). For instance, the IAM principal running the query must be allowed to invoke the protect Lambda. Various IAM role configuration settings are shown in the appen dices of this document.

                                The following figure illustrates the Protegrity Athena Integration architecture.

                                1.2.3 - Installation

                                Instructions for installing Protect Service, Policy Agent, and Log Forwarder.

                                1.2.3.1 - Prerequisites

                                Requirements before installing the protector.

                                  AWS Service Dependencies

                                  The following table describes the AWS services that may be a part of your Protegrity installation.

                                  Service

                                  Description

                                  Lambda

                                  Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                  KMS

                                  Provides secrets for envelope policy encryption/decryption for Protegrity.

                                  Secrets Manager

                                  Provides secrets management for the ESA credentials.

                                  S3

                                  Intermediate storage location for the encrypted ESA policy layer.

                                  Kinesis

                                  Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                  VPC & NAT Gateway

                                  Optional. Provides a private subnet to communicate with an on-prem ESA.

                                  CloudWatch

                                  Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                  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 VPC must be able to obtain network access to the ESA
                                  AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                  Athena Engine Version 3Only Athena engine version 3 is supported. The product may work in Athena engine version 2, but it is deprecated and all users are encouraged to upgrade.

                                  Required Skills and Abilities

                                  Role / Skillset

                                  Description

                                  AWS Account Administrator

                                  To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

                                  Protegrity Administrator

                                  The ESA credentials required to extract the policy for the Policy Agent

                                  Network Administrator

                                  To open firewall to access ESA and evaluate AWS network setup

                                  What’s Next

                                  1.2.3.2 - Pre-Configuration

                                  Configuration steps before installing the protector.

                                    Provide AWS sub-account

                                    Identify or create an AWS account where the Protegrity solution will be installed. It is recommended that a new AWS sub-account be created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some subsequent installation steps.

                                    AWS Account ID: ___________________

                                    AWS Region (AwsRegion): ___________________

                                    Create S3 bucket for Installing Artifacts

                                    This S3 bucket will be used for the artifacts required by the CloudFormation installation steps. This S3 bucket must be created in the region that is defined in Determine AWS Region.

                                    To create S3 bucket for installing artifacts:

                                    1. Access the AWS S3 Management Console.

                                    2. Change region to the one determined in Determine AWS Region

                                    3. Click Create Bucket.

                                    4. Enter a unique bucket name:

                                      For example, protegrity-install.us-west-2.example.com.

                                    5. Click Create Bucket.

                                    6. Upload the installation artifacts to this bucket. Protegrity will provide the following three artifacts.

                                      • protegrity-athena-protect-udfs-<version>.jar
                                      • protegrity-agent-<version>.zip
                                      • protegrity-sample-policy-<version>.zip
                                      • protegrity-external-extension-<version>.zip

                                      S3 Bucket name (ArtifactS3Bucket): ___________________

                                    Create KMS Key

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

                                    To create KMS key:

                                    1. In the AWS sub-account where the KMS key will reside, select the region.

                                    2. Navigate to Key Management Service > Create Key.

                                    3. Configure the key settings:

                                      • Key type: Asymmetric
                                      • Key usage: Encrypt and decrypt
                                      • Key spec: RSA_4096
                                      • Click Next
                                    4. Create alias and optional description, such as, Protegrity-Serverless and click Next.

                                    5. Define key administrative permissions, the IAM user who will administrate the key.

                                    6. Click Next.

                                    7. Define the key usage permissions.

                                    8. In Other AWS accounts, enter the AWS account id used for the Protegrity Serverless installation.

                                    9. Continue on to create the key. If there is a concern this permission is overly broad, then you can return later to restrict access to the role of two Protegrity Serverless Lambda as principals. Click to open the key in the list and record the ARN.

                                      KMS Key ARN (AWS_KMS_KEY_ID): ___________________

                                    10. Download the public key from the KMS key. Navigate to the key in KMS console, select the Public key tab, and click Download. Save the PEM file. This public key will be added to the ESA data store as an export key. Refer to Exporting Keys to Datastore for instructions on adding the public key to the data store.

                                      KMS Public Key PEM file: ___________________

                                    What’s Next

                                    1.2.3.2.1 -

                                    Determine AWS Region

                                    Determine the AWS region where the Amazon Athena Workgroup is running. This is the region in where the Protegrity solution must be installed.

                                    AWS Region (AccountRegion): ___________________

                                    1.2.3.3 - Protect Service Installation

                                    Install the protect service.

                                      Protect Service Installation

                                      The following sections install the Cloud Protect serverless Lambda function.

                                      Preparation

                                      Ensure that all the steps in Pre-Configuration are performed.

                                      1. Login to the AWS account console where Protegrity Serverless will be installed.

                                      2. Ensure that the required CloudFormation templates provided by Protegrity are available on your local computer.

                                      Create Protect Lambda IAM Execution Policy

                                      This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

                                      Perform the following steps to create the Lambda execution role and required policies:

                                      1. From the AWS IAM console, select Policies > Create Policy.

                                      2. Select the JSON tab and copy the following sample policy.

                                        {
                                          "Version": "2012-10-17",
                                          "Statement": [
                                            {
                                              "Sid": "CloudWatchWriteLogs",
                                              "Effect": "Allow",
                                              "Action": [
                                                "logs:CreateLogGroup",
                                                "logs:CreateLogStream",
                                                "logs:PutLogEvents"
                                              ],
                                              "Resource": "*"
                                            },
                                            {
                                              "Sid": "KmsDecrypt",
                                              "Effect": "Allow",
                                              "Action": [
                                                "kms:Decrypt"
                                              ],
                                              "Resource": [
                                                "arn:aws:kms:*:*:key/*"
                                              ]
                                            }
                                          ]
                                        }
                                        
                                      3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                      4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

                                        ProtectLambdaPolicyName:__________________

                                      Create Protect Lambda IAM Role

                                      The following steps create the role to utilize the policy defined in Create Protect Lambda IAM Execution Policy.

                                      To create protect lambda IAM execution role:

                                      1. From the AWS IAM console, select Roles > Create Role.

                                      2. Select AWS Service > Lambda > Next.

                                      3. In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.

                                      4. Click Next

                                      5. Type the role name, for example, ProtegrityProtectRole

                                      6. Click Create role

                                      7. Record the role ARN.

                                        Role ARN (LambdaExecutionRoleArn): ___________________

                                      Install using CloudFormation

                                      The following steps describe the deployment of the Lambda function.

                                      • Access CloudFormation and select the target AWS Region in the console.

                                      • Click Create Stack and choose With new resources.

                                      • In Specify template section select Upload a template file.

                                      • Click Choose file to upload the Protegrity-provided CloudFormation template called pty_athena_protect_cf.json and click Next.

                                      • Specify stack details. Enter stack name.

                                      • Enter the required parameters. All the values were generated in the pre-configuration steps.

                                        Parameter

                                        Description

                                        ArtifactS3Bucket

                                        Name of S3 bucket created in the pre-configuration step

                                        LambdaExecutionRoleArn

                                        The ARN of Lambda role created in the prior step

                                        PolicyUser

                                        Name of the Policy User that will be passed as an environment variable to the lambda function. With protegrity-sample-policy-<version>.zip, you can set this value to policyuser.

                                        PolicyUserConfig

                                        The settings for POLICY_USER_CONFIG. Default Value: 0, Values: [0,1,2].

                                        UsernameRegex

                                        The settings for USERNAME_REGEX. Default Value: Not Set, Values: “1” or regex expression.

                                        MinLogLevel

                                        Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                                      • The log forwarder parameters can be provided later after log forwarder is deployed. If you are not planning to deploy log forwarder you can skip this step.

                                        Log Forwarder ParametersDescription
                                        KinesisLogStreamArnThe ARN of the AWS Kinesis stream where audit logs will be sent for aggregation
                                        AuditLogFlushIntervalTime interval used to accumulate audit logs before sending to Kinesis
                                      • Proceed to the last step of the Create Stack wizard with defaults and click Submit to create CloudFormation stack.

                                      • After CloudFormation is completed, select the Outputs tab in the stack. Record the following values:

                                        ProtectFunctionName: __________________________

                                        ProtectFunctionProductionAlias: __________________________

                                        ProtectLayerName: _____________________________

                                      Test Connectivity

                                      Perform the following steps to verify Athena is working correctly with Protegrity.

                                      • Access the Athena console.

                                      • Copy and paste the following snippet into a worksheet.

                                        USING EXTERNAL FUNCTION unprotect(val varchar, el varchar) RETURNS varchar 
                                             LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                        SELECT unprotect('UtfVk UHgcD!', 'alpha')
                                        
                                      • Replace the placeholder value with the lambda function name

                                      • Run the above Query

                                      • Verify that the string hello world! is returned.

                                      Troubleshooting Tips

                                      Error

                                      Action

                                      User: <USER_ARN> is not authorized to perform: glue:GetDatabases on resource: arn:aws:glue:<AWS_REGION>:<AWS_ACCOUNT>:catalog (Service: AmazonDataCatalog; Status Code: 400; Error Code: AccessDeniedException; Request ID: <REQUEST_ID>; Proxy: null)

                                      Verify user has Glue permission GetDatabases

                                      User: <USER_ARN> is not authorized to perform: glue:GetTables on resource: arn:aws:glue: <AWS_REGION>:<AWS_ACCOUNT>:catalog (Service: AmazonDataCatalog; Status Code: 400; Error Code: AccessDeniedException; Request ID: <REQUEST_ID>; Proxy: null)

                                      Verify user has Glue permission GetTables

                                      Insufficient permissions to execute the query

                                      Verify user has InvokeFunction permission for the protect lambda function

                                      Access denied when writing output to url: s3://<BUCKET_NAME>/Unsaved/<YEAR>/<MONTH>/<DAY>/<QUERY_ID>.csv Please ensure you are allowed to access the S3 bucket. If you are encrypting query results with KMS key, please ensure you are allowed to access your KMS key

                                      Verify user has S3 permission PutObject for the query result location bucket. If using KMS encryption, verify the required KMS permissions.

                                      You do not seem to have access to the S3 location of your query results. Please confirm your account has access to the S3 location where your query results are saved and try again. If you are using KMS to encrypt query results, please ensure you have permission to access your KMS key.

                                      Verify user has S3 permission GetObject for the query result location bucket. If using KMS encryption, verify the required KMS decrypt permissions.

                                      User: <USER_ARN>is not authorized to perform: athena:<ACTION> on resource: arn:aws:athena:<AWS_REGION>:<ACCOUNT>:workgroup/<WORKGROUP> (Service: AmazonAthena; Status Code: 400; Error Code: AccessDeniedException; Request ID: <REQUEST_ID>; Proxy: null)

                                      Verify user has the permissions: StartQueryExecution GetQueryResults GetWorkGroup StopQueryExecution GetQueryExecution

                                      java.lang.RuntimeException: Failed to initialize MemoryUtil. Was Java started with `–add-opens=java.base/java.nio=ALL-UNNAMED`? (See https://arrow.apache.org/docs/java/install.html)

                                      Verify that the environment variable JAVA_TOOL_OPTIONS=--add-opens=java.base/java.nio=ALL-UNNAMED has been added to the protect function.

                                      What’s Next

                                      1.2.3.4 - Policy Agent Installation

                                      Install the policy agent.

                                        The following sections will install the Policy Agent. The Policy Agent polls the ESA and deploys the policy to Protegrity Serverless as a static resource. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity Professional Services for further guidance on configuration alternatives in the Cloud.

                                        ESA Server

                                        Policy Agent Lambda requires ESA server running and accessible on TCP port 443.

                                        Note down ESA IP address:

                                        ESA IP Address (EsaIpAddress): ___________________

                                        Certificates on ESA

                                        Whether your ESA is configured with default self-signed certificate or your corporate CA certificate, Policy Agent can validate authenticity of ESA connection using CA certificate. The process for both scenarios is the same:

                                        • Obtain CA certificate
                                        • Convert CA certificate to a value accepted by Policy Agent
                                        • Provide converted CA certificate value to Policy Agent

                                        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. To convert downloaded CA certificate to a value accepted by Policy Agent, open the downloaded 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 or PTY_ESA_CA_SERVER_CERT_SECRET Lambda variable in section Policy Agent Lambda Configuration

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

                                        Identify or Create a new VPC

                                        Establish a VPC where the Policy Agent will be hosted. This VPC will need connectivity to the ESA. The VPC should be in the same account and region established in Pre-Configuration.

                                        VPC name: ___________________

                                        VPC Subnet Configuration

                                        Identify or create a new subnet in the VPC where tha Lambda function will be connected to. It is recommended to use a private subnet.

                                        Subnet name: ___________________

                                        NAT Gateway For ESA Hosted Outside AWS Network

                                        If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                        VPC Endpoints Configuration

                                        If an internal VPC was created, then add VPC Endpoints, which will be used by the Policy Agent to access AWS services. Policy Agent needs access to the following AWS services:

                                        Type

                                        Service name

                                        Interface

                                        com.amazonaws.{REGION}.secretsmanager

                                        Interface

                                        com.amazonaws.{REGION}.kms

                                        Gateway

                                        com.amazonaws.{REGION}.s3

                                        Interface

                                        com.amazonaws.{REGION}.lambda

                                        Identify or Create Security Groups

                                        Policy Agent and cloud-based ESA appliance use AWS security groups to control traffic that is allowed to leave and reach them. Policy Agent runs on schedule and is mostly concerned with allowing traffic out of itself to ESA and AWS services it depends on. ESA runs most of the time and it must allow Policy Agent to connect to it.

                                        Policy Agent security group must allow outbound traffic using rules described in the table below. To edit security group navigate:

                                        From VPC > Security Groups > Policy Agent Security Group configuration.

                                        TypeProtocolPort RangeDestinationReason
                                        Custom TCPTCP443Policy Agent Lambda SGESA Communication
                                        HTTPSTCP443AnyAWS Services

                                        Record Policy Agent security group ID:

                                        Policy Agent Security Group Id: ___________________

                                        Policy Agent will reach out to ESA on port 443. Create following inbound security group rule for cloud-based ESA appliance to allow connections from Policy Agent:

                                        TypeProtocolPort RangeSource
                                        Custom TCPTCP443Policy Agent Lambda SG

                                        Creating ESA Credentials

                                        Policy Agent Lambda requires ESA credentials to be provided as one of the three options.

                                        Option 1: Secrets Manager

                                        Creating secrets manager secret with ESA username and password.

                                        1. From the AWS Secrets Manager Console, select Store New Secret.

                                        2. Select Other Type of Secrets.

                                        3. Specify the username and password key value pair.

                                        4. Select the encryption key or leave default AWS managed key.

                                        5. Specify the Secret Name and record it.

                                          ESA Credentials Secret Name: __________________

                                        Option 2: KMS Encrypted Password

                                        ESA password is encrypted with AWS KMS symmetric key.

                                        1. Create AWS KMS symmetric key which will be used to encrypt ESA password. See Create KMS Key for instructions on how to create KMS symmetric key using AWS console.

                                        2. Record KMS Key ARN.

                                          ESA PASSWORD KMS KEY ARN: __________________

                                        3. Run AWS CLI command to encrypt ESA password. Below you can find sample Linux aws cli command. Replace <key_arn> with KMS symmetric key ARN.

                                          aws kms encrypt --key-id <key_arn> --plaintext $(echo '<esa_password>' | base64 )
                                          
                                        4. Sample output.

                                          {
                                            "CiphertextBlob": "esa_encrypted_password",
                                            "KeyId": "arn:aws:kms:region:aws_account:key/key_id ",
                                            "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
                                          }
                                          
                                        5. Record ESA username and encrypted password.

                                          ESA USERNAME: __________________

                                          ESA ENCRYPTED PASSWORD: __________________

                                        Option 3: Custom AWS Lambda function

                                        With this option ESA username and password are returned by a custom AWS Lambda function. This method may be used to get the username and password from external vaults.

                                        1. Create AWS Lambda in any AWS supported runtime.

                                          1. There is no input needed.

                                          2. The Lambda function must return the following response schema.

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

                                            For example,

                                            example output: {"username": "admin", "password": "Password1234"}
                                            
                                          3. Sample AWS Lambda function in Python:

                                            import json
                                            
                                            def lambda_handler(event, context):
                                            
                                                return {"username": "admin", "password": "password1234"}
                                            
                                        2. Record the Lambda name:

                                          Custom AWS lambda for ESA credentials: _______________

                                        Create Agent Lambda IAM Policy

                                        Follow the steps below to create Lambda execution policies.

                                        Create Agent Lambda IAM policy

                                        1. From AWS IAM console, select Policies > Create Policy.

                                        2. Select JSON tab and copy the following snippet.

                                          {
                                            "Version": "2012-10-17",
                                            "Statement": [
                                              {
                                                "Sid": "EC2ModifyNetworkInterfaces",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "ec2:CreateNetworkInterface",
                                                  "ec2:DescribeNetworkInterfaces",
                                                  "ec2:DeleteNetworkInterface"
                                                ],
                                                "Resource": "*"
                                              },
                                              {
                                                "Sid": "CloudWatchWriteLogs",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "logs:CreateLogGroup",
                                                  "logs:CreateLogStream",
                                                  "logs:PutLogEvents"
                                                ],
                                                "Resource": "*"
                                              },
                                              {
                                                "Sid": "LambdaUpdateFunction",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "lambda:UpdateFunctionConfiguration"
                                                ],
                                                "Resource": [
                                                  "arn:aws:lambda:*:*:function:*"
                                                ]
                                              },
                                              {
                                                "Sid": "LambdaReadLayerVersion",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "lambda:GetLayerVersion",
                                                  "lambda:ListLayerVersions"
                                                ],
                                                "Resource": "*"
                                              },
                                              {
                                                "Sid": "LambdaDeleteLayerVersion",
                                                "Effect": "Allow",
                                                "Action": "lambda:DeleteLayerVersion",
                                                "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                              },
                                              {
                                                "Sid": "LambdaPublishLayerVersion",
                                                "Effect": "Allow",
                                                "Action": "lambda:PublishLayerVersion",
                                                "Resource": "arn:aws:lambda:*:*:layer:*"
                                              },
                                              {
                                                "Sid": "S3GetObject",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "s3:GetObject"
                                                ],
                                                "Resource": "arn:aws:s3:::*/*"
                                              },
                                              {
                                                "Sid": "S3PutObject",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "s3:PutObject"
                                                ],
                                                "Resource": "arn:aws:s3:::*/*"
                                              },
                                              {
                                                "Sid": "KmsEncrypt",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "kms:GetPublicKey"
                                                ],
                                                "Resource": [
                                                  "arn:aws:kms:*:*:key/*"
                                                ]
                                              },
                                              {
                                                "Sid": "SecretsManagerGetSecret",
                                                "Effect": "Allow",
                                                "Action": [
                                                  "secretsmanager:GetSecretValue"
                                                ],
                                                "Resource": [
                                                  "arn:aws:secretsmanager:*:*:secret:*"
                                                ]
                                              },
                                              {
                                                "Sid": "LambdaGetConfiguration",
                                                "Effect": "Allow",
                                                "Action": [
                                                    "lambda:GetFunctionConfiguration"
                                                ],
                                                "Resource": [
                                                    "arn:aws:lambda:*:*:function:*"
                                                ]
                                              }
                                            ]
                                          }
                                          
                                        3. Replace wildcard * with the region, account, and resource name information where required.

                                        4. This step is required if KMS is used to encrypt ESA password.

                                          Add policy entry below. Replace ESA PASSWORD KMS KEY ARN with the value recorded in Option 2: KMS Encrypted Password.

                                          
                                            {
                                              "Sid": "KmsDecryptEsaPassword",
                                              "Effect": "Allow",
                                              "Action": [
                                                "kms:Decrypt"
                                              ],
                                              "Resource": [
                                                "**ESA PASSWORD KMS KEY ARN**"
                                              ]
                                            }
                                          
                                        5. Select Next type in the policy name and Create Policy. Record policy name:

                                          Policy Name: ___________________

                                        Create Agent Lambda IAM Role

                                        Perform the following steps to create Agent Lambda execution IAM role.

                                        To create agent Lambda IAM role:

                                        1. From AWS IAM console, select Roles > Create Role.

                                        2. Select AWS Service > Lambda > Next.

                                        3. Select the policy created in Create Agent Lambda IAM policy.

                                        4. Proceed to Name, Review and Create.

                                        5. Type the role name, for example, ProtegrityAgentRole and click Confirm.

                                        6. Select Create role.

                                        7. Record the role ARN.

                                          Agent Lambda IAM Execution Role Name: ___________________

                                        Corporate Firewall Configuration

                                        If an on-premise firewall is used, then the firewall must allow access from the NAT Gateway to an ESA. The firewall must allow access from the NAT Gateway IP to ESA via port 443 and 443.

                                        CloudFormation Installation

                                        Create the Policy Agent in the VPC using the CloudFormation script provided by Protegrity.

                                        1. Access the CloudFormation service.

                                        2. Select the target installation region.

                                        3. Create a stack with new resources.

                                        4. Upload the Policy Agent CloudFormation template (file name: pty_agent_cf.json).

                                        5. Specify the following parameters for Cloud Formation:

                                          ParameterDescriptionNote
                                          VPCVPC where the Policy Agent will be hostedIdentify or Create a new VPC
                                          SubnetSubnet where the Policy Agent will be hostedVPC Subnet Configuration
                                          PolicyAgentSecurityGroupIdSecurity Group Id, which allows communication between the Policy Agent and the ESAIdentify or Create Security Groups
                                          LambdaExecutionRoleArnAgent Lambda IAM execution role ARN allowing access to the S3 bucket, KMS encryption Key, Lambda and Lambda LayerCreate Agent Lambda IAM Role
                                          ArtifactS3BucketS3 bucket name with deployment package for the Policy AgentUse S3 Bucket name recorded in Create S3 bucket for Installing Artifacts
                                          CreateCRONJobSet to True to create a CloudWatch schedule for the agent to run.Default: False

                                        Policy Agent Lambda Configuration

                                        After the CloudFormation stack is deployed, the Policy Agent Lambda must be configured with parameters recorded in earlier steps. From your AWS Console, navigate to lambda and select the following Lambda.

                                        Protegrity_Agent<STACK_NAME>_

                                        Select Configuration tab and scroll down to the Environment variables section. Select Editand replace all entries with the actual values.

                                        Parameter

                                        Description

                                        Notes

                                        PTY_ESA_IP

                                        ESA IP address or hostname

                                        ESA Server

                                        PTY_ESA_CA_SERVER_CERT

                                        ESA self-signed CA certificate or your corporate CA certificate used by policy Agent Lambda 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.

                                        PTY_ESA_CA_SERVER_CERT_SECRET

                                        This configuration option fulfills the same function as PTY_ESA_CA_SERVER_CERT but supports larger configuration values, making it the recommended choice. The value should specify the name of the AWS Secrets Manager secret containing the ESA self-signed CA certificate. The secret value should be set to the json with “PTY_ESA_CA_SERVER_CERT” key and PEM formated CA certificate content value as shown below.

                                        {
                                          "PTY_ESA_CA_SERVER_CERT":"-----BEGIN CERTIFICATE----- MIIF..."
                                        }
                                        

                                        Recorded in step Certificates on ESA

                                        In case ESA is configured with publicly signed certificates, the PTY_ESA_CA_SERVER_CERT_SECRET configuration will be ignored. When both PTY_ESA_CA_SERVER_CERT and PTY_ESA_CA_SERVER_CERT_SECRET are configured the PTY_ESA_CA_SERVER_CERT_SECRET takes precedence.

                                        PTY_ESA_CREDENTIALS_SECRET

                                        ESA username and password (encrypted value by AWS Secrets Manager)

                                        Option 1: Secrets Manager

                                        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.

                                        AWS_KMS_KEY_ID

                                        KMS key id or full ARN e.g. arn:aws:kms:us-west-2:112233445566:key/bfb6c4fb-509a-43ac-b0aa-82f1ca0b52d3

                                        Create KMS Key

                                        AWS_POLICY_S3_BUCKET

                                        S3 bucket where the encrypted policy will be written

                                        S3 bucket of your choice

                                        AWS_POLICY_S3_FILENAME

                                        Filename of the encrypted policy stored in S3 bucket

                                        Default: protegrity-policy.zip

                                        AWS_PROTECT_FN_NAME

                                        Comma separated list of Protect function names or ARNs

                                        ProtectFunctionName(s), recorded in CloudFormation Installation

                                        DISABLE_DEPLOY

                                        This flag can be either 1 or 0. If set to 1, then the agent will not update PTY_PROTECT lambda with the newest policy. Else, the policy will be saved in the S3 bucket and deployed to the Lambda Layer

                                        Default: 0

                                        AWS_POLICY_LAYER_NAME

                                        Lambda layer used to store the Protegrity policy used by the PTY_PROTECT function

                                         

                                        POLICY_LAYER_RETAIN

                                        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: 2

                                        POLICY_PULL_TIMEOUT

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

                                        Default: 20s

                                        ESA_CONNECTION_TIMEOUT

                                        Time in seconds to wait for the ESA response

                                        Default: 5s

                                        LOG_LEVEL

                                        Application and audit logs verbiage level

                                        Default: INFO

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

                                        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

                                        PTY_CORE_CASESENSITIVE

                                        Specifies whether policy usernames should be case sensitive

                                        Default: no

                                        Allowed values:

                                        yes

                                        no

                                        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_ESA_USERNAME

                                        Plaintext ESA username which is used together with PTY_ESA_ENCRYPTED_PASSWORD as an optional ESA credentials

                                        Option 2: KMS Encrypted Password

                                        Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                        PTY_ESA_ENCRYPTED_PASSWORD

                                        ESA password encrypted with KMS symmetric key.

                                        Example AWS cli command to generate the value:

                                        aws kms encrypt --key-id <your key ARN> --plaintext '<your-esa-password-base64>'

                                        Option 2: KMS Encrypted Password

                                        Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                        Value must be base64 encoded

                                        EMPTY_POLICY_S3

                                        This flag can be either 1 or 0. If set to 1, then the agent will remove the content of the policy file in S3 bucket, but will keep the checksum in the metadata. Else, the policy will be saved in the S3 bucket and not removed.

                                        Default: 0

                                        PTY_ESA_CREDENTIALS_LAMBDA

                                        Lambda function to return ESA credentials

                                        Recorded in step Option 3: Custom AWS Lambda function LAMBDA FOR ESA CREDENTIALS. Presence of PTY_ESA_USERNAME, or PTY_ESA_CREDENTIALS_SECRET will cause this value to be ignored.

                                        The Policy Agent Lambda must have network access and IAM permissions to invoke the custom ESA Credentials Lambda you have created in Option 3: Custom AWS Lambda function.

                                        Test Installation

                                        Open the Lambda and configure Test to execute the lambda and specify the default test event. Wait for around 20 seconds for the Lambda to complete. If policy is downloaded successfully, then a success message appears.

                                        Navigate to the AWS_POLICY_S3_BUCKET bucket and verify that the AWS_POLICY_S3_FILENAME file was created.

                                        Troubleshooting

                                        Lambda Error

                                        Example Error

                                        Action

                                        Task timed out after x seconds

                                        2020-10-06T23:40:54.121Z 2dc84942-b5cc-4be9-aa4c-965f322307e4 Task timed out after 90.09 seconds
                                        
                                        1. Ensure that there is network connectivity between the Lambda and ESA. Check the Security groups and/or Network firewall configuration
                                        2. When using internal VPC, AWS Lambda needs to have access to AWS Network. The Policy Agent Lambda can start using Secrets Manager with Amazon VPC endpoints by creating an Amazon VPC endpoint for Secrets Manager.

                                        ESA connection error. Failed to download certificates

                                        Policy Pull takes a long time

                                        {
                                          "errorMessage": "Timeout! Unable to download policy in 20 seconds.",
                                          "errorType": "Exception",
                                          "stackTrace": [...]
                                        }
                                        
                                        1. Increase POLICY_PULL_TIMEOUT.
                                        2. Ensure that there is at least 1 policy with datastore matching the Lambda Policy Agent. Other considerations:
                                          1. Policy has default datastore.
                                          2. Policy has datastores matching AWS lambda IP range (check the subnet IP Range).
                                          3. Lambda function has static IP, and at least one Data store has matching IP.

                                        ESA connection error. Failed to download certificates. HTTP response code: 401

                                        {
                                          "errorMessage": "ESA connection error. Failed to download certificates. HTTP response code: 401.",
                                          "errorType": "ConnectionError",
                                          "stackTrace": [...]
                                        }
                                        

                                        Ensure that the PTY_ESA_CREDENTIALS_SECRET has correct ESA username and password

                                        An error occurred (AccessDeniedException) when calling xyz operation

                                        xyz Access Denied: Exception
                                        Traceback (most recent call last):
                                          … Exception: xyz Access Denied
                                        

                                        Ensure that the Lambda execution role has permission to call the xyz operation

                                        Access Denied to Secret Manager.

                                        Secrets Manager Access Denied: Exception
                                        Traceback (most recent call last):
                                          … Exception: Secrets Manager Access Denied
                                        
                                        1. Ensure that the Lambda execution role has permissions to get the Secret Manager secret name.
                                        2. Ensure that the Lambda execution role has permission to get the Secret Manager secret Encryption Key.

                                        Master Key xyz unable to generate data key

                                        Ensure that the Lambda can access xyz CMK key

                                        The S3 bucket server-side encryption is enabled, the encryption key type is SSE-KMS but the Policy Agent execution IAM role doesn’t have permissions to encrypt using the KMS key .

                                        [ERROR] PolicyAgentException: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
                                        

                                        Add the following permissions to the Policy Agent excution role.

                                        kms:Decrypt
                                        kms:GenerateDatakey
                                        

                                        The S3 bucket has bucket policy to only allow access from within the VPC.

                                        An error occurred (AccessDeniedException) when calling the PublishLayerVersion operation: Your access has been denied by S3,
                                        please make sure your request credentials have permission to GetObject for BUCKET_NAME/FILENAME. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
                                        

                                        The Policy Agent publishes a new Lambda Layer version, and the Lambda Layer service uploads the policy file from the s3 bucket and the upload request is originated from the AWS service outside the Policy Agent Lambda VPC. Update the S3 bucket resource policy to allow access from AWS Service. Sample security policy to lock down access to the vpc:

                                        {
                                          "Version": "2012-10-17",
                                          "Statement": [
                                            {
                                              "Sid": "VpcRestrictions",
                                              "Effect": "Deny",
                                              "Principal": {
                                                "AWS": "*"
                                              },
                                              "Action": "s3:*Object",
                                              "Resource": [
                                                "arn:aws:s3:::<s3_bucket_name>/*",
                                                "arn:aws:s3:::<s3_bucket_name>"
                                              ],
                                              "Condition": {
                                                "Bool": {
                                                  "aws:ViaAWSService": "false"
                                                },
                                                "StringNotEquals": {
                                                  "aws:sourceVpc": "<vpc_id>"
                                                }
                                              }
                                            }
                                          ]
                                        }
                                        

                                        Additional Configuration

                                        Strengthen the KMS IAM policy by granting access only to the required Lambda function(s).

                                        Finalize the IAM policy for the Lambda Execution Role. Ensure to replace wildcard * with the region, account, and resource name information where required.

                                        For example,

                                        "arn:aws:lambda:*:*:function:*" -> "arn:aws:lambda:us-east-1:account:function:function_name"
                                        

                                        Policy Agent Schedule

                                        If specified in CloudFormation Installation, the agent installation created a CloudWatch event rule, which checks for policy update on an hourly schedule. This schedule can be altered to the required frequency.

                                        Under CloudWatch > Events > Rules, find Protegrity_Agent_{stack_name}. Click Action > Edit Set the cron expression. A cron expression can easily be defined using CronMaker, a free online tool. Refer to http://www.cronmaker.com.

                                        What’s Next

                                        1.2.3.5 - Audit Log Forwarder Installation

                                        Install the audit log forwarder.

                                          The following sections show steps how to install Audit Log Forwarder component in the AWS Cloud. The Log Forwarder deployment allows for the audit logs generated by Protector to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protector Service to work properly. See Log Forwarding Architecture section in this document for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. C ontact Protegrity for further guidance on configuration alternatives in the Cloud.

                                          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 (Audit Store) or 24284 (td-agent).

                                          2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                          3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                          Certificates on ESA

                                          By default, ESA is configured with self-signed certificates, which can optionally be validated using a self-signed CA certificate supplied in the Log Forwarder configuration. If no CA certificate is provided, the Log Forwarder will skip server certificate validation.

                                          If ESA is configured with publicly signed certificates, this section can be skipped since the forwarder Lambda will use the public CA to validate ESA certificates.

                                          To obtain the 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 PtyEsaCaServerCert cloudformation parameter in section Install through CloudFormation

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

                                          AWS VPC Configuration

                                          Log forwarder Lambda function requires network connectivity to ESA, similar to Policy Agent Lambda function. Therefore, it can be hosted in the same VPC as Policy Agent.

                                          Separate VPC can be used, as long as it provides network connectivity to ESA.

                                          VPC Name: ___________________

                                          VPC Subnet Configuration

                                          Log Forwarder can be connected to the same subnet as Policy Agent or separate one as long as it provides connectivity to ESA.

                                          Subnet Name: ___________________

                                          NAT Gateway For ESA Hosted Outside AWS Network

                                          If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                          VPC Endpoint Configuration

                                          Log Forwarder Lambda function requires connectivity to Secrets Manager AWS service. If the VPC identified in the steps before has no connectivity to public internet through the NAT Gateway, then the following service endpoint must be configured:

                                          • com.amazonaws.{REGION}.cloudwatch
                                          • com.amazonaws.{REGION}.secretsmanager
                                          • com.amazonaws.{REGION}.kms

                                          Security Group Configuration

                                          Security groups restrict communication between Log Forwarder Lambda function and the ESA appliance. The following rules must be in place for ESA and Log Forwarder Lambda function.

                                          From VPC > Security Groups > Log Forwarder Security Group configuration.

                                          TypeProtocolPort RangeDestinationReason
                                          Custom TCPTCP9200Log Forwarder Lambda SGESA Communication

                                          Record the name of Log Forwarder security group name.

                                          Log Forwarder Security Group Id: ___________________

                                          The following port must be open for the ESA. If the ESA is running in the Cloud, then create the following security.

                                          ESA Security Group configuration

                                          TypeProtocolPort RangeSource
                                          Custom TCPTCP9200Log Forwarder Lambda SG

                                          Configure ESA Audit Store Credentials

                                          Audit Log Forwarder can optionally authenticate with ESA using certificate-based authentication with a client certificate and certificate key. If used, both the certificate and certificate key will be stored in AWS Secrets Manager.

                                          Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                          • client.key
                                          • client.pem

                                          After certificates are downloaded, open each 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 commands below depending on your operating system.

                                          Linux Bash:

                                          awk 'NF {printf "%s\\n",$0;}' client.key > private_key.txt
                                          awk 'NF {printf "%s\\n",$0;}' client.pem > public_key.txt
                                          

                                          Windows PowerShell:

                                          (Get-Content '.\client.key') -join '\n' | Set-Content 'private_key.pem'
                                          (Get-Content '.\client.pem') -join '\n' | Set-Content 'public_key.pem'
                                          

                                          For more information on how to configure client certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                          To create secret with ESA client certificate/key pair in AWS Secrets Manager.

                                          1. From the AWS Secrets Manager Console, select Store New Secret.

                                          2. Select Other Type of Secrets.

                                          3. Specify the private_key and public_key value pair.

                                          4. Select the encryption key or leave default AWS managed key.

                                          5. Specify the Secret Name and record it below.

                                            ESA Client Certificate/Key Pair Secret Name: ___________________

                                            This value will be used to set PtyEsaClientCertificatesSecretId cloudformation parameter in section Install through CloudFormation

                                          Create Audit Log Forwarder IAM Execution Policy

                                          This task defines a policy used by the Protegrity Log Forwarder Lambda function to write CloudWatch logs, access the KMS encryption key to decrypt the policy and access Secrets Manager for log forwarder user credentials.

                                          Perform the following steps to create the Lambda execution role and required policies:

                                          1. From the AWS IAM console, select Policies > Create Policy.

                                          2. Select the JSON tab and copy the following sample policy.

                                            {
                                              "Version": "2012-10-17",
                                              "Statement": [
                                                {
                                                  "Sid": "EC2ModifyNetworkInterfaces",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "ec2:CreateNetworkInterface",
                                                    "ec2:DescribeNetworkInterfaces",
                                                    "ec2:DeleteNetworkInterface"
                                                  ],
                                                  "Resource": "*"
                                                },
                                                {
                                                  "Sid": "CloudWatchWriteLogs",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "logs:CreateLogGroup",
                                                    "logs:CreateLogStream",
                                                    "logs:PutLogEvents"
                                                  ],
                                                  "Resource": "*"
                                                },
                                                {
                                                  "Sid": "KmsDecrypt",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "kms:Decrypt"
                                                  ],
                                                  "Resource": [
                                                    "arn:aws:kms:*:*:key/*"
                                                  ]
                                                },
                                                {
                                                    "Sid": "KinesisStreamRead",
                                                    "Effect": "Allow",
                                                    "Action": [
                                                        "kinesis:GetRecords",
                                                        "kinesis:GetShardIterator",
                                                        "kinesis:DescribeStream",
                                                        "kinesis:DescribeStreamSummary",
                                                        "kinesis:ListShards",
                                                        "kinesis:ListStreams"
                                                    ],
                                                    "Resource": "*"
                                                },
                                                {
                                                  "Sid": "SecretsManagerGetSecret",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "secretsmanager:GetSecretValue"
                                                  ],
                                                  "Resource": [
                                                    "arn:aws:secretsmanager:*:*:secret:*"
                                                  ]
                                                }
                                              ]
                                            }
                                            
                                          3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                          4. Select Review policy, type in a policy name, for example, ProtegrityLogForwarderLambdaPolicy and Confirm. Record the policy name:

                                            LogForwarderLambdaPolicyName:__________________

                                          Create Log Forwarder IAM Role

                                          Perform the following steps to create Log Forwarder execution IAM role.

                                          To create Log Forwarder IAM role:

                                          1. From AWS IAM console, select Roles > Create Role.

                                          2. Select AWS Service > Lambda > Next.

                                          3. Select the policy created in Create Audit Log Forwarder IAM Execution Policy.

                                          4. Proceed to Name, Review and Create.

                                          5. Type the role name, for example, ProtegrityForwarderRole and click Confirm.

                                          6. Record the role ARN.

                                            Log Forwarder IAM Execution Role Name: ___________________

                                          Installation Artifacts

                                          Audit Log Forwarder installation artifacts are part of the same deployment package as the one used for protect and policy agent services. Follow the steps below to ensure the right artifacts are available for log forwarder installation.

                                          1. Verify that the Protegrity deployment package is available on your local system, if not, you can download it from the Protegrity portal.

                                          2. Extract the pty_log_forwarder_cf.json cloud formation file from the deployment package.

                                          3. Check the S3 deployment bucket identified in section Create S3 bucket for Installing Artifacts. Make sure that all Protegrity deployment zip files are uploaded to the S3 bucket.

                                          Install through CloudFormation

                                          The following steps describe the deployment of the Audit Log Forwarder AWS cloud components.

                                          1. Access CloudFormation and select the target AWS Region in the console.

                                          2. Click Create Stack and choose With new resources.

                                          3. Specify the template.

                                          4. Select Upload a template file.

                                          5. Upload the Protegrity-provided CloudFormation template called pty_log_forwarder_cf.json and click Next.

                                          6. Specify the stack details. Enter a stack name.

                                          7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                                          Parameter

                                          Description

                                          Default Value

                                          Required

                                          LogForwarderSubnets

                                          Subnets where the Log Forwarder will be hosted.

                                           

                                           

                                          LogForwarderSecurityGroups

                                          Security Groups, which allow communication between the Log Forwarder and ESA.

                                           

                                          X

                                          LambdaExecutionRoleArn

                                          The ARN of Lambda role created in the prior step.

                                           

                                          X

                                          ArtifactS3Bucket

                                          Name of S3 bucket created in the pre-configuration step.

                                           

                                          X

                                          LogDestinationEsaIp

                                          IP or FQDN of the ESA instance or cluster.

                                           

                                          X

                                          AuditLogOutput

                                          Audit log processor to target on ESA. Allowed values: audit-store, td-agent

                                          audit-store

                                          X

                                          PtyEsaClientCertificatesSecretId

                                          AWS Secrets Manager secret id containing client certificates used for authentication with ESA Audit Store. It is expected that the public key will be stored in a field public_key and the private key in a field named private_key.

                                          This parameter is optional. If not provided, Log Forwarder will connect to ESA without client certificate authentication.

                                          EsaTlsDisableCertVerify

                                          Disable certificate verification when connecting to ESA if set to 1. This is only for dev purposes, do not disable in production environment.

                                          0

                                          X

                                          PtyEsaCaServerCert

                                          ESA self-signed CA certificate used by log forwarder Lambda to ensure ESA is the trusted server.

                                          Recorded in step Certificates on ESA

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

                                           

                                          EsaConnectTimeout

                                          Time in seconds to wait for the ESA response. Minimum value: 1.

                                          5

                                          X

                                          EsaVirtualHost

                                          ESA virtual hostname. This configuration is optional and it can be used when proxy server is present and supports TLS SNI extension.

                                           

                                           

                                          KinesisLogStreamRetentionPeriodHours

                                          The number of hours for the log records to be stored in Kinesis Stream in case log destination server is not available. Minimum value: 24. See Log Forwarder Performance section for more details.

                                          24

                                          X

                                          KinesisLogStreamShardCount

                                          The number of shards that the Kinesis log stream uses. For greater provisioned throughput, increase the number of shards. Minimum value: 1. See Log Forwarder Performance section for more details.

                                          10

                                          X

                                          MinLogLevel

                                          Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                                          severe

                                          X

                                          1. Click Next with defaults to complete CloudFormation.

                                          2. After CloudFormation is completed, select the Outputstab in the stack.

                                          3. Record the following values

                                            KinesisLogStreamArn: ________________________________

                                          Add Kinesis Put Record permission to the Protect Function IAM Role

                                          1. Login to the AWS account that hosts the Protect Lambda Function.

                                          2. Search for Protect Lambda Function IAM Execution Role Name created in Create Protect Lambda IAM role.

                                          3. Under Permissions policies, select Add Permissions > Create inline policy.

                                          4. In Specify permissions view, switch to JSON.

                                          5. Copy the policy json from below replacing the placeholder value indicated in the following snippet as <Audit Log Kinesis Stream ARN> with the value recorded in the previous step.

                                            {
                                            	"Version": "2012-10-17",
                                            	"Statement": [
                                            		{
                                            			"Sid": "KinesisPutRecords",
                                            			"Effect": "Allow",
                                            			"Action": "kinesis:PutRecords",
                                            			"Resource": "<Audit Log Kinesis Stream ARN>"
                                            		}
                                            	]
                                            }
                                            
                                          6. When you are finished, choose Next.

                                          7. On the Review and create page, type a Name, then choose Create policy.

                                          Test Log Forwarder Installation

                                          Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                          Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                          1. Navigate to the log forwarder lambda function.

                                          2. Select the Test tab.

                                          3. Copy the json test event into the Event JSON pane.

                                            {
                                                "Records": [
                                                    {
                                                        "kinesis": {
                                                            "kinesisSchemaVersion": "1.0",
                                                            "partitionKey": "041e96d78c778677ce43f50076a8ae3e",
                                                            "sequenceNumber": "49620336010289430959432297775520367512250709822916263938",
                                                            "data": "eyJpbmdlc3RfdGltZV91dGMiOiIyMDI2LTAzLTI3VDEzOjIzOjEyLjkwNFoiLCJhZGRpdGlvbmFsX2luZm8iOnsiZGVzY3JpcHRpb24iOiJEYXRhIHVucHJvdGVjdCBvcGVyYXRpb24gd2FzIHN1Y2Nlc3NmdWwuIn0sImNsaWVudCI6e30sImNudCI6NCwiY29ycmVsYXRpb25pZCI6InJzLXF1ZXJ5LWlkOjEyMzQiLCJsZXZlbCI6IlNVQ0NFU1MiLCJsb2d0eXBlIjoiUHJvdGVjdGlvbiIsIm9yaWdpbiI6eyJob3N0bmFtZSI6IlBSTy1VUy1QRjNSSEdGOSIsImlwIjoiMTAuMTAuMTAuMTAiLCJ0aW1lX3V0YyI6MTcxMTU1OTEwMH0sInByb2Nlc3MiOnsiaWQiOjJ9LCJwcm90ZWN0aW9uIjp7ImF1ZGl0X2NvZGUiOjgsImRhdGFlbGVtZW50IjoiYWxwaGEiLCJkYXRhc3RvcmUiOiJTQU1QTEVfUE9MSUNZIiwibWFza19zZXR0aW5nIjoiIiwib2xkX2RhdGFlbGVtZW50IjpudWxsLCJvcGVyYXRpb24iOiJVbnByb3RlY3QiLCJwb2xpY3lfdXNlciI6IlBUWURFViJ9LCJwcm90ZWN0b3IiOnsiY29yZV92ZXJzaW9uIjoiMS4yLjErNTUuZzU5MGZlLkhFQUQiLCJmYW1pbHkiOiJjcCIsInBjY192ZXJzaW9uIjoiMy40LjAuMTQiLCJ2ZW5kb3IiOiJyZWRzaGlmdCIsInZlcnNpb24iOiIwLjAuMS1kZXYifSwic2lnbmF0dXJlIjp7ImNoZWNrc3VtIjoiN0VCMkEzN0FDNzQ5MDM1NjQwMzBBNUUxNENCMTA5QzE0OEJGODYwRjE3NEVCMjMxMTAyMEI3RkE1QTY4MjdGQyIsImtleV9pZCI6ImM0MjQ0MzZhLTExMmYtNGMzZi1iMmRiLTEwYmFhOGI1NjJhNyJ9fQ==",
                                                            "approximateArrivalTimestamp": 1626878559.213
                                                        },
                                                        "eventSource": "aws:kinesis",
                                                        "eventVersion": "1.0",
                                                        "eventID": "shardId-000000000000:49620336010289430959432297775520367512250709822916261234",
                                                        "eventName": "aws:kinesis:record",
                                                        "invokeIdentityArn": "arn:aws:iam::555555555555:role/service-role/TestRole",
                                                        "awsRegion": "us-east-1",
                                                        "eventSourceARN": "arn:aws:kinesis:us-east-1:555555555555:stream/CloudProtectEventStream"
                                                    }
                                                ]
                                            }
                                            
                                          4. Select Test to execute the test event.

                                          5. Test is successful if the Log Output of test results contains the following log:

                                            [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                            

                                            If the log is not present, please consult the Troubleshooting section for common errors and solutions.

                                          Update Protector With Kinesis Log Stream

                                          In this section, Kinesis log stream ARN will be provided to the Protect Function installation.

                                          1. Navigate to the Protector CloudFormation stack created in the protector installation section.

                                          2. Select Update.

                                          3. Choose Use existing template > Next.

                                          4. Set parameter KinesisLogStreamArn to the output value recorded in Install through CloudFormation.

                                          5. Proceed with Next and Submit the changes.

                                          6. Continue to the next section once stack status indicates UPDATE_COMPLETE.

                                          Update Policy Agent With Log Forwarder Function Target

                                          Log Forwarder Lambda function requires a policy layer which is in sync with the Protegrity Protector. This section will describe the steps to update the policy agent to include updating Log Forwarder Lambda function.

                                          1. Navigate to the Policy Agent Function created in Policy Agent Installation

                                          2. Select Configuration > Environment variables > Edit

                                          3. Edit the value for environment variable AWS_PROTECT_FN_NAME to include the log forwarder function name/arn in the comma separated list of Lambda functions.

                                          4. Save the changes and continue when update completes

                                          5. Navigate to Test tab

                                          6. Add an event {} and select Test to run the Policy Agent function

                                          7. Verify Log forwarder function was updated to use the policy layer by inspecting the log output. Logs should include the following:

                                            
                                            [INFO] 2024-07-09 18:58:04,793.793Z 622d374b-1f73-4123-9a38-abc61973adef iap_agent.policy_deployer:Updating lambda [Protegrity_LogForwarder_<stack ID>] to use layer version [arn:aws:lambda:<aws region>:<aws account number>:layer:Protegrity_Layer_<layer name>:<layer version>]
                                            

                                          Test Full Log Forwarder Installation

                                          Install and configure Protegrity Agent, Protector, and Log Forwarder components.

                                          1. Send a protect operation to the protector using a data element or user which will result in audit log generation

                                          2. Navigate to the CloudWatch log group for the Protect function

                                          3. Select the log stream for the test operation and scroll to the latest logs

                                          4. Expect to see a log similar to the below:

                                            
                                            [2024-07-09T19:28:23.158] [INFO] [kinesis-external-sink.cpp:51] Sending 2 logs to Kinesis ...
                                            [2024-07-09T19:28:23.218] [INFO] [aws-utils.cpp:206] Kinesis send time: 0.060s
                                            
                                          5. Navigate to the CloudWatch log group for the Log Forwarder function

                                          6. Expect to see a new log stream - it may take several minutes for the stream to start

                                          7. Select the new stream and scroll to the most recent logs in the stream

                                          8. Expect to see a log similar to the below:

                                            
                                            [2024-07-09T19:32:31.648] [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                            

                                          Troubleshooting

                                          Error

                                          Action

                                          Log forwarder log contains severe level secrets permissions error:

                                          [SEVERE] User: <arn> is not authorized to perform: secretsmanager:
                                          GetSecretValue on resource: <secret name> because no identity-based
                                          policy allows the secretsmanager:GetSecretValue action
                                          
                                          1. Verify the permission policy/role attached to the log forwarder function has secretsmanager:GetSecretValue permission for the insights esa user credentials secret.
                                          2. Consult sections Configure ESA Audit Store Credentials and Create Audit Log Forwarder IAM Execution Policy

                                          When testing log forwarder as described in Test Log Forwarder Installation, response contains policy decryption error:

                                          
                                          {
                                            "error_msg": "Failed to decrypt the policy. Please verify
                                              that the function has access to the key service and the key.",
                                            "success": false
                                          }
                                          
                                          1. Verify the permission policy/role attached to the log forwarder function has kms:Decrypt permission for KMS key used to encrypt the Protegrity security policy.
                                          2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                          Cloudformation stack creation fails with error:

                                          
                                          The provided execution role does not have permissions to call
                                          [CreateNetworkInterface|DescribeNetworkInterfaces|DeleteNetworkInterface]
                                          on EC2 (Service: Lambda, Status Code: 400, Request ID: <request id>)"
                                          (RequestToken: <request token>, HandlerErrorCode: InvalidRequest)
                                          
                                          1. Verify the permission policy/role attached to the log forwarder function has ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, ec2:DeleteNetworkInterface permissions
                                          2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                          Severe level kinesis permissions log message in protector function:

                                          
                                          [SEVERE] Kinesis stream client returned 400 error with error message:
                                          User: <function arn> is not authorized to perform: kinesis:PutRecords
                                          on resource: <kinesis stream arn> because no identity-based policy
                                          allows the kinesis:PutRecords action
                                          
                                          1. Verify the permission policy/role attached to the protector function has kinesis:PutRecords permission
                                          2. Consult section Add Kinesis Put Record permission to the Protect Function IAM Role

                                          TLS errors reported in log forwarder function logs:

                                          
                                          [error] [tls] <error message>
                                          
                                          1. If ESA is using self-signed certificate, verify the correct ESA certificate has been given in the format described in Certificates on ESA

                                          1.2.3.6 -

                                          Configuring Regular Expression to Extract Policy Username

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

                                          • USERNAME_REGEX Lambda Environment configuration

                                            The USERNAME_REGEX configuration can be used to extract policy username from user in the request. The following are allowed values for USERNAME_REGEX:

                                            • 1 - Default build-in regular expression is used:

                                              ^arn:aws:(?:iam|sts)::[0-9]{12}:(?:role|user|group|assumed\-role|federated\-user)\/([\w\/+=,.\-]{1,1024}|[\w\/+=,.\-@]{1,1024})(?:@[a-zA-Z0-9\-]{1,320}(?:\.\w+)+)?$
                                              
                                            • ^User regex$ - Custom regex 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

                                          arn:aws:iam::123456789012:user/juliet.snow

                                          arn:aws:iam::123456789012:user/juliet.snow

                                          arn:aws:sts::123456789012:assumed-role/TestSaml

                                          arn:aws:sts::123456789012:assumed-role/TestSaml

                                          1

                                          arn:aws:iam::123456789012:user/juliet.snow

                                          juliet.snow

                                          arn:aws:sts::123456789012:assumed-role/TestSaml

                                          TestSaml

                                          ^arn:aws:(?:iam|sts)::[0-9]{12}:((?:role|user|group|assumed-role|federated-user).*)$
                                          

                                          arn:aws:iam::123456789012:user/juliet.snow

                                          user/juliet.snow

                                          arn:aws:sts::123456789012:assumed-role/TestSaml

                                          assumed-role/TestSaml

                                          1.2.3.7 -

                                          Create Protect Lambda IAM Execution Policy

                                          This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

                                          Perform the following steps to create the Lambda execution role and required policies.

                                          To create protect lambda IAM execution policy:

                                          1. From the AWS IAM console, select Policies > Create Policy.

                                          2. Select the JSON tab and copy the following sample policy.

                                            {
                                              "Version": "2012-10-17",
                                              "Statement": [
                                                {
                                                  "Sid": "CloudWatchWriteLogs",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "logs:CreateLogGroup",
                                                    "logs:CreateLogStream",
                                                    "logs:PutLogEvents"
                                                  ],
                                                  "Resource": "*"
                                                },
                                                {
                                                  "Sid": "KmsDecrypt",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                    "kms:Decrypt"
                                                  ],
                                                  "Resource": [
                                                    "arn:aws:kms:*:*:key/*"
                                                  ]
                                                }
                                              ]
                                            }
                                            
                                          3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                          4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

                                            ProtectLambdaPolicyName:__________________

                                          1.2.3.8 -

                                          Granting access to use the Cloud Protect UDF

                                          The ability to use the Cloud Protect UDF from Athena is controlled through IAM permissions. The Athena user/role must have the InvokeFunction permission to the Cloud Protect Lambda function as shown in the following example:

                                          { 
                                              "Version": "2012-10-17", 
                                              "Statement": [ 
                                                { 
                                                      "Sid": "ProtectLambdaFunction", 
                                                      "Effect": "Allow", 
                                                      "Action": "lambda:InvokeFunction", 
                                                      "Resource": "<PROTECT_FUNCTION_ARN>" 
                                                 } 
                                              ] 
                                          }
                                          

                                          The policy above would be used in addition to any other IAM policies required to use Amazon Athena. Refer to the AWS Athena example policy for a typical IAM policy.

                                          1.2.3.9 -

                                          Policy User

                                          Policy user for protect and unprotect operations can be provided from either Lambda environment variable or federated identity.

                                          • POLICY_USER Environment Variable in the Athena Protect Lambda

                                            The Lambda environment variable POLICY_USER, may be set with a default user in the security policy or as a service user.

                                          • Federated Identity

                                            When the request contains the federated identity, the policy user maybe the IAM ARN of the user running the SQL query. For example:

                                          User

                                          arn:aws:iam::123456789012:user/juliet.snow

                                          Role

                                          arn:aws:sts::123456789012:assumed-role/TestSaml

                                          To control which Policy User is used, Athena Protect Lambda has the Environment Variable: POLICY_USER_CONFIG.

                                          Value

                                          description

                                          0

                                          (Default) The Federated Identity is used when provided by Amazon Athena, if the Federated Identity is not provided, the user defaults to the POLICY_USER.

                                          1

                                          The Federated Identity will only be used. If The Federated Identity is not provided the Athena Protect Lambda will fail the query.

                                          2

                                          The POLICY_USER will always be used, regardless if the Federated Identity is provided or not. POLICY_USER is required. If it is empty or missing the Protect Lambda will fail the query.

                                          1.2.3.10 -

                                          Prerequisites

                                          RequirementDetail
                                          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
                                          AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                          Athena Engine Version 3Only Athena engine version 3 is supported. The product may work in Athena engine version 2, but it is deprecated and all users are encouraged to upgrade.

                                          1.2.3.11 -

                                          AWS Service Dependencies

                                          The following table describes the AWS services that may be a part of your Protegrity installation.

                                          Service

                                          Description

                                          Lambda

                                          Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                          KMS

                                          Provides secrets for envelope policy encryption/decryption for Protegrity.

                                          Secrets Manager

                                          Provides secrets management for the ESA credentials.

                                          S3

                                          Intermediate storage location for the encrypted ESA policy layer.

                                          Kinesis

                                          Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                          VPC & NAT Gateway

                                          Optional. Provides a private subnet to communicate with an on-prem ESA.

                                          CloudWatch

                                          Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                          1.2.3.12 -

                                          Required Skills and Abilities

                                          Role / Skillset

                                          Description

                                          AWS Account Administrator

                                          To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

                                          Protegrity Administrator

                                          The ESA credentials required to extract the policy for the Policy Agent

                                          Network Administrator

                                          To open firewall to access ESA and evaluate AWS network setup

                                          1.2.4 - Understanding Athena Objects

                                          Key concepts in understanding Protegrity Serverless with Athena.

                                          Understanding Athena Objects

                                          The following sections describe key concepts in understanding Protegrity Serverless with Athena.

                                          1.2.4.1 -

                                          User Defined Functions

                                          User Defined Functions (UDF) in Amazon Athena allow users to invoke protect and unprotect operations on data using Athena SQL.

                                          To use a UDF in Athena, you must declare the USING EXTERNAL FUNCTION clause before the SELECT statement in a SQL query. For example, the following query would perform an unprotect on first_name and last_name fields using the deName element policy:

                                          USING EXTERNAL FUNCTION unprotect(val varchar, el varchar) RETURNS varchar      LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                          SELECT unprotect(first_name, 'deName'), unprotect(last_name, 'deName')
                                          FROM customers;
                                          

                                          Parent topic:Understanding Athena Objects

                                          1.2.5 - Performance

                                          Benchmarks and performance tuning

                                          Performance

                                          Performance Considerations

                                          The following factors may cause variation in real performance versus benchmarks:

                                          1. Cold startup: The Lambda 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 Lambda is initialized, subsequent “warm executions” should process quickly.
                                          2. Size of policy: The size of the policy impacts cold start performance. Larger policies take more time to initialize.
                                          3. Lambda memory: AWS provides more virtual cores based on the memory configuration. The initial configuration of 1728 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                          4. Number of security operations (protect or unprotect).
                                          5. Lambda concurrency and burst quotas: AWS limits the number of concurrent executions and how quickly lambda can scale to meet demand. This is discussed in an upcoming section of the document.
                                          6. Size of data element: Operations on larger text consume time.

                                          Sample Benchmarks

                                          The following benchmarks were performed against CSV files from an S3 bucket.

                                          Benchmark (rows x columns):

                                          Operations1M * 6 cols10M * 6 cols100M * 6 cols
                                          Athena Protector (Athena v3 Engine)8.5s17.9s2m 12s

                                          Estimated AWS costs:

                                          Type/#Ops5B ops/mo.50B ops/mo.500B ops/mo.1T ops/mo.
                                          Athena Protector$8$80$800$1,600

                                          Performance Tuning

                                          • Lambda Tuning
                                            AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region.
                                          • Concurrency Troubleshooting
                                            Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a client query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your API Gateway or Lambda services in the region.
                                          • Cold-Start Performance
                                            Cold-start vs warm execution refers to the state of the Lambda when a request is received. A cold-start undergoes additional initialization, such as, loading the security policy. Warm execution applies to all subsequent requests served by the Lambda.

                                          Lambda Tuning

                                          AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region.

                                          The concurrent executionsquota cap is the maximum number of lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                                          The burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. Once the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response. Athena will generally retry until all requests succeed but may abort if a high percentage of failed responses occur.

                                          The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended selecting a Athena AWS region with the highest burst limits.

                                          Concurrency Troubleshooting

                                          Exceeding your quota limits may indicate quota adjustments are required. Exceeding quota limits may cause a query to fail or reduce performance. Worst case, significant throttling can impact the performance of all your Lambda functions in the region.

                                          Athena is tolerant of a certain ratio of failed requests and automatically retries. If a high percentage of requests fail, the query may abort.

                                          CloudWatch Metrics can be observed on Lambda to reveal if quotas are being reached. CloudWatch logs can be used to access the actual error code.

                                          Cold-Start Performance

                                          Cold-start vs warm execution refers to the state of the Lambda function when a request is received. A cold-start undergoes additional initialization such as loading the security policy. Warm execution applies to all subsequent requests served by the Lambda. The following table shows an example how these states impact latency and performance:

                                          Execution stateAvg. Execution Duration
                                          Cold execution438 ms
                                          Warm execution< 2ms

                                          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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Amazon Kinesis Stream where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated. 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 Cloud Formation Parameters

                                            • AuditLogFlushInterval: Determines the minimum amount of time required for the audit log to be sent to Amazon Kinesis. Changing flush interval may affect the level of aggregation, which in turn may result in different number of connections and different data rates to Amazon Kinesis. Default value is 30 seconds.

                                              Increasing the flush interval may result in higher aggregation of audit logs, in fewer connections to Amazon Kinesis, in higher latency of audit logs arriving to ESA and in higher data throughput.

                                              Lowering the flush interval may result in lower aggregation of audit logs, in more connections to Amazon Kinesis, in lower latency of audit logs arriving to ESA and in lower data throughput.

                                              It is not recommended to reduce the flush interval from default value in production environment as it may overload the Amazon Kinesis service. However, it may be beneficial to reduce flush interval during testing to make audit records appear on ESA faster.

                                                

                                          • Log Forwarder Cloud Formation Parameters

                                            • Amazon KinesisLogStreamShardCount: The number of shards represents the level of parallel streams in the Amazon Kinesis and it is proportional to the throughput capacity of the stream. If the number of shards is too low and the volume of audit logs is too high, Amazon Kinesis service may be overloaded and some audit records sent from protect function may be lost.

                                              Default value is 10, however you are advised to test with a production-like load to determine whether this is sufficient or not.

                                            • Amazon KinesisLogStreamRetentionPeriodHours: The time for the audit records to be retained in Amazon Kinesis log stream in cases where log forwarder function is unable to read records from the Kinesis stream or send records to ESA, for example due to a connectivity outage. Amazon Kinesis will retain failed audit records and retry periodically until connectivity with ESA is restored or retention period expires.

                                              Default value is 24 hours, however you are advised to review this value to align it with your Recovery Time Objective and Recovery Point Objective SLAs.

                                                

                                          • Monitoring Log Forwarder Resources

                                            • Amazon Kinesis Stream Metrics: Any positive value in Amazon Kinesis PutRecords throttled records metric indicates that audit logs rate from protect function is too high. The recommended action is to increase the Amazon KinesisLogStreamShardCount or optionally increase the AuditLogFlushInterval.

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

                                              [SEVERE] Dropped records: x.
                                              
                                            • Protect Function CloudWatch Logs: If protect function is unable to send logs to Amazon Kinesis, it will log the following message:

                                              [SEVERE] Amazon Kinesis error, retrying in x ms (retry: y/z) ..."
                                              

                                              Any dropped audit log records will be reported with the following log message:

                                              [SEVERE] Failed to send x/y audit logs to Amazon Kinesis.
                                              

                                          1.2.6 - Audit Logging

                                          Audit log description/formatting

                                            Audit Logging

                                            Audit records and application logs stream to Amazon CloudWatch Logs or optionally be sent to ESA. 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 Amazon CloudWatch. Third-party solutions may be used if they are supported by Amazon Cloudwatch or AWS Lambda logging extensions. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Amazon CloudWatch, refer to the Amazon CloudWatch User Guide.

                                            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

                                            Example Audit Records

                                            The following are sample audit messages:

                                            Protect Success:

                                            {
                                                  "additional_info": {
                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                    "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",
                                                    "ip": "127.0.0.1",
                                                    "time_utc": 1635363966
                                                  },
                                                  "protection": {
                                                    "dataelement": "deAddress",
                                                    "operation": "Protect",
                                                    "audit_code": 6,
                                                    "datastore": "SAMPLE_POLICY",
                                                    "policy_user": "test_user"
                                                  },
                                                  process":{
                                                    "name":"protect",
                                                    "id":"13",
                                                    "module":"coreprovider",
                                                    "thread_id":"573580544",
                                                    "user":"sbx_user1051",
                                                    "platform":"\"Linux_x64\"",
                                                    "version":"UNKNOWN"
                                                  },
                                                  "client": {
                                                    "ip":"169.254.62.117"
                                                  },
                                                  "protector": {
                                                    "family": "cp",
                                                    "version": "4.0.0.102",
                                                    "vendor": "aws.snowflake",
                                                    "datastore":"SAMPLE_POLICY",
                                                    "pcc_version": "4.0.0.9",
                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                    "lambda_version":"4.0.1"
                                                  },
                                                  "signature": {
                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                    "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                  }
                                                }
                                            

                                            User permission denied:

                                            {
                                                  "additional_info": {
                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                    "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",
                                                    "ip": "127.0.0.1",
                                                    "time_utc": 1635363966
                                                  },
                                                  "protection": {
                                                    "dataelement": "deAddress",
                                                    "operation": "Protect",
                                                    "audit_code": 3,
                                                    "datastore": "SAMPLE_POLICY",
                                                    "policy_user": "test_user"
                                                  },
                                                  process":{
                                                    "name":"protect",
                                                    "id":"13",
                                                    "module":"coreprovider",
                                                    "thread_id":"573580544",
                                                    "user":"sbx_user1051",
                                                    "platform":"\"Linux_x64\"",
                                                    "version":"UNKNOWN"
                                                  },
                                                  "client": {
                                                    "ip":"169.254.62.117"
                                                  },
                                                  "protector": {
                                                    "family": "cp",
                                                    "version": "4.0.0.102",
                                                    "vendor": "aws.snowflake",
                                                    "datastore":"SAMPLE_POLICY",
                                                    "pcc_version": "4.0.0.9",
                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                    "lambda_version":"4.0.1"
                                                  },
                                                  "signature": {
                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                    "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                  }
                                                }
                                            

                                            Data element not found:

                                            {
                                                  "additional_info": {
                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                    "description": "The data element could not be found in the policy.",
                                                    "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",
                                                    "ip": "127.0.0.1",
                                                    "time_utc": 1635363966
                                                  },
                                                  "protection": {
                                                    "dataelement": "deAddress",
                                                    "operation": "Protect",
                                                    "audit_code": 2,
                                                    "datastore": "SAMPLE_POLICY",
                                                    "policy_user": "test_user"
                                                  },
                                                  process":{
                                                    "name":"protect",
                                                    "id":"13",
                                                    "module":"coreprovider",
                                                    "thread_id":"573580544",
                                                    "user":"sbx_user1051",
                                                    "platform":"\"Linux_x64\"",
                                                    "version":"UNKNOWN"
                                                  },
                                                  "client": {
                                                    "ip":"169.254.62.117"
                                                  },
                                                  "protector": {
                                                    "family": "cp",
                                                    "version": "4.0.0.102",
                                                    "vendor": "aws.snowflake",
                                                    "datastore":"SAMPLE_POLICY",
                                                    "pcc_version": "4.0.0.9",
                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                    "lambda_version":"4.0.1"
                                                  },
                                                  "signature": {
                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                    "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                  }
                                                }
                                            

                                            1.2.7 - No Access Behavior

                                            Describes the result of various policy configurations with no access operations

                                            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.2.8 - Known Limitations

                                            Known product limitations.
                                            • FPE is supported only for ASCII values.
                                            • Only the protect and unprotect operations are supported. The reprotect operation is not currently supported.
                                            • Binary data types not supported.

                                            1.2.9 - Upgrading To The Latest Version

                                            Instructions for upgrading the protector.

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

                                              After downloading the deployment package from the Protegrity Portal, unzip the package to extract the artifact files. In the AWS Console, navigate to the S3 bucket that was previously created to upload deployment artifacts (see: Create S3 bucket for Installing Artifacts).

                                              Upload the following artifacts to the S3 bucket:

                                              - -
                                              • protegrity-protect-<version>.zip
                                              • protegrity-agent-<version>.zip
                                              • protegrity-external-extension-<version>.zip
                                              • protegrity-sample-policy-<version>.zip
                                              • protegrity-protect-<version>.zip
                                              • protegrity-agent-<version>.zip
                                              • protegrity-external-extension-<version>.zip
                                              • protegrity-sample-policy-<version>.zip
                                              • protegrity-protect-<version>.zip
                                              • protegrity-agent-<version>.zip
                                              • protegrity-external-extension-<version>.zip
                                              • protegrity-sample-policy-<version>.zip
                                              • protegrity-athena-protect-udfs-<version>.jar
                                              • protegrity-external-extension-<version>.zip
                                              • protegrity-agent-<version>.zip
                                              • protegrity-sample-policy-<version>.zip

                                              If the release version matches your existing deployment, you don’t need to upload it again. Save the following artifacts on your local system so that you have them available during the next steps:

                                              - -
                                              • pty_protect_cf.json
                                              • pty_agent_cf.json
                                              • pty_protect_cf.json
                                              • pty_agent_cf.json
                                              • pty_protect_api_cf.json
                                              • pty_agent_cf.json
                                              • pty_log_forwarder_cf.json
                                              • pty_athena_protect_cf.json
                                              • pty_agent_cf.json

                                              Perform the following steps to upgrade the Agent Lambda and Protect Lambda separately.

                                              Disable Protegrity Agent Function CloudWatch Event Rule

                                              Cloud Watch Event Rule is used to periodically run Protegrity Agent Function to synchronize policy from ESA. This functionality is optional when deploying Protegrity Serverless Solution. If the Event Rule is enabled, it must be disabled temporarily for the time of the upgrade process.

                                              Follow the steps below to determine if your deployment uses Event Rule and disable it.

                                              1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                              2. Select Resources tab from the top portion of the screen.

                                              3. Check if there is a resource with ScheduledRule LogicalID. If there is no such resource you can skip to Upgrading Policy Agent Lambda section. If the scheduled rule is there, continue with the next steps in this section.

                                              4. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                              5. Select Disable from the top-right portion of the screen. This will disable the rule. You will re-enable it after the upgrade process is complete.

                                              Upgrading Policy Agent Lambda

                                              1. Go to AWS Lambda console and select existing Protegrity Agent Lambda.

                                              2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish. The version of Agent Lambda you just created will serve as restore point in the case you needed to rollback the upgrade.

                                              3. Go to Lambda Configuration > Environment variables.

                                              4. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                aws lambda get-function-configuration --function-name \
                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                --query Environment > <function_name>_env_config.json
                                                
                                              5. Go to AWS Cloud Formation and select existing Protegrity Agent deployment stack.

                                              6. Select Update. Check Replace current template > Upload a template file.

                                              7. Upload pty_agent_cf.json file and select Next.

                                              8. Click Next until Review window and then select Update stack.

                                              9. Wait for the Cloud Formation to complete.

                                              10. Navigate back to Agent Lambda Function.

                                              1. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                aws lambda update-function-configuration --function-name \
                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                --environment file://./<function_name>_env_config.json
                                                
                                              2. If you are upgrading from versions prior to v3.0, backup and remove existing policy from the bucket defined by AWS_POLICY_S3_BUCKET property, so that the policy can be re-downloaded and re-encrypted with new ‘key commitment’ feature.

                                              3. If you are upgrading from version prior to 1.6.1 please follow the steps below, otherwise the upgrade process is completed.

                                              4. From AWS Console, navigate to IAM > Policies

                                              5. Search for the Agent Lambda IAM Policy created in Create Agent Lambda IAM policy

                                              6. Click on the policy, then select Edit Policy. Select JSON tab.

                                              7. Add the following statement to the list of policy statements.

                                                
                                                {
                                                  "Sid": "LambdaGetConfiguration",
                                                  "Effect": "Allow",
                                                  "Action": [
                                                      "lambda:GetFunctionConfiguration"
                                                  ],
                                                  "Resource": [
                                                      "arn:aws:lambda:*:*:function:*"
                                                  ]
                                                }
                                                
                                              8. Click Review Policy, then Save Changes. Wait for the changes to save.

                                              Upgrading Log Forwarder Lambda

                                              • Publish Log Forwarder Lambda Version

                                                Publishing a version of the Log Forwarder Lambda allows to roll-back to pre-existing version if upgrade fails

                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                3. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                  Log Forwarder Lambda version number for roll-backs: ___________________

                                              • Disable Kinesis Trigger

                                                Disabling Kinesis trigger ensures there are no unprocessed or re-processed events while function is upgraded.

                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                2. Select Configuration tab > Triggers
                                                3. Check Kinesis trigger and click Edit button
                                                4. Uncheck Activate trigger and click Save
                                                5. Wait for function to stop processing events by monitoring function in Monitor tab
                                              • Upgrade Forwarder Lambda Version

                                                Upgrade Log Forwarder function with new code

                                                1. Go to AWS Cloud Formation and select existing Protegrity Log Forwarder deployment stack.
                                                2. Select Update Stack > Make a direct update.
                                                3. Select Replace existing template > Upload a template file.
                                                4. Upload pty_log_forwarder_cf file and select Next.
                                                5. Click Next until Review window and then select Update stack.
                                                6. Wait for the Cloud Formation to complete.
                                              • Enable Kinesis Trigger

                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                2. Select Configuration tab > Triggers
                                                3. Check Kinesis trigger and click Edit button
                                                4. Check Activate trigger and click Save Log Forwarder function will now start processing events from where it left off when Kinesis trigger was disabled.
                                              • Monitor and roll-back

                                                Monitor Log Forwarder function for errors in its CloudWatch logs and in Montior tab. To roll back function to the previous version if any errors occur follow these steps:

                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                2. Select Configuration tab > Triggers

                                                3. Expand Details section of Kinesis trigger and record UUID value

                                                4. Execute the following AWS CLI command to move Kinesis trigger to previous version of Log Forwarder Lambda that was created earlier and recorded as Log Forwarder Lambda version number for roll-backs. Substitute kinesis-mapping-uuid, log-forwarder-function-name, version-for-roll-backs with your values:

                                                  
                                                  aws lambda update-event-source-mapping --uuid <kinesis-mapping-uuid> --function-name <log-forwarder-function-name>:<version-for-roll-backs>
                                                  
                                                5. Find Kinesis trigger attached to previous version of Log Forwarder Lambda by navigating Versions tab > Version number link in the Versions column Kinesis trigger is now moved to previous version of Log Forwarder Lambda function.

                                              Upgrading Protect Lambda

                                              Diagram below illustrates upgrade steps.

                                              Snowflake Function Upgrade Steps

                                              Redshift Function Upgrade Steps

                                              Cloud API Function Upgrade Steps

                                              Athena Function Upgrade Steps

                                              • Publish Protect Lambda Version

                                                Publishing a version of the Protect Lambda allows updating it without interruptions to the existing traffic.

                                                1. Go to AWS Lambda console and select existing Protegrity Protect Lambda.

                                                2. Go to Lambda Configuration > Environment variables.

                                                3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                  aws lambda get-function-configuration --function-name \
                                                  arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                  --query Environment > <function_name>_env_config.json
                                                  
                                                4. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                5. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                  Protect Lambda version number: ___________________

                                                6. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                  CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                      RETURNS varchar
                                                      VOLATILE lambda
                                                      'Protegrity_Protect_test:<protect_lambda_version_number>' iam_role
                                                      'arn:aws:iam::123456789212:role/example_role';
                                                  
                                              • Run protect service upgrade

                                                In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                                                1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                2. Select Update. Check Replace current template > Upload a template file.

                                                3. Upload pty_protect_cf.json file and select Next.

                                                4. Update ProtectFunctionProductionVersion parameter with Protect Lambda version number recorded in step 3.

                                                5. Click Next until Review window and then select Update stack.

                                                6. Wait for the Cloud Formation to complete.

                                                7. Go back to Lambda console and select Protect Lambda.

                                                8. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                  aws lambda update-function-configuration --function-name \
                                                  arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                  --environment file://./<function_name>_env_config.json
                                                  
                                                9. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                                                10. The upgraded Protect Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.

                                              • Finalize upgrade

                                                In this step, the Protect Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                                                1. Go back to Protegrity AWS Cloud Formation deployment stack.

                                                2. Select Update. Check Use Current template.

                                                3. Update ProtectFunctionProductionVersion parameter with the following value: $LATEST.

                                                4. Click Next until Review window and then select Update stack.

                                                5. Go back to Lambda console and select Protect Lambda.

                                                6. From the Lambda console, verify that Latest alias points to $LATEST version.

                                                7. Test your function to make sure it works as expected.

                                                8. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                  CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                      RETURNS varchar
                                                      VOLATILE lambda
                                                      'Protegrity_Protect_test:Production' iam_role
                                                      'arn:aws:iam::123456789212:role/example_role';
                                                  
                                                9. If you need to rollback to older version of Protect Lambda, you can re-run the cloud formation with ProtectFunctionProductionVersion parameter set to the previous version of Protect Lambda.

                                              Re-enable Protegrity Agent Function CloudWatch Event Rule

                                              If the Event Rule was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to re-enable Policy Agent Event rule.

                                              1. Go to the Protegrity Agent Cloud Formation Stack.

                                              2. Select Resources tab from the top portion of the screen.

                                              3. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                              4. Select Enable from the top-right portion of the screen. This will enable the rule. You will re-enable it after the upgrade process is complete.

                                              1.2.10 - Appendices

                                              Additional references for the protector.

                                              1.2.10.1 - Sample Athena External Functions

                                              Sample Athena External Functions

                                              Method: Tokenization

                                              Type: ALPHA

                                               

                                              Athena Data Types

                                              Athena Max Size

                                              Protegrity Max Size

                                              VARCHAR

                                              65K (65,535 bytes)

                                              4K (4,096 bytes)

                                               

                                               

                                               

                                              External Function Sample Definitions:

                                              USING EXTERNAL FUNCTION protect(val varchar, el varchar) RETURNS varchar
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect('hello world!', 'deAlpha'); 
                                              
                                              USING EXTERNAL FUNCTION unprotect(val varchar, el varchar) RETURNS varchar
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect('UtfVk UHgcD!', 'deAlpha'); 
                                              

                                               

                                              Method: Tokenization

                                              Type: NUMERIC

                                               

                                              Athena Data Types

                                              Athena Max Size

                                              Protegrity Max Size

                                              DECIMAL

                                              4K (4,096 bytes)

                                              4K (4,096 bytes)

                                              INTEGER

                                              BIGINT

                                              DOUBLE

                                               

                                              External Function Sample Definitions:

                                              USING EXTERNAL FUNCTION protect(val INTEGER, el varchar) RETURNS INTEGER 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(1234, 'deInt4') as protected_int;
                                              
                                              USING EXTERNAL FUNCTION unprotect(val INTEGER, el varchar) RETURNS INTEGER 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(1626684183, 'deInt4') as clear_int;
                                              
                                              USING EXTERNAL FUNCTION protect(val BIGINT, el varchar) RETURNS BIGINT 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(2147483648, 'deInt8') as protected_int8;
                                              
                                              USING EXTERNAL FUNCTION unprotect(val BIGINT, el varchar) RETURNS BIGINT 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(-5629842771706374842, 'deInt8') as clear_int8;
                                              
                                              USING EXTERNAL FUNCTION protect(val decimal(3,2), el varchar) RETURNS decimal(3,2)
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(decimal '1.23', 'deDecimal') as protected_decimal;
                                              
                                              USING EXTERNAL FUNCTION unprotect(val decimal(3,2), el varchar) RETURNS decimal(3,2)
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(decimal '6.16', 'deDecimal') as clear_decimal;
                                              

                                              Method: Tokenization

                                              Type: Date YYYY-MM-DD

                                               

                                              Athena Data Types

                                              Athena Max Size

                                              Protegrity Max Size

                                              DATE (any supported format)

                                              10 bytes

                                              10 bytes

                                               

                                              External Function Sample Definitions:

                                              USING EXTERNAL FUNCTION protect(val DATE, el varchar) RETURNS DATE 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(DATE('2020-11-09'), 'deDate') as protected_date;
                                              
                                              USING EXTERNAL FUNCTION unprotect(val DATE, el varchar) RETURNS DATE 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(DATE('1283-09-22'), 'deDate') as clear_date;
                                              

                                               

                                               

                                              Method: Tokenization

                                              Type: DATETIME YYYY-MM-DD HH:mm:ss

                                               

                                              Athena Data Types

                                              Athena Max Size

                                              Protegrity Max Size

                                              TIMESTAMP

                                              29 bytes

                                              29 bytes

                                              External Function Sample Definitions:

                                              USING EXTERNAL FUNCTION protect(val TIMESTAMP, el varchar) RETURNS TIMESTAMP 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(timestamp '2020-11-09 02:02:03.123', 'deDOB') as protected_time; 
                                              
                                              USING EXTERNAL FUNCTION unprotect(val TIMESTAMP, el varchar) RETURNS TIMESTAMP 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(timestamp '1283-09-22 02:02:03.123', 'deDOB') as clear_time;
                                              

                                               

                                              Method: Encryption

                                              Type: AES

                                               

                                              Athena Data Types

                                              Athena Max Size

                                              Protegrity Max Size

                                              VARBINARY

                                               

                                               

                                               

                                              External Function Sample Definitions:

                                              USING EXTERNAL FUNCTION protect(val varbinary, el varchar) RETURNS varbinary 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT protect(CAST('protegrity' as varbinary), 'aes256'); 
                                              
                                              USING EXTERNAL FUNCTION unprotect(val varbinary, el varchar) RETURNS varbinary 
                                                   LAMBDA '<replace_with_athena_protect_function_name>:Production'
                                              SELECT unprotect(from_hex('a79fa1c1a21f84e0d00acd8b20cf020c'), 'aes256');
                                              

                                               

                                              1.2.10.2 - Installing the Policy Agent and Protector in Different AWS Accounts

                                              Example steps to install Agent in a different AWS account than the Protector

                                                The Policy Agent Lambda function and Protect Lambda functions can be installed in separate AWS accounts. However, additional configuration is required to authorize the Policy Agent to provision the security policy to a remote Protect Lambda function.

                                                Create Agent Lambda IAM policy

                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                2. From the AWS IAM console, select Policies > Create Policy.

                                                3. Select the JSON tab and copy the following snippet.

                                                  {
                                                    "Version": "2012-10-17",
                                                    "Statement": [
                                                      {
                                                        "Sid": "LambdaUpdateFunction",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                          "lambda:UpdateFunctionConfiguration"
                                                        ],
                                                        "Resource": [
                                                          "arn:aws:lambda:*:*:function:*"
                                                        ]
                                                      },
                                                      {
                                                        "Sid": "LambdaReadLayerVersion",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                          "lambda:GetLayerVersion",
                                                          "lambda:ListLayerVersions"
                                                        ],
                                                        "Resource": "*"
                                                      },
                                                      {
                                                        "Sid": "LambdaDeleteLayerVersion",
                                                        "Effect": "Allow",
                                                        "Action": "lambda:DeleteLayerVersion",
                                                        "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                                      },
                                                      {
                                                        "Sid": "LambdaPublishLayerVersion",
                                                        "Effect": "Allow",
                                                        "Action": "lambda:PublishLayerVersion",
                                                        "Resource": "arn:aws:lambda:*:*:layer:*"
                                                      },
                                                      {
                                                        "Sid": "S3GetObject",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                          "s3:GetObject"
                                                        ],
                                                        "Resource": "arn:aws:s3:::*/*"
                                                      },
                                                      {
                                                        "Sid": "S3PutObject",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                          "s3:PutObject"
                                                        ],
                                                        "Resource": "arn:aws:s3:::*/*"
                                                      },
                                                      {
                                                        "Sid": "LambdaGetConfiguration",
                                                        "Effect": "Allow",
                                                        "Action": [
                                                            "lambda:GetFunctionConfiguration"
                                                        ],
                                                        "Resource": [
                                                            "arn:aws:lambda:*:*:function:*"
                                                        ]
                                                      }
                                                    ]
                                                  }
                                                  
                                                4. Replace the wildcards (*) with the region, account, and resource name information where required.

                                                5. Select Review policy, type in the policy name, and confirm. Record policy name:

                                                  Agent Lambda Cross Account Policy Name: ___________________

                                                Create Policy Agent cross-account IAM Role

                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                2. From the AWS IAM console, select Roles > Create Role

                                                3. Select AWS Service > Lambda . Proceed to Permissions.

                                                4. Select Policy created in the step above. Proceed to Tags.

                                                5. Specify Tag, proceed to the final screen. Type in policy name and confirm. Record the name.

                                                  Policy Agent Cross Account IAM Role Name: ___________________

                                                Allow the Policy Agent Cross-Account Role to be Assumed by the Policy Agent IAM Role

                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                2. Navigate to the previously created IAM Role (Agent Lambda Cross-Account IAM Role Name).

                                                3. Navigate to Trust Relationships > Edit Trust Relationships.

                                                4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda IAM Execution Role ARN> with ARN of Agent Lambda IAM Role that was created in Agent Installation.

                                                  {
                                                    "Version": "2012-10-17",
                                                    "Statement": [
                                                      {
                                                        "Effect": "Allow",
                                                  
                                                     "Principal": {
                                                  
                                                              "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                  
                                                        },
                                                        "Action": "sts:AssumeRole"
                                                      }
                                                    ]
                                                  }
                                                  
                                                5. Click Update Trust Policy.

                                                Add Assume Role to the Policy Agent Execution IAM Role

                                                1. Login to the AWS account that hosts the Policy Agent.

                                                2. Navigate to the Agent Lambda IAM Execution Role that was created in Agent Installation.

                                                  {
                                                    "Version": "2012-10-17",
                                                    "Statement": [
                                                      {
                                                        "Effect": "Allow",
                                                  
                                                     "Principal": {
                                                  
                                                              "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                  
                                                        },
                                                        "Action": "sts:AssumeRole"
                                                      }
                                                    ]
                                                  }
                                                  
                                                3. Add Inline Policy.

                                                4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda Cross-Account IAM ARN> with the value recorded in Create Policy Agent cross-account IAM Role.

                                                  {
                                                    "Version": "2012-10-17",
                                                    "Statement": [
                                                      {
                                                        "Effect": "Allow",
                                                        "Action": [
                                                          "sts:AssumeRole"
                                                        ],
                                                        "Resource": "<Agent Lambda Cross-Account IAM  ARN>."
                                                      }
                                                    ]
                                                  }
                                                  
                                                5. When you are finished, choose Review Policy.

                                                6. On the Review policy page, type a Name, then choose Create Policy.

                                                Update the Policy Agent Lambda Configuration

                                                1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                2. Select Configuration tab | Environment variables.

                                                3. Select Edit and add the following environment variables with the value from Agent Lambda Cross-Account IAM ARN:

                                                  ParameterValue
                                                  AWS_ASSUME_ROLEAgent Lambda Cross-Account IAM ARN
                                                4. Ensure the values in the Parameters AWS_POLICY_S3_BUCKET, AWS_PROTECT_FN_NAME and AWS_POLICY_LAYER_NAME are all in the Protect Lambda Function AWS Account.

                                                5. In case custom VPC hostname configuration is used, you will need to set the ENDPOINT_URL. Refer to Policy Agent - Custom VPC Endpoint Hostname Configuration.

                                                  AWS_VPC_ENDPOINT_URL

                                                  <AWS_VPC_ENDPOINT>

                                                6. Click Save and Run the Lambda. The Lambda will now assume the Role in Protect Lambda Function AWS Account and update the policy cross accounts.

                                                1.2.10.3 - 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.2.10.4 - Security Recommendations

                                                    The following section provides recommendations on configuring Amazon Athena for querying PII Data protected by Protegrity Athena Protector.

                                                    Security is a shared responsibility between AWS and you. When using PII Data in Amazon Athena, it is essential to understand the best practices and keep your Data always protected. In this section, we summarize the configuration needed when using Amazon Athena.

                                                    To read more on Amazon Shared responsibility on Amazon Athena, visit Amazon Athena Security - Amazon Athena

                                                    Logging and Monitoring

                                                    Enable AWS CloudTrail to audit all calls made to Athena API.

                                                    For more information, visit Logging Amazon Athena API Calls with AWS CloudTrail - Amazon Athena .

                                                    Encryption at rest

                                                    AWS S3 buckets

                                                    Amazon Athena lets you run queries on encrypted data stored in Amazon S3 repositories in the same region. Make sure you enable Amazon S3 encryption options supported by Amazon Athena.

                                                    For more information, visit Creating Tables Based on Encrypted Datasets in Amazon S3 - Amazon Athena .

                                                    Query Results and Query History

                                                    Amazon Athena saves the query history in an S3 bucket. If you unprotect data using Amazon Athena Protector, Amazon Athena saves the results (the unprotected data) in an S3 bucket. The query history is viewable by anyone with IAM permissions on the bucket. To remediate, we suggest the following configurations.

                                                    Setting Amazon Athena Workgroup

                                                    You should set up the Amazon Athena Workgroup S3 staging directory and overwrite Client-side settings. It ensures all users comply with the S3 staging directory and encryption setting for the results. Restrict the IAM access to the bucket to the minimum required for Amazon Athena to work.

                                                    Amazon S3 lifecycle policy

                                                    Amazon Athena’s defaults configuration is to store the results for 45 days, and we suggest reducing it to the minimum (1 day) using the Amazon S3 lifecycle policy.

                                                    For more infromation, visit Working with Query Results, Output Files, and Query History - Amazon Athena

                                                    Encrypt Glue Catalog

                                                    Amazon Athena has integration with AWS Glue Data Catalog. If you use it, you can enable encryption in the AWS Glue Data Catalog. It doesn’t encrypt the data, only the Athena table definition. It provides another layer of security on where your data exists and what it includes.

                                                    For more information, visit Encrypting Your Data Catalog. Access from Athena to Encrypted Metadata in the AWS Glue Data Catalog - Amazon Athena.

                                                    Encryption in transit

                                                    To allow only encrypted connections with HTTPS (TLS), you can apply the aws:SecureTransport condition on S3 buckets IAM policies.

                                                    Access Control

                                                    Resources

                                                    Make sure you provide the least privilege access control to Amazon Athena workgroup, S3 buckets, Protegrity Protect Lambda function, AWS KMS (If used for data encryption at rest).

                                                    For more information, visit Identity and Access Management in Athena - Amazon Athena .

                                                    Granting access to use the Cloud Protect UDF

                                                    The ability to use the Cloud Protect UDF from Athena is controlled through IAM permissions. The Athena user/role must have the InvokeFunction permission to the Cloud Protect Lambda function as shown in the following example:

                                                    { 
                                                        "Version": "2012-10-17", 
                                                        "Statement": [ 
                                                          { 
                                                                "Sid": "ProtectLambdaFunction", 
                                                                "Effect": "Allow", 
                                                                "Action": "lambda:InvokeFunction", 
                                                                "Resource": "<PROTECT_FUNCTION_ARN>" 
                                                           } 
                                                        ] 
                                                    }
                                                    

                                                    The policy above would be used in addition to any other IAM policies required to use Amazon Athena. Refer to the AWS Athena example policy for a typical IAM policy.

                                                    Separate Workgroups

                                                    Create separate Workgroups based on the privacy controls. It provides more control on who can see the Query History and access unprotected data stored there.

                                                    For more information, visit Using Workgroups to Control Query Access and Costs - Amazon Athena .

                                                    AWS Lake Formation

                                                    Amazon Athena can benefit from AWS Lake Formation table and column access policies. It is another layer of security before Protegrity Protect Function and reduces unauthorized requests.

                                                    For more information, visit Using Athena to Query Data Registered With AWS Lake Formation - Amazon Athena .

                                                    1.2.10.5 - Policy Agent - Custom VPC Endpoint Hostname Configuration

                                                    Custom vpc endpoint hostname configuration

                                                    The Policy Agent uses default endpoint hostnames to communicate with other AWS services (for example, secretsmanager.amazonaws.com). This configuration will only work in VPCs where Amazon-provided DNS is available (default VPC configuration with private DNS option enabled for the endpoint). If your VPC uses custom DNS, follow the instructions below to configure the Policy Agent Lambda to use custom endpoint hostnames.

                                                    Identify DNS Hostnames

                                                    To identify DNS hostnames:

                                                    1. From AWS console, select VPC > Endpoints.

                                                    2. Select Secrets Manager endpoint from the list of endpoints.

                                                    3. Under Details > DNS Names, note the private endpoint DNS names adding https:// at the beginning of the endpoint name.

                                                      For example, https://vpce-1234-4pzomrye.kms.us-west-1.vpce.amazonaws.com

                                                    4. Note down DNS names for the KMS and Lambda endpoints:

                                                      AWS_SECRETSMANAGER_ENDPOINT: https://_________________

                                                      AWS_KMS_ENDPOINT: https://_________________

                                                      AWS_LAMBDA_ENDPOINT: https://_________________

                                                    Update the Policy Agent Lambda configuration

                                                    To update policy agent lambda configuration:

                                                    1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                    2. Select the Configuration section and choose Environment variables.

                                                    3. Select Edit and add the following environment variables with the corresponding endpoint URLs recorded in steps 3-4:

                                                      ParametersValue
                                                      AWS_SECRETSMANAGER_ENDPOINT_URL<AWS_SECRETS_ENDPOINT>
                                                      AWS_KMS_ENDPOINT_URL<AWS KMS ENDPOINT>
                                                      AWS_LAMBDA_ENDPOINT_URL<AWS LAMBDA ENDPOINT>
                                                    4. Click Save and Run the Lambda. The Lambda will now use endpoints you have just configured.

                                                    1.2.10.6 - 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.2.10.7 - Configuring Regular Expression to Extract Policy Username

                                                    Extract the policy username from the AWS identity.

                                                    Configuring Regular Expression to Extract Policy Username

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

                                                    • USERNAME_REGEX Lambda Environment configuration

                                                      The USERNAME_REGEX configuration can be used to extract policy username from user in the request. The following are allowed values for USERNAME_REGEX:

                                                      • 1 - Default build-in regular expression is used:

                                                        ^arn:aws:(?:iam|sts)::[0-9]{12}:(?:role|user|group|assumed\-role|federated\-user)\/([\w\/+=,.\-]{1,1024}|[\w\/+=,.\-@]{1,1024})(?:@[a-zA-Z0-9\-]{1,320}(?:\.\w+)+)?$
                                                        
                                                      • ^User regex$ - Custom regex 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

                                                    arn:aws:iam::123456789012:user/juliet.snow

                                                    arn:aws:iam::123456789012:user/juliet.snow

                                                    arn:aws:sts::123456789012:assumed-role/TestSaml

                                                    arn:aws:sts::123456789012:assumed-role/TestSaml

                                                    1

                                                    arn:aws:iam::123456789012:user/juliet.snow

                                                    juliet.snow

                                                    arn:aws:sts::123456789012:assumed-role/TestSaml

                                                    TestSaml

                                                    ^arn:aws:(?:iam|sts)::[0-9]{12}:((?:role|user|group|assumed-role|federated-user).*)$
                                                    

                                                    arn:aws:iam::123456789012:user/juliet.snow

                                                    user/juliet.snow

                                                    arn:aws:sts::123456789012:assumed-role/TestSaml

                                                    assumed-role/TestSaml

                                                    1.2.10.8 - Associating ESA Data Store With Cloud Protect Agent

                                                    Configure ESA data store for Policy Agent.

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

                                                    The Lambda service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range of the VPC subnet the Lambda is associated with. By default, when agent lambda is contacting ESA to register node for policy download, ESA uses agent Lambda VPC 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 lambda, 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 VPC subnet IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent lambda config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                                                    169.254.144.8110.1.2.173No Proxytrueyes169.254.144.81
                                                    trueno10.1.2.173
                                                    falseyes
                                                    falseno
                                                    169.254.144.8110.1.2.17334.230.42.110trueyes169.254.144.81
                                                    trueno34.230.42.110
                                                    falseyes
                                                    falseno

                                                    1.3 - Redshift

                                                    Protector for Amazon Redshift.

                                                    This section describes the high-level architecture of the product on AWS for integration with Amazon Redshift, the installation procedures, and provides guidance on performance. This section focuses on Protegrity-specific aspects and should be consumed with corresponding Redshift 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.3.1 - Overview

                                                    Solution overview and features.

                                                      Solution Overview

                                                      Amazon Redshift Protector is a cloud native, serverless product for fine-grained data protection with Redshift™, a managed Cloud data warehouse. This enables invocation of the Protegrity data protection cryptographic methods from the Redshift 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 Amazon Redshift. The UDFs act as a client transmitting micro-batches of data to the serverless Protegrity Lambda 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.

                                                      Amazon Redshift Protector 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 Redshift.
                                                      • 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 Redshift Protector on AWS service.

                                                      Features

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

                                                      • Fine grained field-level protection in the managed Cloud data warehouse
                                                      • 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.3.2 - Architecture

                                                      Deployment architecture and connectivity

                                                        Protector Deployment Architecture

                                                        The Protegrity product should be deployed in the customer’s Cloud account within the same AWS region as the Redshift cluster. The product incorporates Protegrity’s vaultless tokenization engine within an AWS Lambda Function. The encrypted data security policy from an ESA is deployed periodically as a static resource through an AWS Lambda Layer. The policy is decrypted in memory at runtime within the Lambda. 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 calls to the serverless Protegrity Lambda 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.

                                                        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 additional envelope encryption using Amazon KMS, and deploys the policy into the Lambda Layer used by the serverless product. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. The policy takes effect immediately for all new requests. There is no downtime for users during this process.

                                                        The following diagram shows the high-level architecture described above.

                                                        The following diagram shows a reference architecture for synchronizing the security policy from ESA.

                                                        The Protegrity Policy Agent requires network access to an Enterprise Security Administrator (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 Guide.

                                                        Log Forwarding Architecture

                                                        Audit logs are by default sent to CloudWatch as long as the function’s execution role has the necessary permissions. 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 Amazon Kinesis data stream and the forwarder Lambda function. Amazon Kinesis stream is used to batch audit records before sending them 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 Amazon Kinesis. Due to specifics of the Lambda runtime lifecycle, audit logs may take up to 15 minutes before being sent to Amazon Kinesis. Protector function exposes configuration to minimize this time 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 Amazon Kinesis 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 client certificate to authenticate calls to ESA.

                                                        To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instructions can be found in 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.

                                                        Redshift Connectivity

                                                        The AWS Redshift system is a cloud data warehouse Platform-as-a-Service (PaaS) from AWS. Unlike traditional (on-prem or customer-managed) data warehouses and RDBMS systems, Redshift is a fully managed, multi-tenant PaaS service, where the customers do not have the ability to install 3rd party software within the Redshift infrastructure.

                                                        Currently, the Redshift architecture does not allow installing Protegrity data protection UDFs and policy enforcement point (PEP) agents inside the Redshift infrastructure. Therefore, a remote-coupling integration mechanism where Redshift invokes RESTful APIs exposed by the Protegrity product is used.

                                                        Redshift supports remote invocations to the Protegrity infrastructure through External Functions, which in turn calls AWS Lambda.

                                                        Access and authorization between various AWS services involved in this architecture is achieved through Identity Access Management (IAM). For instance, Redshift is given an IAM role to call Lambda, Lambda is given an IAM role to call Secrets Manager, etc. Various IAM role configuration settings are shown in the appendices of this document.

                                                        The following figure illustrates the Protegrity Redshift Integration architecture.

                                                        1.3.2.1 -

                                                        Redshift Connectivity

                                                        The AWS Redshift system is a cloud data warehouse Platform-as-a-Service (PaaS) from AWS. Unlike traditional (on-prem or customer-managed) data warehouses and RDBMS systems, Redshift is a fully managed, multi-tenant PaaS service, where the customers do not have the ability to install 3rd party software within the Redshift infrastructure.

                                                        Currently, the Redshift architecture does not allow installing Protegrity data protection UDFs and policy enforcement point (PEP) agents inside the Redshift infrastructure. Therefore, a remote-coupling integration mechanism where Redshift invokes RESTful APIs exposed by the Protegrity product is used.

                                                        Redshift supports remote invocations to the Protegrity infrastructure through External Functions, which in turn calls AWS Lambda.

                                                        Access and authorization between various AWS services involved in this architecture is achieved through Identity Access Management (IAM). For instance, Redshift is given an IAM role to call Lambda, Lambda is given an IAM role to call Secrets Manager, etc. Various IAM role configuration settings are shown in the appendices of this document.

                                                        The following figure illustrates the Protegrity Redshift Integration architecture.

                                                        1.3.3 - Installation

                                                        Instructions for installing Protect Service, Policy Agent, and Log Forwarder.

                                                        1.3.3.1 - Prerequisites

                                                        Requirements before installing the protector.

                                                          AWS Services

                                                          The following table describes the AWS services that may be a part of your Protegrity installation.

                                                          Service

                                                          Description

                                                          Lambda

                                                          Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                                          KMS

                                                          Provides secrets for envelope policy encryption/decryption for Protegrity.

                                                          Secrets Manager

                                                          Provides secrets management for the ESA credentials.

                                                          S3

                                                          Intermediate storage location for the encrypted ESA policy layer.

                                                          Kinesis

                                                          Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                                          VPC & NAT Gateway

                                                          Optional. Provides a private subnet to communicate with an on-prem ESA.

                                                          CloudWatch

                                                          Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                                          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

                                                          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
                                                          AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                                          Redshift cluster (Enterprise Edition)Must be in the same region as Protegrity Protect Lambda

                                                          Required Skills and Abilities

                                                          RequirementsDescription
                                                          AWS Account AdministratorTo run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.
                                                          Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                                          Redshift AdministratorAccount Admin access required to setup access
                                                          Network AdministratorTo open firewall to access ESA and evaluate AWS network setup

                                                          What’s Next

                                                          1.3.3.2 - Pre-Configuration

                                                          Configuration steps before installing the protector.

                                                            Provide AWS sub-account

                                                            Identify or create an AWS account where the Protegrity solution will be installed. It is recommended that a new AWS sub-account be created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some subsequent installation steps.

                                                            AWS Account ID: ___________________

                                                            AWS Region (AwsRegion): ___________________

                                                            Determine AWS Region

                                                            Determine the AWS region where the Amazon Redshift cluster is running. This is the region in where the Protegrity solution must be installed.

                                                            AWS Region (AccountRegion): ___________________

                                                            Create S3 bucket for Installing Artifacts

                                                            This S3 bucket will be used for the artifacts required by the CloudFormation installation steps. This S3 bucket must be created in the region that is defined in Provide AWS sub-account

                                                            1. Sign in to the AWS Management Console and open the Amazon S3 console.

                                                            2. Change region to the one determined in Provide AWS sub-account

                                                            3. Click Create Bucket.

                                                            4. Enter a unique bucket name:

                                                              For example, protegrity-install.us-west-2.example.com

                                                            5. Upload the installation artifacts to this bucket. Protegrity will provide the following three artifacts:

                                                              • protegrity-protect-<version>.zip
                                                              • protegrity-agent-<version>.zip
                                                              • protegrity-external-extension-<version>.zip
                                                              • protegrity-sample-policy-<version>.zip

                                                              S3 Bucket name (ArtifactS3Bucket): ___________________

                                                            Create KMS Key

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

                                                            To create KMS key:

                                                            1. In the AWS sub-account where the KMS key will reside, select the region.

                                                            2. Navigate to Key Management Service > Create Key.

                                                            3. Configure the key settings:

                                                              • Key type: Asymmetric
                                                              • Key usage: Encrypt and decrypt
                                                              • Key spec: RSA_4096
                                                              • Click Next
                                                            4. Create alias and optional description, such as, Protegrity-Serverless and click Next.

                                                            5. Define key administrative permissions, the IAM user who will administrate the key.

                                                            6. Click Next.

                                                            7. Define the key usage permissions.

                                                            8. In Other AWS accounts, enter the AWS account id used for the Protegrity Serverless installation.

                                                            9. Continue on to create the key. If there is a concern this permission is overly broad, then you can return later to restrict access to the role of two Protegrity Serverless Lambda as principals. Click to open the key in the list and record the ARN.

                                                              KMS Key ARN (AWS_KMS_KEY_ID): ___________________

                                                            10. Download the public key from the KMS key. Navigate to the key in KMS console, select the Public key tab, and click Download. Save the PEM file. This public key will be added to the ESA data store as an export key. Refer to Exporting Keys to Datastore for instructions on adding the public key to the data store.

                                                              KMS Public Key PEM file: ___________________

                                                            Create IAM Account Role

                                                            An IAM role is used to authorize Redshift to access the future Protect Lambda resource.

                                                            To create IAM account role:

                                                            1. From the AWS console, access IAM, select Roles and then Create Role.

                                                            2. In Trusted entity type section, select AWS service

                                                            3. In Use case section, for Service or use case, select Redshift.

                                                            4. For Use case, select Redshift – Customizable.

                                                            5. Click Next to advance to Add Permissions step.

                                                            6. Click Next to skip Add Permissions step.

                                                            7. Enter a Role name, for example, RedshiftProtegrity.

                                                            8. Click Create role.

                                                            9. After the role is created, click on the role. Record the following information:

                                                              • Role Name (DBRoleName): ____________________
                                                              • Role ARN (DBRoleARN): ____________________

                                                            What’s Next

                                                            1.3.3.3 - Protect Service Installation

                                                            Install the protect service.

                                                              Preparation

                                                              1. Ensure that all the steps in Pre-Configuration are performed.

                                                              2. Login to the AWS account console where Amazon Redshift Protector will be installed.

                                                              3. Ensure that the required CloudFormation templates provided by Protegrity are available on your local computer.

                                                              Create Protect Lambda IAM Execution Policy

                                                              This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

                                                              Perform the following steps to create the Lambda execution role and required policies:

                                                              1. From the AWS IAM console, select Policies > Create Policy.

                                                              2. Select the JSON tab and copy the following sample policy.

                                                                {
                                                                  "Version": "2012-10-17",
                                                                  "Statement": [
                                                                    {
                                                                      "Sid": "CloudWatchWriteLogs",
                                                                      "Effect": "Allow",
                                                                      "Action": [
                                                                        "logs:CreateLogGroup",
                                                                        "logs:CreateLogStream",
                                                                        "logs:PutLogEvents"
                                                                      ],
                                                                      "Resource": "*"
                                                                    },
                                                                    {
                                                                      "Sid": "KmsDecrypt",
                                                                      "Effect": "Allow",
                                                                      "Action": [
                                                                        "kms:Decrypt"
                                                                      ],
                                                                      "Resource": [
                                                                        "arn:aws:kms:*:*:key/*"
                                                                      ]
                                                                    }
                                                                  ]
                                                                }
                                                                
                                                              3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                                              4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

                                                                ProtectLambdaPolicyName:__________________

                                                              Create Protect Lambda IAM Role

                                                              The following steps create the role to utilize the policy defined in Create Protect Lambda IAM Execution Policy.

                                                              To create protect lambda IAM execution role:

                                                              1. From the AWS IAM console, select Roles > Create Role.

                                                              2. Select AWS Service > Lambda > Next.

                                                              3. In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.

                                                              4. Click Next

                                                              5. Type the role name, for example, ProtegrityProtectRole

                                                              6. Click Create role

                                                              7. Record the role ARN.

                                                                Role ARN (LambdaExecutionRoleArn): ___________________

                                                              Install through CloudFormation

                                                              The following steps describe the deployment of the Lambda function.

                                                              To install through CloudFormation:

                                                              1. Access CloudFormation and select the target AWS Region in the console.

                                                              2. Click Create Stack and choose With new resources.

                                                              3. Specify the template.

                                                              4. Select Upload a template file.

                                                              5. Upload the Protegrity-provided CloudFormation template called pty_protect_cf.json and click Next.

                                                              6. Specify the stack details. Enter a stack name.

                                                              7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                                                                Parameter

                                                                Description

                                                                DBRoleName

                                                                Name of the account role created in the pre-configuration step

                                                                ArtifactS3Bucket

                                                                Name of S3 bucket created in the pre-configuration step

                                                                LambdaExecutionRoleArn

                                                                The ARN of Lambda role created in the prior step

                                                                MinLogLevel

                                                                Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                                                                UsernameRegex

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

                                                              8. If you are not planning to deploy log forwarder you can skip this step. The log forwarder parameters can be provided later after log forwarder is deployed.

                                                                Log Forwarder ParametersDescription
                                                                KinesisLogStreamArnThe ARN of the AWS Kinesis stream where audit logs will be sent for aggregation
                                                                AuditLogFlushIntervalTime interval in seconds used to accumulate audit logs before sending to Kinesis. Default value: 30. See Log Forwarder Performance section for more details.
                                                              9. Proceed to the last step of the Create Stack wizard with defaults and click Submit to create CloudFormation stack.

                                                              10. Select Outputs tab of the stack after stack is created.

                                                              11. Record the following values:

                                                                ProtectFunctionName: __________________________

                                                                ProtectFunctionProductionAlias: __________________________

                                                                ProtectLayerName: _____________________________

                                                              Protect Lambda Configuration

                                                              After CloudFormation stack is deployed, the Protect Lambda default configuration can be changed using Lambda environment configuration. See below for list of available configuration and instructions how to update it.

                                                              • List of Protect Lambda Environment Variables

                                                                Variable Name

                                                                Description

                                                                Notes

                                                                LOG_REDSHIFT_CLUSTER_ARN

                                                                When enabled, Redshift cluster ARN is recorded in CloudWatch audit log.

                                                                Set LOG_REDSHIFT_CLUSTER_ARN = 1 to enable.

                                                                See Audit Logging for audit log examples.

                                                              • Updating Lambda Configuration

                                                                From your AWS console, navigate to Lambda and select the following Lambda:

                                                                Protegrity_Protect_<STACK_NAME>

                                                                Select Configuration tab and scroll down to the Environment variables section. Select Edit then Add environment variable. For the list of allowed variables and corresponding values refer to the table above.

                                                              Delete API Gateway (Optional)

                                                              CloudFormation created an API Gateway that makes this product compatible with Snowflake. However, this service is not required for Amazon Redshift so it may be optionally removed.

                                                              To delete API Gateway:

                                                              1. From Services, access API Gateway.

                                                              2. Select the API Gateway service that is created.

                                                              3. Click Actions > Delete.

                                                              Add Lambda Protect IAM Permissions to Role

                                                              To add inline Lambda Protect IAM permissions to role:

                                                              1. Select the role created in section Create IAM Account Role (DBRoleName).

                                                              2. In the Permissions tab, click Add inline policy.

                                                              3. Select the JSON tab and copy the following sample policy.

                                                                {
                                                                  "Version": "2012-10-17",
                                                                  "Statement": [
                                                                    {
                                                                      "Sid": "ProtegrityProtectInvokePermission",
                                                                      "Effect": "Allow",
                                                                      "Action": "lambda:InvokeFunction",
                                                                      "Resource": "arn:aws:lambda:*:*:function:*"
                                                                    }
                                                                  ]
                                                                }
                                                                
                                                              4. Edit the Resource value in the snippet with the ARN of the Protect Lambda function to further restrict privileges.

                                                              Attach IAM Account Role to Redshift

                                                              Perform the following steps to allow Redshift to invoke the Protect Lambda function.

                                                              Attach the IAM role (DBRoleName) created in Create IAM Account Role to the Redshift cluster.

                                                              To attach IAM account role to Redshift:

                                                              1. From the AWS console, access Amazon Redshift and click on the cluster.

                                                              2. Select Actions > Manage IAM Roles.

                                                              3. Under Available IAM roles, select Enter ARN.

                                                              4. Enter the Role ARN recorded in Create Protect Lambda IAM Role.

                                                              5. Click Add IAM role.

                                                              Test Connectivity

                                                              Perform the following steps to verify if Redshift is working correctly with the Protegrity product.

                                                              To test the connectivity:

                                                              1. Access the Redshift SQL console.

                                                              2. Copy and paste the following snippet into a worksheet.

                                                                CREATE OR REPLACE EXTERNAL FUNCTION pty_unprotect_alpha(varchar) RETURNS varchar
                                                                VOLATILE lambda '<replace_with_protect_function_name>:Production' iam_role 'arn:aws:iam::<you-awsaccount-
                                                                number>:role/<role-name>
                                                                
                                                              3. Replace the placeholder values with the lambda function name and role created in earlier steps.

                                                              4. Run the following command in the console:

                                                                select pty_unprotect_alpha('UtfVk UHgcD!')
                                                                
                                                              5. Verify that the string hello world! is returned.

                                                              Troubleshooting Tips

                                                              Error

                                                              Action

                                                              Empty result or Invalid operation error

                                                              1. If a permission exception occurred, please make sure the Redshift cluster was not in modification status when performing the step in the prior step. Try again.

                                                              2. Try running the Lambda directly. Open the Lambda function and create the following test case.

                                                                {
                                                                  "user": "test",
                                                                  "arguments": [
                                                                    [
                                                                      "UtfVk UHgcD!"
                                                                    ]
                                                                  ],
                                                                  "query_id": 0,
                                                                  "external_function": "pty_unprotect_alpha"
                                                                }
                                                                
                                                              3. If this step fails, please check the console for meaningful error. If the step succeeds, the installation is correct.

                                                              4. Please recheck all the IAM configuration steps above.

                                                              What’s Next

                                                              1.3.3.4 - Policy Agent Installation

                                                              Install the policy agent.

                                                                The following sections will install the Policy Agent. The Policy Agent polls the ESA and deploys the policy to Protegrity Serverless as a static resource. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity Professional Services for further guidance on configuration alternatives in the Cloud.

                                                                ESA Server

                                                                Policy Agent Lambda requires ESA server running and accessible on TCP port 443.

                                                                Note down ESA IP address:

                                                                ESA IP Address (EsaIpAddress): ___________________

                                                                Certificates on ESA

                                                                Whether your ESA is configured with default self-signed certificate or your corporate CA certificate, Policy Agent can validate authenticity of ESA connection using CA certificate. The process for both scenarios is the same:

                                                                • Obtain CA certificate
                                                                • Convert CA certificate to a value accepted by Policy Agent
                                                                • Provide converted CA certificate value to Policy Agent

                                                                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. To convert downloaded CA certificate to a value accepted by Policy Agent, open the downloaded 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 or PTY_ESA_CA_SERVER_CERT_SECRET Lambda variable in section Policy Agent Lambda Configuration

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

                                                                Identify or Create a new VPC

                                                                Establish a VPC where the Policy Agent will be hosted. This VPC will need connectivity to the ESA. The VPC should be in the same account and region established in Pre-Configuration.

                                                                VPC name: ___________________

                                                                VPC Subnet Configuration

                                                                Identify or create a new subnet in the VPC where tha Lambda function will be connected to. It is recommended to use a private subnet.

                                                                Subnet name: ___________________

                                                                NAT Gateway For ESA Hosted Outside AWS Network

                                                                If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                                                VPC Endpoints Configuration

                                                                If an internal VPC was created, then add VPC Endpoints, which will be used by the Policy Agent to access AWS services. Policy Agent needs access to the following AWS services:

                                                                Type

                                                                Service name

                                                                Interface

                                                                com.amazonaws.{REGION}.secretsmanager

                                                                Interface

                                                                com.amazonaws.{REGION}.kms

                                                                Gateway

                                                                com.amazonaws.{REGION}.s3

                                                                Interface

                                                                com.amazonaws.{REGION}.lambda

                                                                Identify or Create Security Groups

                                                                Policy Agent and cloud-based ESA appliance use AWS security groups to control traffic that is allowed to leave and reach them. Policy Agent runs on schedule and is mostly concerned with allowing traffic out of itself to ESA and AWS services it depends on. ESA runs most of the time and it must allow Policy Agent to connect to it.

                                                                Policy Agent security group must allow outbound traffic using rules described in the table below. To edit security group navigate:

                                                                From VPC > Security Groups > Policy Agent Security Group configuration.

                                                                TypeProtocolPort RangeDestinationReason
                                                                Custom TCPTCP443Policy Agent Lambda SGESA Communication
                                                                HTTPSTCP443AnyAWS Services

                                                                Record Policy Agent security group ID:

                                                                Policy Agent Security Group Id: ___________________

                                                                Policy Agent will reach out to ESA on port 443. Create following inbound security group rule for cloud-based ESA appliance to allow connections from Policy Agent:

                                                                TypeProtocolPort RangeSource
                                                                Custom TCPTCP443Policy Agent Lambda SG

                                                                Creating ESA Credentials

                                                                Policy Agent Lambda requires ESA credentials to be provided as one of the three options.

                                                                Option 1: Secrets Manager

                                                                Creating secrets manager secret with ESA username and password.

                                                                1. From the AWS Secrets Manager Console, select Store New Secret.

                                                                2. Select Other Type of Secrets.

                                                                3. Specify the username and password key value pair.

                                                                4. Select the encryption key or leave default AWS managed key.

                                                                5. Specify the Secret Name and record it.

                                                                  ESA Credentials Secret Name: __________________

                                                                Option 2: KMS Encrypted Password

                                                                ESA password is encrypted with AWS KMS symmetric key.

                                                                1. Create AWS KMS symmetric key which will be used to encrypt ESA password. See Create KMS Key for instructions on how to create KMS symmetric key using AWS console.

                                                                2. Record KMS Key ARN.

                                                                  ESA PASSWORD KMS KEY ARN: __________________

                                                                3. Run AWS CLI command to encrypt ESA password. Below you can find sample Linux aws cli command. Replace <key_arn> with KMS symmetric key ARN.

                                                                  aws kms encrypt --key-id <key_arn> --plaintext $(echo '<esa_password>' | base64 )
                                                                  
                                                                4. Sample output.

                                                                  {
                                                                    "CiphertextBlob": "esa_encrypted_password",
                                                                    "KeyId": "arn:aws:kms:region:aws_account:key/key_id ",
                                                                    "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
                                                                  }
                                                                  
                                                                5. Record ESA username and encrypted password.

                                                                  ESA USERNAME: __________________

                                                                  ESA ENCRYPTED PASSWORD: __________________

                                                                Option 3: Custom AWS Lambda function

                                                                With this option ESA username and password are returned by a custom AWS Lambda function. This method may be used to get the username and password from external vaults.

                                                                1. Create AWS Lambda in any AWS supported runtime.

                                                                  1. There is no input needed.

                                                                  2. The Lambda function must return the following response schema.

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

                                                                    For example,

                                                                    example output: {"username": "admin", "password": "Password1234"}
                                                                    
                                                                  3. Sample AWS Lambda function in Python:

                                                                    import json
                                                                    
                                                                    def lambda_handler(event, context):
                                                                    
                                                                        return {"username": "admin", "password": "password1234"}
                                                                    
                                                                2. Record the Lambda name:

                                                                  Custom AWS lambda for ESA credentials: _______________

                                                                Create Agent Lambda IAM Policy

                                                                Follow the steps below to create Lambda execution policies.

                                                                Create Agent Lambda IAM policy

                                                                1. From AWS IAM console, select Policies > Create Policy.

                                                                2. Select JSON tab and copy the following snippet.

                                                                  {
                                                                    "Version": "2012-10-17",
                                                                    "Statement": [
                                                                      {
                                                                        "Sid": "EC2ModifyNetworkInterfaces",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "ec2:CreateNetworkInterface",
                                                                          "ec2:DescribeNetworkInterfaces",
                                                                          "ec2:DeleteNetworkInterface"
                                                                        ],
                                                                        "Resource": "*"
                                                                      },
                                                                      {
                                                                        "Sid": "CloudWatchWriteLogs",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "logs:CreateLogGroup",
                                                                          "logs:CreateLogStream",
                                                                          "logs:PutLogEvents"
                                                                        ],
                                                                        "Resource": "*"
                                                                      },
                                                                      {
                                                                        "Sid": "LambdaUpdateFunction",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "lambda:UpdateFunctionConfiguration"
                                                                        ],
                                                                        "Resource": [
                                                                          "arn:aws:lambda:*:*:function:*"
                                                                        ]
                                                                      },
                                                                      {
                                                                        "Sid": "LambdaReadLayerVersion",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "lambda:GetLayerVersion",
                                                                          "lambda:ListLayerVersions"
                                                                        ],
                                                                        "Resource": "*"
                                                                      },
                                                                      {
                                                                        "Sid": "LambdaDeleteLayerVersion",
                                                                        "Effect": "Allow",
                                                                        "Action": "lambda:DeleteLayerVersion",
                                                                        "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                                                      },
                                                                      {
                                                                        "Sid": "LambdaPublishLayerVersion",
                                                                        "Effect": "Allow",
                                                                        "Action": "lambda:PublishLayerVersion",
                                                                        "Resource": "arn:aws:lambda:*:*:layer:*"
                                                                      },
                                                                      {
                                                                        "Sid": "S3GetObject",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "s3:GetObject"
                                                                        ],
                                                                        "Resource": "arn:aws:s3:::*/*"
                                                                      },
                                                                      {
                                                                        "Sid": "S3PutObject",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "s3:PutObject"
                                                                        ],
                                                                        "Resource": "arn:aws:s3:::*/*"
                                                                      },
                                                                      {
                                                                        "Sid": "KmsEncrypt",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "kms:GetPublicKey"
                                                                        ],
                                                                        "Resource": [
                                                                          "arn:aws:kms:*:*:key/*"
                                                                        ]
                                                                      },
                                                                      {
                                                                        "Sid": "SecretsManagerGetSecret",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                          "secretsmanager:GetSecretValue"
                                                                        ],
                                                                        "Resource": [
                                                                          "arn:aws:secretsmanager:*:*:secret:*"
                                                                        ]
                                                                      },
                                                                      {
                                                                        "Sid": "LambdaGetConfiguration",
                                                                        "Effect": "Allow",
                                                                        "Action": [
                                                                            "lambda:GetFunctionConfiguration"
                                                                        ],
                                                                        "Resource": [
                                                                            "arn:aws:lambda:*:*:function:*"
                                                                        ]
                                                                      }
                                                                    ]
                                                                  }
                                                                  
                                                                3. Replace wildcard * with the region, account, and resource name information where required.

                                                                4. This step is required if KMS is used to encrypt ESA password.

                                                                  Add policy entry below. Replace ESA PASSWORD KMS KEY ARN with the value recorded in Option 2: KMS Encrypted Password.

                                                                  
                                                                    {
                                                                      "Sid": "KmsDecryptEsaPassword",
                                                                      "Effect": "Allow",
                                                                      "Action": [
                                                                        "kms:Decrypt"
                                                                      ],
                                                                      "Resource": [
                                                                        "**ESA PASSWORD KMS KEY ARN**"
                                                                      ]
                                                                    }
                                                                  
                                                                5. Select Next type in the policy name and Create Policy. Record policy name:

                                                                  Policy Name: ___________________

                                                                Create Agent Lambda IAM Role

                                                                Perform the following steps to create Agent Lambda execution IAM role.

                                                                To create agent Lambda IAM role:

                                                                1. From AWS IAM console, select Roles > Create Role.

                                                                2. Select AWS Service > Lambda > Next.

                                                                3. Select the policy created in Create Agent Lambda IAM policy.

                                                                4. Proceed to Name, Review and Create.

                                                                5. Type the role name, for example, ProtegrityAgentRole and click Confirm.

                                                                6. Select Create role.

                                                                7. Record the role ARN.

                                                                  Agent Lambda IAM Execution Role Name: ___________________

                                                                Corporate Firewall Configuration

                                                                If an on-premise firewall is used, then the firewall must allow access from the NAT Gateway to an ESA. The firewall must allow access from the NAT Gateway IP to ESA via port 443 and 443.

                                                                CloudFormation Installation

                                                                Create the Policy Agent in the VPC using the CloudFormation script provided by Protegrity.

                                                                1. Access the CloudFormation service.

                                                                2. Select the target installation region.

                                                                3. Create a stack with new resources.

                                                                4. Upload the Policy Agent CloudFormation template (file name: pty_agent_cf.json).

                                                                5. Specify the following parameters for Cloud Formation:

                                                                  ParameterDescriptionNote
                                                                  VPCVPC where the Policy Agent will be hostedIdentify or Create a new VPC
                                                                  SubnetSubnet where the Policy Agent will be hostedVPC Subnet Configuration
                                                                  PolicyAgentSecurityGroupIdSecurity Group Id, which allows communication between the Policy Agent and the ESAIdentify or Create Security Groups
                                                                  LambdaExecutionRoleArnAgent Lambda IAM execution role ARN allowing access to the S3 bucket, KMS encryption Key, Lambda and Lambda LayerCreate Agent Lambda IAM Role
                                                                  ArtifactS3BucketS3 bucket name with deployment package for the Policy AgentUse S3 Bucket name recorded in Create S3 bucket for Installing Artifacts
                                                                  CreateCRONJobSet to True to create a CloudWatch schedule for the agent to run.Default: False

                                                                Policy Agent Lambda Configuration

                                                                After the CloudFormation stack is deployed, the Policy Agent Lambda must be configured with parameters recorded in earlier steps. From your AWS Console, navigate to lambda and select the following Lambda.

                                                                Protegrity_Agent<STACK_NAME>_

                                                                Select Configuration tab and scroll down to the Environment variables section. Select Editand replace all entries with the actual values.

                                                                Parameter

                                                                Description

                                                                Notes

                                                                PTY_ESA_IP

                                                                ESA IP address or hostname

                                                                ESA Server

                                                                PTY_ESA_CA_SERVER_CERT

                                                                ESA self-signed CA certificate or your corporate CA certificate used by policy Agent Lambda 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.

                                                                PTY_ESA_CA_SERVER_CERT_SECRET

                                                                This configuration option fulfills the same function as PTY_ESA_CA_SERVER_CERT but supports larger configuration values, making it the recommended choice. The value should specify the name of the AWS Secrets Manager secret containing the ESA self-signed CA certificate. The secret value should be set to the json with “PTY_ESA_CA_SERVER_CERT” key and PEM formated CA certificate content value as shown below.

                                                                {
                                                                  "PTY_ESA_CA_SERVER_CERT":"-----BEGIN CERTIFICATE----- MIIF..."
                                                                }
                                                                

                                                                Recorded in step Certificates on ESA

                                                                In case ESA is configured with publicly signed certificates, the PTY_ESA_CA_SERVER_CERT_SECRET configuration will be ignored. When both PTY_ESA_CA_SERVER_CERT and PTY_ESA_CA_SERVER_CERT_SECRET are configured the PTY_ESA_CA_SERVER_CERT_SECRET takes precedence.

                                                                PTY_ESA_CREDENTIALS_SECRET

                                                                ESA username and password (encrypted value by AWS Secrets Manager)

                                                                Option 1: Secrets Manager

                                                                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.

                                                                AWS_KMS_KEY_ID

                                                                KMS key id or full ARN e.g. arn:aws:kms:us-west-2:112233445566:key/bfb6c4fb-509a-43ac-b0aa-82f1ca0b52d3

                                                                Create KMS Key

                                                                AWS_POLICY_S3_BUCKET

                                                                S3 bucket where the encrypted policy will be written

                                                                S3 bucket of your choice

                                                                AWS_POLICY_S3_FILENAME

                                                                Filename of the encrypted policy stored in S3 bucket

                                                                Default: protegrity-policy.zip

                                                                AWS_PROTECT_FN_NAME

                                                                Comma separated list of Protect function names or ARNs

                                                                ProtectFunctionName(s), recorded in CloudFormation Installation

                                                                DISABLE_DEPLOY

                                                                This flag can be either 1 or 0. If set to 1, then the agent will not update PTY_PROTECT lambda with the newest policy. Else, the policy will be saved in the S3 bucket and deployed to the Lambda Layer

                                                                Default: 0

                                                                AWS_POLICY_LAYER_NAME

                                                                Lambda layer used to store the Protegrity policy used by the PTY_PROTECT function

                                                                 

                                                                POLICY_LAYER_RETAIN

                                                                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: 2

                                                                POLICY_PULL_TIMEOUT

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

                                                                Default: 20s

                                                                ESA_CONNECTION_TIMEOUT

                                                                Time in seconds to wait for the ESA response

                                                                Default: 5s

                                                                LOG_LEVEL

                                                                Application and audit logs verbiage level

                                                                Default: INFO

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

                                                                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

                                                                PTY_CORE_CASESENSITIVE

                                                                Specifies whether policy usernames should be case sensitive

                                                                Default: no

                                                                Allowed values:

                                                                yes

                                                                no

                                                                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_ESA_USERNAME

                                                                Plaintext ESA username which is used together with PTY_ESA_ENCRYPTED_PASSWORD as an optional ESA credentials

                                                                Option 2: KMS Encrypted Password

                                                                Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                                                PTY_ESA_ENCRYPTED_PASSWORD

                                                                ESA password encrypted with KMS symmetric key.

                                                                Example AWS cli command to generate the value:

                                                                aws kms encrypt --key-id <your key ARN> --plaintext '<your-esa-password-base64>'

                                                                Option 2: KMS Encrypted Password

                                                                Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                                                Value must be base64 encoded

                                                                EMPTY_POLICY_S3

                                                                This flag can be either 1 or 0. If set to 1, then the agent will remove the content of the policy file in S3 bucket, but will keep the checksum in the metadata. Else, the policy will be saved in the S3 bucket and not removed.

                                                                Default: 0

                                                                PTY_ESA_CREDENTIALS_LAMBDA

                                                                Lambda function to return ESA credentials

                                                                Recorded in step Option 3: Custom AWS Lambda function LAMBDA FOR ESA CREDENTIALS. Presence of PTY_ESA_USERNAME, or PTY_ESA_CREDENTIALS_SECRET will cause this value to be ignored.

                                                                The Policy Agent Lambda must have network access and IAM permissions to invoke the custom ESA Credentials Lambda you have created in Option 3: Custom AWS Lambda function.

                                                                Test Installation

                                                                Open the Lambda and configure Test to execute the lambda and specify the default test event. Wait for around 20 seconds for the Lambda to complete. If policy is downloaded successfully, then a success message appears.

                                                                Navigate to the AWS_POLICY_S3_BUCKET bucket and verify that the AWS_POLICY_S3_FILENAME file was created.

                                                                Troubleshooting

                                                                Lambda Error

                                                                Example Error

                                                                Action

                                                                Task timed out after x seconds

                                                                2020-10-06T23:40:54.121Z 2dc84942-b5cc-4be9-aa4c-965f322307e4 Task timed out after 90.09 seconds
                                                                
                                                                1. Ensure that there is network connectivity between the Lambda and ESA. Check the Security groups and/or Network firewall configuration
                                                                2. When using internal VPC, AWS Lambda needs to have access to AWS Network. The Policy Agent Lambda can start using Secrets Manager with Amazon VPC endpoints by creating an Amazon VPC endpoint for Secrets Manager.

                                                                ESA connection error. Failed to download certificates

                                                                Policy Pull takes a long time

                                                                {
                                                                  "errorMessage": "Timeout! Unable to download policy in 20 seconds.",
                                                                  "errorType": "Exception",
                                                                  "stackTrace": [...]
                                                                }
                                                                
                                                                1. Increase POLICY_PULL_TIMEOUT.
                                                                2. Ensure that there is at least 1 policy with datastore matching the Lambda Policy Agent. Other considerations:
                                                                  1. Policy has default datastore.
                                                                  2. Policy has datastores matching AWS lambda IP range (check the subnet IP Range).
                                                                  3. Lambda function has static IP, and at least one Data store has matching IP.

                                                                ESA connection error. Failed to download certificates. HTTP response code: 401

                                                                {
                                                                  "errorMessage": "ESA connection error. Failed to download certificates. HTTP response code: 401.",
                                                                  "errorType": "ConnectionError",
                                                                  "stackTrace": [...]
                                                                }
                                                                

                                                                Ensure that the PTY_ESA_CREDENTIALS_SECRET has correct ESA username and password

                                                                An error occurred (AccessDeniedException) when calling xyz operation

                                                                xyz Access Denied: Exception
                                                                Traceback (most recent call last):
                                                                  … Exception: xyz Access Denied
                                                                

                                                                Ensure that the Lambda execution role has permission to call the xyz operation

                                                                Access Denied to Secret Manager.

                                                                Secrets Manager Access Denied: Exception
                                                                Traceback (most recent call last):
                                                                  … Exception: Secrets Manager Access Denied
                                                                
                                                                1. Ensure that the Lambda execution role has permissions to get the Secret Manager secret name.
                                                                2. Ensure that the Lambda execution role has permission to get the Secret Manager secret Encryption Key.

                                                                Master Key xyz unable to generate data key

                                                                Ensure that the Lambda can access xyz CMK key

                                                                The S3 bucket server-side encryption is enabled, the encryption key type is SSE-KMS but the Policy Agent execution IAM role doesn’t have permissions to encrypt using the KMS key .

                                                                [ERROR] PolicyAgentException: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
                                                                

                                                                Add the following permissions to the Policy Agent excution role.

                                                                kms:Decrypt
                                                                kms:GenerateDatakey
                                                                

                                                                The S3 bucket has bucket policy to only allow access from within the VPC.

                                                                An error occurred (AccessDeniedException) when calling the PublishLayerVersion operation: Your access has been denied by S3,
                                                                please make sure your request credentials have permission to GetObject for BUCKET_NAME/FILENAME. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
                                                                

                                                                The Policy Agent publishes a new Lambda Layer version, and the Lambda Layer service uploads the policy file from the s3 bucket and the upload request is originated from the AWS service outside the Policy Agent Lambda VPC. Update the S3 bucket resource policy to allow access from AWS Service. Sample security policy to lock down access to the vpc:

                                                                {
                                                                  "Version": "2012-10-17",
                                                                  "Statement": [
                                                                    {
                                                                      "Sid": "VpcRestrictions",
                                                                      "Effect": "Deny",
                                                                      "Principal": {
                                                                        "AWS": "*"
                                                                      },
                                                                      "Action": "s3:*Object",
                                                                      "Resource": [
                                                                        "arn:aws:s3:::<s3_bucket_name>/*",
                                                                        "arn:aws:s3:::<s3_bucket_name>"
                                                                      ],
                                                                      "Condition": {
                                                                        "Bool": {
                                                                          "aws:ViaAWSService": "false"
                                                                        },
                                                                        "StringNotEquals": {
                                                                          "aws:sourceVpc": "<vpc_id>"
                                                                        }
                                                                      }
                                                                    }
                                                                  ]
                                                                }
                                                                

                                                                Additional Configuration

                                                                Strengthen the KMS IAM policy by granting access only to the required Lambda function(s).

                                                                Finalize the IAM policy for the Lambda Execution Role. Ensure to replace wildcard * with the region, account, and resource name information where required.

                                                                For example,

                                                                "arn:aws:lambda:*:*:function:*" -> "arn:aws:lambda:us-east-1:account:function:function_name"
                                                                

                                                                Policy Agent Schedule

                                                                If specified in CloudFormation Installation, the agent installation created a CloudWatch event rule, which checks for policy update on an hourly schedule. This schedule can be altered to the required frequency.

                                                                Under CloudWatch > Events > Rules, find Protegrity_Agent_{stack_name}. Click Action > Edit Set the cron expression. A cron expression can easily be defined using CronMaker, a free online tool. Refer to http://www.cronmaker.com.

                                                                What’s Next

                                                                1.3.3.5 - Audit Log Forwarder Installation

                                                                Install the audit log forwarder.

                                                                  The following sections show steps how to install Audit Log Forwarder component in the AWS Cloud. The Log Forwarder deployment allows for the audit logs generated by Protector to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protector Service to work properly. See Log Forwarding Architecture section in this document for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. C ontact Protegrity for further guidance on configuration alternatives in the Cloud.

                                                                  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 (Audit Store) or 24284 (td-agent).

                                                                  2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                  3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                  Certificates on ESA

                                                                  By default, ESA is configured with self-signed certificates, which can optionally be validated using a self-signed CA certificate supplied in the Log Forwarder configuration. If no CA certificate is provided, the Log Forwarder will skip server certificate validation.

                                                                  If ESA is configured with publicly signed certificates, this section can be skipped since the forwarder Lambda will use the public CA to validate ESA certificates.

                                                                  To obtain the 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 PtyEsaCaServerCert cloudformation parameter in section Install through CloudFormation

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

                                                                  AWS VPC Configuration

                                                                  Log forwarder Lambda function requires network connectivity to ESA, similar to Policy Agent Lambda function. Therefore, it can be hosted in the same VPC as Policy Agent.

                                                                  Separate VPC can be used, as long as it provides network connectivity to ESA.

                                                                  VPC Name: ___________________

                                                                  VPC Subnet Configuration

                                                                  Log Forwarder can be connected to the same subnet as Policy Agent or separate one as long as it provides connectivity to ESA.

                                                                  Subnet Name: ___________________

                                                                  NAT Gateway For ESA Hosted Outside AWS Network

                                                                  If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                                                  VPC Endpoint Configuration

                                                                  Log Forwarder Lambda function requires connectivity to Secrets Manager AWS service. If the VPC identified in the steps before has no connectivity to public internet through the NAT Gateway, then the following service endpoint must be configured:

                                                                  • com.amazonaws.{REGION}.cloudwatch
                                                                  • com.amazonaws.{REGION}.secretsmanager
                                                                  • com.amazonaws.{REGION}.kms

                                                                  Security Group Configuration

                                                                  Security groups restrict communication between Log Forwarder Lambda function and the ESA appliance. The following rules must be in place for ESA and Log Forwarder Lambda function.

                                                                  From VPC > Security Groups > Log Forwarder Security Group configuration.

                                                                  TypeProtocolPort RangeDestinationReason
                                                                  Custom TCPTCP9200Log Forwarder Lambda SGESA Communication

                                                                  Record the name of Log Forwarder security group name.

                                                                  Log Forwarder Security Group Id: ___________________

                                                                  The following port must be open for the ESA. If the ESA is running in the Cloud, then create the following security.

                                                                  ESA Security Group configuration

                                                                  TypeProtocolPort RangeSource
                                                                  Custom TCPTCP9200Log Forwarder Lambda SG

                                                                  Configure ESA Audit Store Credentials

                                                                  Audit Log Forwarder can optionally authenticate with ESA using certificate-based authentication with a client certificate and certificate key. If used, both the certificate and certificate key will be stored in AWS Secrets Manager.

                                                                  Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                                                  • client.key
                                                                  • client.pem

                                                                  After certificates are downloaded, open each 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 commands below depending on your operating system.

                                                                  Linux Bash:

                                                                  awk 'NF {printf "%s\\n",$0;}' client.key > private_key.txt
                                                                  awk 'NF {printf "%s\\n",$0;}' client.pem > public_key.txt
                                                                  

                                                                  Windows PowerShell:

                                                                  (Get-Content '.\client.key') -join '\n' | Set-Content 'private_key.pem'
                                                                  (Get-Content '.\client.pem') -join '\n' | Set-Content 'public_key.pem'
                                                                  

                                                                  For more information on how to configure client certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                                                  To create secret with ESA client certificate/key pair in AWS Secrets Manager.

                                                                  1. From the AWS Secrets Manager Console, select Store New Secret.

                                                                  2. Select Other Type of Secrets.

                                                                  3. Specify the private_key and public_key value pair.

                                                                  4. Select the encryption key or leave default AWS managed key.

                                                                  5. Specify the Secret Name and record it below.

                                                                    ESA Client Certificate/Key Pair Secret Name: ___________________

                                                                    This value will be used to set PtyEsaClientCertificatesSecretId cloudformation parameter in section Install through CloudFormation

                                                                  Create Audit Log Forwarder IAM Execution Policy

                                                                  This task defines a policy used by the Protegrity Log Forwarder Lambda function to write CloudWatch logs, access the KMS encryption key to decrypt the policy and access Secrets Manager for log forwarder user credentials.

                                                                  Perform the following steps to create the Lambda execution role and required policies:

                                                                  1. From the AWS IAM console, select Policies > Create Policy.

                                                                  2. Select the JSON tab and copy the following sample policy.

                                                                    {
                                                                      "Version": "2012-10-17",
                                                                      "Statement": [
                                                                        {
                                                                          "Sid": "EC2ModifyNetworkInterfaces",
                                                                          "Effect": "Allow",
                                                                          "Action": [
                                                                            "ec2:CreateNetworkInterface",
                                                                            "ec2:DescribeNetworkInterfaces",
                                                                            "ec2:DeleteNetworkInterface"
                                                                          ],
                                                                          "Resource": "*"
                                                                        },
                                                                        {
                                                                          "Sid": "CloudWatchWriteLogs",
                                                                          "Effect": "Allow",
                                                                          "Action": [
                                                                            "logs:CreateLogGroup",
                                                                            "logs:CreateLogStream",
                                                                            "logs:PutLogEvents"
                                                                          ],
                                                                          "Resource": "*"
                                                                        },
                                                                        {
                                                                          "Sid": "KmsDecrypt",
                                                                          "Effect": "Allow",
                                                                          "Action": [
                                                                            "kms:Decrypt"
                                                                          ],
                                                                          "Resource": [
                                                                            "arn:aws:kms:*:*:key/*"
                                                                          ]
                                                                        },
                                                                        {
                                                                            "Sid": "KinesisStreamRead",
                                                                            "Effect": "Allow",
                                                                            "Action": [
                                                                                "kinesis:GetRecords",
                                                                                "kinesis:GetShardIterator",
                                                                                "kinesis:DescribeStream",
                                                                                "kinesis:DescribeStreamSummary",
                                                                                "kinesis:ListShards",
                                                                                "kinesis:ListStreams"
                                                                            ],
                                                                            "Resource": "*"
                                                                        },
                                                                        {
                                                                          "Sid": "SecretsManagerGetSecret",
                                                                          "Effect": "Allow",
                                                                          "Action": [
                                                                            "secretsmanager:GetSecretValue"
                                                                          ],
                                                                          "Resource": [
                                                                            "arn:aws:secretsmanager:*:*:secret:*"
                                                                          ]
                                                                        }
                                                                      ]
                                                                    }
                                                                    
                                                                  3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                                                  4. Select Review policy, type in a policy name, for example, ProtegrityLogForwarderLambdaPolicy and Confirm. Record the policy name:

                                                                    LogForwarderLambdaPolicyName:__________________

                                                                  Create Log Forwarder IAM Role

                                                                  Perform the following steps to create Log Forwarder execution IAM role.

                                                                  To create Log Forwarder IAM role:

                                                                  1. From AWS IAM console, select Roles > Create Role.

                                                                  2. Select AWS Service > Lambda > Next.

                                                                  3. Select the policy created in Create Audit Log Forwarder IAM Execution Policy.

                                                                  4. Proceed to Name, Review and Create.

                                                                  5. Type the role name, for example, ProtegrityForwarderRole and click Confirm.

                                                                  6. Record the role ARN.

                                                                    Log Forwarder IAM Execution Role Name: ___________________

                                                                  Installation Artifacts

                                                                  Audit Log Forwarder installation artifacts are part of the same deployment package as the one used for protect and policy agent services. Follow the steps below to ensure the right artifacts are available for log forwarder installation.

                                                                  1. Verify that the Protegrity deployment package is available on your local system, if not, you can download it from the Protegrity portal.

                                                                  2. Extract the pty_log_forwarder_cf.json cloud formation file from the deployment package.

                                                                  3. Check the S3 deployment bucket identified in section Create S3 bucket for Installing Artifacts. Make sure that all Protegrity deployment zip files are uploaded to the S3 bucket.

                                                                  Install through CloudFormation

                                                                  The following steps describe the deployment of the Audit Log Forwarder AWS cloud components.

                                                                  1. Access CloudFormation and select the target AWS Region in the console.

                                                                  2. Click Create Stack and choose With new resources.

                                                                  3. Specify the template.

                                                                  4. Select Upload a template file.

                                                                  5. Upload the Protegrity-provided CloudFormation template called pty_log_forwarder_cf.json and click Next.

                                                                  6. Specify the stack details. Enter a stack name.

                                                                  7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                                                                  Parameter

                                                                  Description

                                                                  Default Value

                                                                  Required

                                                                  LogForwarderSubnets

                                                                  Subnets where the Log Forwarder will be hosted.

                                                                   

                                                                   

                                                                  LogForwarderSecurityGroups

                                                                  Security Groups, which allow communication between the Log Forwarder and ESA.

                                                                   

                                                                  X

                                                                  LambdaExecutionRoleArn

                                                                  The ARN of Lambda role created in the prior step.

                                                                   

                                                                  X

                                                                  ArtifactS3Bucket

                                                                  Name of S3 bucket created in the pre-configuration step.

                                                                   

                                                                  X

                                                                  LogDestinationEsaIp

                                                                  IP or FQDN of the ESA instance or cluster.

                                                                   

                                                                  X

                                                                  AuditLogOutput

                                                                  Audit log processor to target on ESA. Allowed values: audit-store, td-agent

                                                                  audit-store

                                                                  X

                                                                  PtyEsaClientCertificatesSecretId

                                                                  AWS Secrets Manager secret id containing client certificates used for authentication with ESA Audit Store. It is expected that the public key will be stored in a field public_key and the private key in a field named private_key.

                                                                  This parameter is optional. If not provided, Log Forwarder will connect to ESA without client certificate authentication.

                                                                  EsaTlsDisableCertVerify

                                                                  Disable certificate verification when connecting to ESA if set to 1. This is only for dev purposes, do not disable in production environment.

                                                                  0

                                                                  X

                                                                  PtyEsaCaServerCert

                                                                  ESA self-signed CA certificate used by log forwarder Lambda to ensure ESA is the trusted server.

                                                                  Recorded in step Certificates on ESA

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

                                                                   

                                                                  EsaConnectTimeout

                                                                  Time in seconds to wait for the ESA response. Minimum value: 1.

                                                                  5

                                                                  X

                                                                  EsaVirtualHost

                                                                  ESA virtual hostname. This configuration is optional and it can be used when proxy server is present and supports TLS SNI extension.

                                                                   

                                                                   

                                                                  KinesisLogStreamRetentionPeriodHours

                                                                  The number of hours for the log records to be stored in Kinesis Stream in case log destination server is not available. Minimum value: 24. See Log Forwarder Performance section for more details.

                                                                  24

                                                                  X

                                                                  KinesisLogStreamShardCount

                                                                  The number of shards that the Kinesis log stream uses. For greater provisioned throughput, increase the number of shards. Minimum value: 1. See Log Forwarder Performance section for more details.

                                                                  10

                                                                  X

                                                                  MinLogLevel

                                                                  Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                                                                  severe

                                                                  X

                                                                  1. Click Next with defaults to complete CloudFormation.

                                                                  2. After CloudFormation is completed, select the Outputstab in the stack.

                                                                  3. Record the following values

                                                                    KinesisLogStreamArn: ________________________________

                                                                  Add Kinesis Put Record permission to the Protect Function IAM Role

                                                                  1. Login to the AWS account that hosts the Protect Lambda Function.

                                                                  2. Search for Protect Lambda Function IAM Execution Role Name created in Create Protect Lambda IAM role.

                                                                  3. Under Permissions policies, select Add Permissions > Create inline policy.

                                                                  4. In Specify permissions view, switch to JSON.

                                                                  5. Copy the policy json from below replacing the placeholder value indicated in the following snippet as <Audit Log Kinesis Stream ARN> with the value recorded in the previous step.

                                                                    {
                                                                    	"Version": "2012-10-17",
                                                                    	"Statement": [
                                                                    		{
                                                                    			"Sid": "KinesisPutRecords",
                                                                    			"Effect": "Allow",
                                                                    			"Action": "kinesis:PutRecords",
                                                                    			"Resource": "<Audit Log Kinesis Stream ARN>"
                                                                    		}
                                                                    	]
                                                                    }
                                                                    
                                                                  6. When you are finished, choose Next.

                                                                  7. On the Review and create page, type a Name, then choose Create policy.

                                                                  Test Log Forwarder Installation

                                                                  Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                  Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                  1. Navigate to the log forwarder lambda function.

                                                                  2. Select the Test tab.

                                                                  3. Copy the json test event into the Event JSON pane.

                                                                    {
                                                                        "Records": [
                                                                            {
                                                                                "kinesis": {
                                                                                    "kinesisSchemaVersion": "1.0",
                                                                                    "partitionKey": "041e96d78c778677ce43f50076a8ae3e",
                                                                                    "sequenceNumber": "49620336010289430959432297775520367512250709822916263938",
                                                                                    "data": "eyJpbmdlc3RfdGltZV91dGMiOiIyMDI2LTAzLTI3VDEzOjIzOjEyLjkwNFoiLCJhZGRpdGlvbmFsX2luZm8iOnsiZGVzY3JpcHRpb24iOiJEYXRhIHVucHJvdGVjdCBvcGVyYXRpb24gd2FzIHN1Y2Nlc3NmdWwuIn0sImNsaWVudCI6e30sImNudCI6NCwiY29ycmVsYXRpb25pZCI6InJzLXF1ZXJ5LWlkOjEyMzQiLCJsZXZlbCI6IlNVQ0NFU1MiLCJsb2d0eXBlIjoiUHJvdGVjdGlvbiIsIm9yaWdpbiI6eyJob3N0bmFtZSI6IlBSTy1VUy1QRjNSSEdGOSIsImlwIjoiMTAuMTAuMTAuMTAiLCJ0aW1lX3V0YyI6MTcxMTU1OTEwMH0sInByb2Nlc3MiOnsiaWQiOjJ9LCJwcm90ZWN0aW9uIjp7ImF1ZGl0X2NvZGUiOjgsImRhdGFlbGVtZW50IjoiYWxwaGEiLCJkYXRhc3RvcmUiOiJTQU1QTEVfUE9MSUNZIiwibWFza19zZXR0aW5nIjoiIiwib2xkX2RhdGFlbGVtZW50IjpudWxsLCJvcGVyYXRpb24iOiJVbnByb3RlY3QiLCJwb2xpY3lfdXNlciI6IlBUWURFViJ9LCJwcm90ZWN0b3IiOnsiY29yZV92ZXJzaW9uIjoiMS4yLjErNTUuZzU5MGZlLkhFQUQiLCJmYW1pbHkiOiJjcCIsInBjY192ZXJzaW9uIjoiMy40LjAuMTQiLCJ2ZW5kb3IiOiJyZWRzaGlmdCIsInZlcnNpb24iOiIwLjAuMS1kZXYifSwic2lnbmF0dXJlIjp7ImNoZWNrc3VtIjoiN0VCMkEzN0FDNzQ5MDM1NjQwMzBBNUUxNENCMTA5QzE0OEJGODYwRjE3NEVCMjMxMTAyMEI3RkE1QTY4MjdGQyIsImtleV9pZCI6ImM0MjQ0MzZhLTExMmYtNGMzZi1iMmRiLTEwYmFhOGI1NjJhNyJ9fQ==",
                                                                                    "approximateArrivalTimestamp": 1626878559.213
                                                                                },
                                                                                "eventSource": "aws:kinesis",
                                                                                "eventVersion": "1.0",
                                                                                "eventID": "shardId-000000000000:49620336010289430959432297775520367512250709822916261234",
                                                                                "eventName": "aws:kinesis:record",
                                                                                "invokeIdentityArn": "arn:aws:iam::555555555555:role/service-role/TestRole",
                                                                                "awsRegion": "us-east-1",
                                                                                "eventSourceARN": "arn:aws:kinesis:us-east-1:555555555555:stream/CloudProtectEventStream"
                                                                            }
                                                                        ]
                                                                    }
                                                                    
                                                                  4. Select Test to execute the test event.

                                                                  5. Test is successful if the Log Output of test results contains the following log:

                                                                    [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                                                    

                                                                    If the log is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                  Update Protector With Kinesis Log Stream

                                                                  In this section, Kinesis log stream ARN will be provided to the Protect Function installation.

                                                                  1. Navigate to the Protector CloudFormation stack created in the protector installation section.

                                                                  2. Select Update.

                                                                  3. Choose Use existing template > Next.

                                                                  4. Set parameter KinesisLogStreamArn to the output value recorded in Install through CloudFormation.

                                                                  5. Proceed with Next and Submit the changes.

                                                                  6. Continue to the next section once stack status indicates UPDATE_COMPLETE.

                                                                  Update Policy Agent With Log Forwarder Function Target

                                                                  Log Forwarder Lambda function requires a policy layer which is in sync with the Protegrity Protector. This section will describe the steps to update the policy agent to include updating Log Forwarder Lambda function.

                                                                  1. Navigate to the Policy Agent Function created in Policy Agent Installation

                                                                  2. Select Configuration > Environment variables > Edit

                                                                  3. Edit the value for environment variable AWS_PROTECT_FN_NAME to include the log forwarder function name/arn in the comma separated list of Lambda functions.

                                                                  4. Save the changes and continue when update completes

                                                                  5. Navigate to Test tab

                                                                  6. Add an event {} and select Test to run the Policy Agent function

                                                                  7. Verify Log forwarder function was updated to use the policy layer by inspecting the log output. Logs should include the following:

                                                                    
                                                                    [INFO] 2024-07-09 18:58:04,793.793Z 622d374b-1f73-4123-9a38-abc61973adef iap_agent.policy_deployer:Updating lambda [Protegrity_LogForwarder_<stack ID>] to use layer version [arn:aws:lambda:<aws region>:<aws account number>:layer:Protegrity_Layer_<layer name>:<layer version>]
                                                                    

                                                                  Test Full Log Forwarder Installation

                                                                  Install and configure Protegrity Agent, Protector, and Log Forwarder components.

                                                                  1. Send a protect operation to the protector using a data element or user which will result in audit log generation

                                                                  2. Navigate to the CloudWatch log group for the Protect function

                                                                  3. Select the log stream for the test operation and scroll to the latest logs

                                                                  4. Expect to see a log similar to the below:

                                                                    
                                                                    [2024-07-09T19:28:23.158] [INFO] [kinesis-external-sink.cpp:51] Sending 2 logs to Kinesis ...
                                                                    [2024-07-09T19:28:23.218] [INFO] [aws-utils.cpp:206] Kinesis send time: 0.060s
                                                                    
                                                                  5. Navigate to the CloudWatch log group for the Log Forwarder function

                                                                  6. Expect to see a new log stream - it may take several minutes for the stream to start

                                                                  7. Select the new stream and scroll to the most recent logs in the stream

                                                                  8. Expect to see a log similar to the below:

                                                                    
                                                                    [2024-07-09T19:32:31.648] [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                                                    

                                                                  Troubleshooting

                                                                  Error

                                                                  Action

                                                                  Log forwarder log contains severe level secrets permissions error:

                                                                  [SEVERE] User: <arn> is not authorized to perform: secretsmanager:
                                                                  GetSecretValue on resource: <secret name> because no identity-based
                                                                  policy allows the secretsmanager:GetSecretValue action
                                                                  
                                                                  1. Verify the permission policy/role attached to the log forwarder function has secretsmanager:GetSecretValue permission for the insights esa user credentials secret.
                                                                  2. Consult sections Configure ESA Audit Store Credentials and Create Audit Log Forwarder IAM Execution Policy

                                                                  When testing log forwarder as described in Test Log Forwarder Installation, response contains policy decryption error:

                                                                  
                                                                  {
                                                                    "error_msg": "Failed to decrypt the policy. Please verify
                                                                      that the function has access to the key service and the key.",
                                                                    "success": false
                                                                  }
                                                                  
                                                                  1. Verify the permission policy/role attached to the log forwarder function has kms:Decrypt permission for KMS key used to encrypt the Protegrity security policy.
                                                                  2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                                                  Cloudformation stack creation fails with error:

                                                                  
                                                                  The provided execution role does not have permissions to call
                                                                  [CreateNetworkInterface|DescribeNetworkInterfaces|DeleteNetworkInterface]
                                                                  on EC2 (Service: Lambda, Status Code: 400, Request ID: <request id>)"
                                                                  (RequestToken: <request token>, HandlerErrorCode: InvalidRequest)
                                                                  
                                                                  1. Verify the permission policy/role attached to the log forwarder function has ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, ec2:DeleteNetworkInterface permissions
                                                                  2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                                                  Severe level kinesis permissions log message in protector function:

                                                                  
                                                                  [SEVERE] Kinesis stream client returned 400 error with error message:
                                                                  User: <function arn> is not authorized to perform: kinesis:PutRecords
                                                                  on resource: <kinesis stream arn> because no identity-based policy
                                                                  allows the kinesis:PutRecords action
                                                                  
                                                                  1. Verify the permission policy/role attached to the protector function has kinesis:PutRecords permission
                                                                  2. Consult section Add Kinesis Put Record permission to the Protect Function IAM Role

                                                                  TLS errors reported in log forwarder function logs:

                                                                  
                                                                  [error] [tls] <error message>
                                                                  
                                                                  1. If ESA is using self-signed certificate, verify the correct ESA certificate has been given in the format described in Certificates on ESA

                                                                  1.3.3.6 -

                                                                  Prerequisites

                                                                  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
                                                                  AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                                                  Redshift cluster (Enterprise Edition)Must be in the same region as Protegrity Protect Lambda

                                                                  1.3.3.7 -

                                                                  AWS Services

                                                                  The following table describes the AWS services that may be a part of your Protegrity installation.

                                                                  Service

                                                                  Description

                                                                  Lambda

                                                                  Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                                                  KMS

                                                                  Provides secrets for envelope policy encryption/decryption for Protegrity.

                                                                  Secrets Manager

                                                                  Provides secrets management for the ESA credentials.

                                                                  S3

                                                                  Intermediate storage location for the encrypted ESA policy layer.

                                                                  Kinesis

                                                                  Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                                                  VPC & NAT Gateway

                                                                  Optional. Provides a private subnet to communicate with an on-prem ESA.

                                                                  CloudWatch

                                                                  Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                                                  1.3.3.8 -

                                                                  Required Skills and Abilities

                                                                  RequirementsDescription
                                                                  AWS Account AdministratorTo run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.
                                                                  Protegrity AdministratorThe ESA credentials required to extract the policy for the Policy Agent
                                                                  Redshift AdministratorAccount Admin access required to setup access
                                                                  Network AdministratorTo open firewall to access ESA and evaluate AWS network setup

                                                                  1.3.4 - Understanding Redshift Objects

                                                                  Key concepts in understanding the Protegrity Cloud Protect with Redshift.

                                                                  External Functions

                                                                  Redshift provides an External Function capability that is used to call out to a process external to Redshift. In this solution, the external service is Protegrity Redshift Protector, an AWS Lambda for re-identification operations.

                                                                  Function Naming Convention

                                                                  The request payload header indicates the current user context making the Protegrity operation through an SQL request. Protegrity also requires the type of operation and the security policy element name. Protegrity Serverless provides a UDF function naming convention to provide this additional context.

                                                                  The function name convention requires the prefix pty, the type of operation (protect or unprotect), and the ESA policy element name. The three tokens are separated by underscores. Additional underscores are interpreted as part of the element name. (e.g. pty_protect_tok_deSSN).

                                                                  The UDF naming convention is as follows.

                                                                  TokenDescriptionValid Options
                                                                  PrefixRequired to indicate this methodpty
                                                                  operationType of operationprotect, unprotect
                                                                  Element nameESA element nameValid ESA element name (can contain additional underscores)

                                                                  For example, the following UDF will perform an unprotect using the alpha element policy.

                                                                  CREATE OR REPLACE EXTERNAL FUNCTION pty_unprotect_alpha(varchar)
                                                                  RETURNS varchar VOLATILE lambda '<replace_with_protect_function_name>:Production' iam_role 'arn:aws:iam::<you-aws-account-number>:role/<role-name>'
                                                                  

                                                                  Mapping File

                                                                  Protegrity Serverless provides an additional method for mapping UDF function names to operations and security policy elements through a JSON mapping file. This method is recommended when either custom naming conventions are needed or element names do not conform to Redshift’s function naming validation rules. Here is an example.

                                                                  The mapping file must be provided in the same S3 bucket as policy export: AWS_POLICY_S3_BUCKET

                                                                  {
                                                                    "myudf_unp_city":
                                                                      {
                                                                        "Operation": "unprotect",
                                                                        "Element": "deCity”
                                                                      },
                                                                    "myudf_pro_dob": {
                                                                        "Operation": "protect",
                                                                        "Element": "deBirthdate"
                                                                      },
                                                                      ...
                                                                  }
                                                                  

                                                                  The example mapping above would cause Protegrity Serverless to perform an unprotect on the deCity security element for the requests made from the myudf_unp_city UDF function within Redshift.

                                                                  1.3.4.1 -

                                                                  External Functions

                                                                  Redshift provides an External Function capability that is used to call out to a process external to Redshift. In this solution, the external service is Protegrity Redshift Protector, an AWS Lambda for re-identification operations.

                                                                  1.3.4.2 -

                                                                  Function Naming Convention

                                                                  The request payload header indicates the current user context making the Protegrity operation through an SQL request. Protegrity also requires the type of operation and the security policy element name. Protegrity Serverless provides a UDF function naming convention to provide this additional context.

                                                                  The function name convention requires the prefix pty, the type of operation (protect or unprotect), and the ESA policy element name. The three tokens are separated by underscores. Additional underscores are interpreted as part of the element name. (e.g. pty_protect_tok_deSSN).

                                                                  The UDF naming convention is as follows.

                                                                  TokenDescriptionValid Options
                                                                  PrefixRequired to indicate this methodpty
                                                                  operationType of operationprotect, unprotect
                                                                  Element nameESA element nameValid ESA element name (can contain additional underscores)

                                                                  For example, the following UDF will perform an unprotect using the alpha element policy.

                                                                  CREATE OR REPLACE EXTERNAL FUNCTION pty_unprotect_alpha(varchar)
                                                                  RETURNS varchar VOLATILE lambda '<replace_with_protect_function_name>:Production' iam_role 'arn:aws:iam::<you-aws-account-number>:role/<role-name>'
                                                                  

                                                                  1.3.4.3 -

                                                                  Mapping File

                                                                  Protegrity Serverless provides an additional method for mapping UDF function names to operations and security policy elements through a JSON mapping file. This method is recommended when either custom naming conventions are needed or element names do not conform to Redshift’s function naming validation rules. Here is an example.

                                                                  The mapping file must be provided in the same S3 bucket as policy export: AWS_POLICY_S3_BUCKET

                                                                  {
                                                                    "myudf_unp_city":
                                                                      {
                                                                        "Operation": "unprotect",
                                                                        "Element": "deCity”
                                                                      },
                                                                    "myudf_pro_dob": {
                                                                        "Operation": "protect",
                                                                        "Element": "deBirthdate"
                                                                      },
                                                                      ...
                                                                  }
                                                                  

                                                                  The example mapping above would cause Protegrity Serverless to perform an unprotect on the deCity security element for the requests made from the myudf_unp_city UDF function within Redshift.

                                                                  1.3.5 - Performance

                                                                  Benchmarks and performance tuning

                                                                    Performance Considerations

                                                                    The following factors may cause variation in real performance versus benchmarks:

                                                                    • Cold startup: The Lambda 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 Lambda 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.
                                                                    • Lambda memory: AWS provides more virtual cores based on the memory configuration. The initial configuration of 1728 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                                                    • Cluster size: Cluster size may make a significant difference depending on the workload.
                                                                    • Number of security operations (protect or unprotect).
                                                                    • Lambda concurrency and burst quotas: AWS limits the number of concurrent executions and how quickly lambda can scale to meet demand. This is discussed in an upcoming section of the document.
                                                                    • Size of data element: Operations on larger text consume time.

                                                                    Sample Benchmarks

                                                                    The following benchmarks were performed against different cluster sizes. These are median times of approximately five runs each. The query unprotected six columns per row (first_name, last_name, email, postal_code, ssn, iban):

                                                                    Rows x Cols# Opsdc2.large (24 nodes)ra3.4xl (3 nodes)ra3.4xl (7 nodes)ra3.16xl (7 nodes)
                                                                    1M x 6 cols6M1.61.71.51.2
                                                                    10M x 6 cols60M6.06.32.83.3
                                                                    100M x 6 cols600M44.349.823.415.1

                                                                    Lambda Tuning

                                                                    AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region:

                                                                    The Concurrent executions quota cap is the maximum number of Lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                                                                    The Burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. After the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response. Redshift will generally retry until all requests succeed but may abort if a high percentage of failed responses occur.

                                                                    The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended to select a Redshift AWS region with the highest burst limits.

                                                                    Concurrency Troubleshooting

                                                                    Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a Redshift query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your Lambda services in the region.

                                                                    Redshift is tolerant of a certain ratio of failed requests and automatically retries. If a high percentage of requests fail, then the query may abort and the last error code will display in the console. For example, 429 Too Many Requests.

                                                                    CloudWatch Metrics can be manually enabled on the Lambda to reveal if quotas are being reached. Metrics aggregate errors into two buckets that are 4xx. CloudWatch logs can be used to access the actual error code.

                                                                    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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Amazon Kinesis Stream where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated. 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 Cloud Formation Parameters

                                                                      • AuditLogFlushInterval: Determines the minimum amount of time required for the audit log to be sent to Amazon Kinesis. Changing flush interval may affect the level of aggregation, which in turn may result in different number of connections and different data rates to Amazon Kinesis. Default value is 30 seconds.

                                                                        Increasing the flush interval may result in higher aggregation of audit logs, in fewer connections to Amazon Kinesis, in higher latency of audit logs arriving to ESA and in higher data throughput.

                                                                        Lowering the flush interval may result in lower aggregation of audit logs, in more connections to Amazon Kinesis, in lower latency of audit logs arriving to ESA and in lower data throughput.

                                                                        It is not recommended to reduce the flush interval from default value in production environment as it may overload the Amazon Kinesis service. However, it may be beneficial to reduce flush interval during testing to make audit records appear on ESA faster.

                                                                          

                                                                    • Log Forwarder Cloud Formation Parameters

                                                                      • Amazon KinesisLogStreamShardCount: The number of shards represents the level of parallel streams in the Amazon Kinesis and it is proportional to the throughput capacity of the stream. If the number of shards is too low and the volume of audit logs is too high, Amazon Kinesis service may be overloaded and some audit records sent from protect function may be lost.

                                                                        Default value is 10, however you are advised to test with a production-like load to determine whether this is sufficient or not.

                                                                      • Amazon KinesisLogStreamRetentionPeriodHours: The time for the audit records to be retained in Amazon Kinesis log stream in cases where log forwarder function is unable to read records from the Kinesis stream or send records to ESA, for example due to a connectivity outage. Amazon Kinesis will retain failed audit records and retry periodically until connectivity with ESA is restored or retention period expires.

                                                                        Default value is 24 hours, however you are advised to review this value to align it with your Recovery Time Objective and Recovery Point Objective SLAs.

                                                                          

                                                                    • Monitoring Log Forwarder Resources

                                                                      • Amazon Kinesis Stream Metrics: Any positive value in Amazon Kinesis PutRecords throttled records metric indicates that audit logs rate from protect function is too high. The recommended action is to increase the Amazon KinesisLogStreamShardCount or optionally increase the AuditLogFlushInterval.

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

                                                                        [SEVERE] Dropped records: x.
                                                                        
                                                                      • Protect Function CloudWatch Logs: If protect function is unable to send logs to Amazon Kinesis, it will log the following message:

                                                                        [SEVERE] Amazon Kinesis error, retrying in x ms (retry: y/z) ..."
                                                                        

                                                                        Any dropped audit log records will be reported with the following log message:

                                                                        [SEVERE] Failed to send x/y audit logs to Amazon Kinesis.
                                                                        

                                                                    1.3.5.1 -

                                                                    Concurrency Troubleshooting

                                                                    Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a Redshift query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your Lambda services in the region.

                                                                    Redshift is tolerant of a certain ratio of failed requests and automatically retries. If a high percentage of requests fail, then the query may abort and the last error code will display in the console. For example, 429 Too Many Requests.

                                                                    CloudWatch Metrics can be manually enabled on the Lambda to reveal if quotas are being reached. Metrics aggregate errors into two buckets that are 4xx. CloudWatch logs can be used to access the actual error code.

                                                                    1.3.5.2 -

                                                                    Lambda Tuning

                                                                    AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region:

                                                                    The Concurrent executions quota cap is the maximum number of Lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                                                                    The Burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. After the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response. Redshift will generally retry until all requests succeed but may abort if a high percentage of failed responses occur.

                                                                    The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended to select a Redshift AWS region with the highest burst limits.

                                                                    1.3.5.3 -

                                                                    Sample Benchmarks

                                                                    The following benchmarks were performed against different cluster sizes. These are median times of approximately five runs each. The query unprotected six columns per row (first_name, last_name, email, postal_code, ssn, iban):

                                                                    Rows x Cols# Opsdc2.large (24 nodes)ra3.4xl (3 nodes)ra3.4xl (7 nodes)ra3.16xl (7 nodes)
                                                                    1M x 6 cols6M1.61.71.51.2
                                                                    10M x 6 cols60M6.06.32.83.3
                                                                    100M x 6 cols600M44.349.823.415.1

                                                                    1.3.5.4 -

                                                                    Performance Considerations

                                                                    The following factors may cause variation in real performance versus benchmarks:

                                                                    • Cold startup: The Lambda 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 Lambda 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.
                                                                    • Lambda memory: AWS provides more virtual cores based on the memory configuration. The initial configuration of 1728 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                                                    • Cluster size: Cluster size may make a significant difference depending on the workload.
                                                                    • Number of security operations (protect or unprotect).
                                                                    • Lambda concurrency and burst quotas: AWS limits the number of concurrent executions and how quickly lambda can scale to meet demand. This is discussed in an upcoming section of the document.
                                                                    • Size of data element: Operations on larger text consume time.

                                                                    1.3.6 - Audit Logging

                                                                    Audit log description/formatting

                                                                      Audit Logging

                                                                      Audit records and application logs stream to Amazon CloudWatch Logs or optionally be sent to ESA. 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 Amazon CloudWatch. Third-party solutions may be used if they are supported by Amazon Cloudwatch or AWS Lambda logging extensions. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Amazon CloudWatch, refer to the Amazon CloudWatch User Guide.

                                                                      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

                                                                      Example Audit Records

                                                                      The following are sample audit messages:

                                                                      Protect Success:

                                                                      {
                                                                            "additional_info": {
                                                                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                              "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",
                                                                              "ip": "127.0.0.1",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 6,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            process":{
                                                                              "name":"protect",
                                                                              "id":"13",
                                                                              "module":"coreprovider",
                                                                              "thread_id":"573580544",
                                                                              "user":"sbx_user1051",
                                                                              "platform":"\"Linux_x64\"",
                                                                              "version":"UNKNOWN"
                                                                            },
                                                                            "client": {
                                                                              "ip":"169.254.62.117"
                                                                            },
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "4.0.0.102",
                                                                              "vendor": "aws.snowflake",
                                                                              "datastore":"SAMPLE_POLICY",
                                                                              "pcc_version": "4.0.0.9",
                                                                              "core_version": "2.1.4+0.g93016.2.1",
                                                                              "lambda_version":"4.0.1"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      User permission denied:

                                                                      {
                                                                            "additional_info": {
                                                                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                              "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",
                                                                              "ip": "127.0.0.1",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 3,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            process":{
                                                                              "name":"protect",
                                                                              "id":"13",
                                                                              "module":"coreprovider",
                                                                              "thread_id":"573580544",
                                                                              "user":"sbx_user1051",
                                                                              "platform":"\"Linux_x64\"",
                                                                              "version":"UNKNOWN"
                                                                            },
                                                                            "client": {
                                                                              "ip":"169.254.62.117"
                                                                            },
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "4.0.0.102",
                                                                              "vendor": "aws.snowflake",
                                                                              "datastore":"SAMPLE_POLICY",
                                                                              "pcc_version": "4.0.0.9",
                                                                              "core_version": "2.1.4+0.g93016.2.1",
                                                                              "lambda_version":"4.0.1"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      Data element not found:

                                                                      {
                                                                            "additional_info": {
                                                                              "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                              "description": "The data element could not be found in the policy.",
                                                                              "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",
                                                                              "ip": "127.0.0.1",
                                                                              "time_utc": 1635363966
                                                                            },
                                                                            "protection": {
                                                                              "dataelement": "deAddress",
                                                                              "operation": "Protect",
                                                                              "audit_code": 2,
                                                                              "datastore": "SAMPLE_POLICY",
                                                                              "policy_user": "test_user"
                                                                            },
                                                                            process":{
                                                                              "name":"protect",
                                                                              "id":"13",
                                                                              "module":"coreprovider",
                                                                              "thread_id":"573580544",
                                                                              "user":"sbx_user1051",
                                                                              "platform":"\"Linux_x64\"",
                                                                              "version":"UNKNOWN"
                                                                            },
                                                                            "client": {
                                                                              "ip":"169.254.62.117"
                                                                            },
                                                                            "protector": {
                                                                              "family": "cp",
                                                                              "version": "4.0.0.102",
                                                                              "vendor": "aws.snowflake",
                                                                              "datastore":"SAMPLE_POLICY",
                                                                              "pcc_version": "4.0.0.9",
                                                                              "core_version": "2.1.4+0.g93016.2.1",
                                                                              "lambda_version":"4.0.1"
                                                                            },
                                                                            "signature": {
                                                                              "key_id": "95f5a194-b0a4-4351-a",
                                                                              "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                            }
                                                                          }
                                                                      

                                                                      1.3.7 - No Access Behavior

                                                                      Describes the result of various policy configurations with no access operations

                                                                      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.3.8 - Known Limitations

                                                                      Known product limitations.

                                                                      Known Limitations

                                                                      Known product limitations:

                                                                      • FPE is supported only for ASCII values.
                                                                      • Only the protect and unprotect operations are supported. The reprotect operation is not currently supported.
                                                                      • The BIGINT data types are not protected/unprotected accurately. Use String instead.
                                                                      • The FLOAT8 (8-byte float) data type is not supported. Use String instead.
                                                                      • The timestamp data type is not supported.

                                                                      1.3.9 - Upgrading To The Latest Version

                                                                      Instructions for upgrading the protector.

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

                                                                        After downloading the deployment package from the Protegrity Portal, unzip the package to extract the artifact files. In the AWS Console, navigate to the S3 bucket that was previously created to upload deployment artifacts (see: Create S3 bucket for Installing Artifacts).

                                                                        Upload the following artifacts to the S3 bucket:

                                                                        - -
                                                                        • protegrity-protect-<version>.zip
                                                                        • protegrity-agent-<version>.zip
                                                                        • protegrity-external-extension-<version>.zip
                                                                        • protegrity-sample-policy-<version>.zip
                                                                        • protegrity-protect-<version>.zip
                                                                        • protegrity-agent-<version>.zip
                                                                        • protegrity-external-extension-<version>.zip
                                                                        • protegrity-sample-policy-<version>.zip
                                                                        • protegrity-protect-<version>.zip
                                                                        • protegrity-agent-<version>.zip
                                                                        • protegrity-external-extension-<version>.zip
                                                                        • protegrity-sample-policy-<version>.zip
                                                                        • protegrity-athena-protect-udfs-<version>.jar
                                                                        • protegrity-external-extension-<version>.zip
                                                                        • protegrity-agent-<version>.zip
                                                                        • protegrity-sample-policy-<version>.zip

                                                                        If the release version matches your existing deployment, you don’t need to upload it again. Save the following artifacts on your local system so that you have them available during the next steps:

                                                                        - -
                                                                        • pty_protect_cf.json
                                                                        • pty_agent_cf.json
                                                                        • pty_protect_cf.json
                                                                        • pty_agent_cf.json
                                                                        • pty_protect_api_cf.json
                                                                        • pty_agent_cf.json
                                                                        • pty_log_forwarder_cf.json
                                                                        • pty_athena_protect_cf.json
                                                                        • pty_agent_cf.json

                                                                        Perform the following steps to upgrade the Agent Lambda and Protect Lambda separately.

                                                                        Disable Protegrity Agent Function CloudWatch Event Rule

                                                                        Cloud Watch Event Rule is used to periodically run Protegrity Agent Function to synchronize policy from ESA. This functionality is optional when deploying Protegrity Serverless Solution. If the Event Rule is enabled, it must be disabled temporarily for the time of the upgrade process.

                                                                        Follow the steps below to determine if your deployment uses Event Rule and disable it.

                                                                        1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                        2. Select Resources tab from the top portion of the screen.

                                                                        3. Check if there is a resource with ScheduledRule LogicalID. If there is no such resource you can skip to Upgrading Policy Agent Lambda section. If the scheduled rule is there, continue with the next steps in this section.

                                                                        4. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                        5. Select Disable from the top-right portion of the screen. This will disable the rule. You will re-enable it after the upgrade process is complete.

                                                                        Upgrading Policy Agent Lambda

                                                                        1. Go to AWS Lambda console and select existing Protegrity Agent Lambda.

                                                                        2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish. The version of Agent Lambda you just created will serve as restore point in the case you needed to rollback the upgrade.

                                                                        3. Go to Lambda Configuration > Environment variables.

                                                                        4. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                          aws lambda get-function-configuration --function-name \
                                                                          arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                          --query Environment > <function_name>_env_config.json
                                                                          
                                                                        5. Go to AWS Cloud Formation and select existing Protegrity Agent deployment stack.

                                                                        6. Select Update. Check Replace current template > Upload a template file.

                                                                        7. Upload pty_agent_cf.json file and select Next.

                                                                        8. Click Next until Review window and then select Update stack.

                                                                        9. Wait for the Cloud Formation to complete.

                                                                        10. Navigate back to Agent Lambda Function.

                                                                        1. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                          aws lambda update-function-configuration --function-name \
                                                                          arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                          --environment file://./<function_name>_env_config.json
                                                                          
                                                                        2. If you are upgrading from versions prior to v3.0, backup and remove existing policy from the bucket defined by AWS_POLICY_S3_BUCKET property, so that the policy can be re-downloaded and re-encrypted with new ‘key commitment’ feature.

                                                                        3. If you are upgrading from version prior to 1.6.1 please follow the steps below, otherwise the upgrade process is completed.

                                                                        4. From AWS Console, navigate to IAM > Policies

                                                                        5. Search for the Agent Lambda IAM Policy created in Create Agent Lambda IAM policy

                                                                        6. Click on the policy, then select Edit Policy. Select JSON tab.

                                                                        7. Add the following statement to the list of policy statements.

                                                                          
                                                                          {
                                                                            "Sid": "LambdaGetConfiguration",
                                                                            "Effect": "Allow",
                                                                            "Action": [
                                                                                "lambda:GetFunctionConfiguration"
                                                                            ],
                                                                            "Resource": [
                                                                                "arn:aws:lambda:*:*:function:*"
                                                                            ]
                                                                          }
                                                                          
                                                                        8. Click Review Policy, then Save Changes. Wait for the changes to save.

                                                                        Upgrading Log Forwarder Lambda

                                                                        • Publish Log Forwarder Lambda Version

                                                                          Publishing a version of the Log Forwarder Lambda allows to roll-back to pre-existing version if upgrade fails

                                                                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                          2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                          3. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                            Log Forwarder Lambda version number for roll-backs: ___________________

                                                                        • Disable Kinesis Trigger

                                                                          Disabling Kinesis trigger ensures there are no unprocessed or re-processed events while function is upgraded.

                                                                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                          2. Select Configuration tab > Triggers
                                                                          3. Check Kinesis trigger and click Edit button
                                                                          4. Uncheck Activate trigger and click Save
                                                                          5. Wait for function to stop processing events by monitoring function in Monitor tab
                                                                        • Upgrade Forwarder Lambda Version

                                                                          Upgrade Log Forwarder function with new code

                                                                          1. Go to AWS Cloud Formation and select existing Protegrity Log Forwarder deployment stack.
                                                                          2. Select Update Stack > Make a direct update.
                                                                          3. Select Replace existing template > Upload a template file.
                                                                          4. Upload pty_log_forwarder_cf file and select Next.
                                                                          5. Click Next until Review window and then select Update stack.
                                                                          6. Wait for the Cloud Formation to complete.
                                                                        • Enable Kinesis Trigger

                                                                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                          2. Select Configuration tab > Triggers
                                                                          3. Check Kinesis trigger and click Edit button
                                                                          4. Check Activate trigger and click Save Log Forwarder function will now start processing events from where it left off when Kinesis trigger was disabled.
                                                                        • Monitor and roll-back

                                                                          Monitor Log Forwarder function for errors in its CloudWatch logs and in Montior tab. To roll back function to the previous version if any errors occur follow these steps:

                                                                          1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                          2. Select Configuration tab > Triggers

                                                                          3. Expand Details section of Kinesis trigger and record UUID value

                                                                          4. Execute the following AWS CLI command to move Kinesis trigger to previous version of Log Forwarder Lambda that was created earlier and recorded as Log Forwarder Lambda version number for roll-backs. Substitute kinesis-mapping-uuid, log-forwarder-function-name, version-for-roll-backs with your values:

                                                                            
                                                                            aws lambda update-event-source-mapping --uuid <kinesis-mapping-uuid> --function-name <log-forwarder-function-name>:<version-for-roll-backs>
                                                                            
                                                                          5. Find Kinesis trigger attached to previous version of Log Forwarder Lambda by navigating Versions tab > Version number link in the Versions column Kinesis trigger is now moved to previous version of Log Forwarder Lambda function.

                                                                        Upgrading Protect Lambda

                                                                        Diagram below illustrates upgrade steps.

                                                                        Snowflake Function Upgrade Steps

                                                                        Redshift Function Upgrade Steps

                                                                        Cloud API Function Upgrade Steps

                                                                        Athena Function Upgrade Steps

                                                                        • Publish Protect Lambda Version

                                                                          Publishing a version of the Protect Lambda allows updating it without interruptions to the existing traffic.

                                                                          1. Go to AWS Lambda console and select existing Protegrity Protect Lambda.

                                                                          2. Go to Lambda Configuration > Environment variables.

                                                                          3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                            aws lambda get-function-configuration --function-name \
                                                                            arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                            --query Environment > <function_name>_env_config.json
                                                                            
                                                                          4. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                          5. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                            Protect Lambda version number: ___________________

                                                                          6. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                            CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                RETURNS varchar
                                                                                VOLATILE lambda
                                                                                'Protegrity_Protect_test:<protect_lambda_version_number>' iam_role
                                                                                'arn:aws:iam::123456789212:role/example_role';
                                                                            
                                                                        • Run protect service upgrade

                                                                          In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                                                                          1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                          2. Select Update. Check Replace current template > Upload a template file.

                                                                          3. Upload pty_protect_cf.json file and select Next.

                                                                          4. Update ProtectFunctionProductionVersion parameter with Protect Lambda version number recorded in step 3.

                                                                          5. Click Next until Review window and then select Update stack.

                                                                          6. Wait for the Cloud Formation to complete.

                                                                          7. Go back to Lambda console and select Protect Lambda.

                                                                          8. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                            aws lambda update-function-configuration --function-name \
                                                                            arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                            --environment file://./<function_name>_env_config.json
                                                                            
                                                                          9. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                                                                          10. The upgraded Protect Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.

                                                                        • Finalize upgrade

                                                                          In this step, the Protect Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                                                                          1. Go back to Protegrity AWS Cloud Formation deployment stack.

                                                                          2. Select Update. Check Use Current template.

                                                                          3. Update ProtectFunctionProductionVersion parameter with the following value: $LATEST.

                                                                          4. Click Next until Review window and then select Update stack.

                                                                          5. Go back to Lambda console and select Protect Lambda.

                                                                          6. From the Lambda console, verify that Latest alias points to $LATEST version.

                                                                          7. Test your function to make sure it works as expected.

                                                                          8. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                            CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                RETURNS varchar
                                                                                VOLATILE lambda
                                                                                'Protegrity_Protect_test:Production' iam_role
                                                                                'arn:aws:iam::123456789212:role/example_role';
                                                                            
                                                                          9. If you need to rollback to older version of Protect Lambda, you can re-run the cloud formation with ProtectFunctionProductionVersion parameter set to the previous version of Protect Lambda.

                                                                        Re-enable Protegrity Agent Function CloudWatch Event Rule

                                                                        If the Event Rule was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to re-enable Policy Agent Event rule.

                                                                        1. Go to the Protegrity Agent Cloud Formation Stack.

                                                                        2. Select Resources tab from the top portion of the screen.

                                                                        3. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                        4. Select Enable from the top-right portion of the screen. This will enable the rule. You will re-enable it after the upgrade process is complete.

                                                                        1.3.10 - Appendices

                                                                        Additional references for the protector.

                                                                        1.3.10.1 - Installing the Policy Agent and Protector in Different AWS Accounts

                                                                        Example steps to install Agent in a different AWS account than the Protector

                                                                          The Policy Agent Lambda function and Protect Lambda functions can be installed in separate AWS accounts. However, additional configuration is required to authorize the Policy Agent to provision the security policy to a remote Protect Lambda function.

                                                                          Create Agent Lambda IAM policy

                                                                          1. Login to the AWS account that hosts the Protect Lambda function.

                                                                          2. From the AWS IAM console, select Policies > Create Policy.

                                                                          3. Select the JSON tab and copy the following snippet.

                                                                            {
                                                                              "Version": "2012-10-17",
                                                                              "Statement": [
                                                                                {
                                                                                  "Sid": "LambdaUpdateFunction",
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                    "lambda:UpdateFunctionConfiguration"
                                                                                  ],
                                                                                  "Resource": [
                                                                                    "arn:aws:lambda:*:*:function:*"
                                                                                  ]
                                                                                },
                                                                                {
                                                                                  "Sid": "LambdaReadLayerVersion",
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                    "lambda:GetLayerVersion",
                                                                                    "lambda:ListLayerVersions"
                                                                                  ],
                                                                                  "Resource": "*"
                                                                                },
                                                                                {
                                                                                  "Sid": "LambdaDeleteLayerVersion",
                                                                                  "Effect": "Allow",
                                                                                  "Action": "lambda:DeleteLayerVersion",
                                                                                  "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                                                                },
                                                                                {
                                                                                  "Sid": "LambdaPublishLayerVersion",
                                                                                  "Effect": "Allow",
                                                                                  "Action": "lambda:PublishLayerVersion",
                                                                                  "Resource": "arn:aws:lambda:*:*:layer:*"
                                                                                },
                                                                                {
                                                                                  "Sid": "S3GetObject",
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                    "s3:GetObject"
                                                                                  ],
                                                                                  "Resource": "arn:aws:s3:::*/*"
                                                                                },
                                                                                {
                                                                                  "Sid": "S3PutObject",
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                    "s3:PutObject"
                                                                                  ],
                                                                                  "Resource": "arn:aws:s3:::*/*"
                                                                                },
                                                                                {
                                                                                  "Sid": "LambdaGetConfiguration",
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                      "lambda:GetFunctionConfiguration"
                                                                                  ],
                                                                                  "Resource": [
                                                                                      "arn:aws:lambda:*:*:function:*"
                                                                                  ]
                                                                                }
                                                                              ]
                                                                            }
                                                                            
                                                                          4. Replace the wildcards (*) with the region, account, and resource name information where required.

                                                                          5. Select Review policy, type in the policy name, and confirm. Record policy name:

                                                                            Agent Lambda Cross Account Policy Name: ___________________

                                                                          Create Policy Agent cross-account IAM Role

                                                                          1. Login to the AWS account that hosts the Protect Lambda function.

                                                                          2. From the AWS IAM console, select Roles > Create Role

                                                                          3. Select AWS Service > Lambda . Proceed to Permissions.

                                                                          4. Select Policy created in the step above. Proceed to Tags.

                                                                          5. Specify Tag, proceed to the final screen. Type in policy name and confirm. Record the name.

                                                                            Policy Agent Cross Account IAM Role Name: ___________________

                                                                          Allow the Policy Agent Cross-Account Role to be Assumed by the Policy Agent IAM Role

                                                                          1. Login to the AWS account that hosts the Protect Lambda function.

                                                                          2. Navigate to the previously created IAM Role (Agent Lambda Cross-Account IAM Role Name).

                                                                          3. Navigate to Trust Relationships > Edit Trust Relationships.

                                                                          4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda IAM Execution Role ARN> with ARN of Agent Lambda IAM Role that was created in Agent Installation.

                                                                            {
                                                                              "Version": "2012-10-17",
                                                                              "Statement": [
                                                                                {
                                                                                  "Effect": "Allow",
                                                                            
                                                                               "Principal": {
                                                                            
                                                                                        "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                                            
                                                                                  },
                                                                                  "Action": "sts:AssumeRole"
                                                                                }
                                                                              ]
                                                                            }
                                                                            
                                                                          5. Click Update Trust Policy.

                                                                          Add Assume Role to the Policy Agent Execution IAM Role

                                                                          1. Login to the AWS account that hosts the Policy Agent.

                                                                          2. Navigate to the Agent Lambda IAM Execution Role that was created in Agent Installation.

                                                                            {
                                                                              "Version": "2012-10-17",
                                                                              "Statement": [
                                                                                {
                                                                                  "Effect": "Allow",
                                                                            
                                                                               "Principal": {
                                                                            
                                                                                        "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                                            
                                                                                  },
                                                                                  "Action": "sts:AssumeRole"
                                                                                }
                                                                              ]
                                                                            }
                                                                            
                                                                          3. Add Inline Policy.

                                                                          4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda Cross-Account IAM ARN> with the value recorded in Create Policy Agent cross-account IAM Role.

                                                                            {
                                                                              "Version": "2012-10-17",
                                                                              "Statement": [
                                                                                {
                                                                                  "Effect": "Allow",
                                                                                  "Action": [
                                                                                    "sts:AssumeRole"
                                                                                  ],
                                                                                  "Resource": "<Agent Lambda Cross-Account IAM  ARN>."
                                                                                }
                                                                              ]
                                                                            }
                                                                            
                                                                          5. When you are finished, choose Review Policy.

                                                                          6. On the Review policy page, type a Name, then choose Create Policy.

                                                                          Update the Policy Agent Lambda Configuration

                                                                          1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                                          2. Select Configuration tab | Environment variables.

                                                                          3. Select Edit and add the following environment variables with the value from Agent Lambda Cross-Account IAM ARN:

                                                                            ParameterValue
                                                                            AWS_ASSUME_ROLEAgent Lambda Cross-Account IAM ARN
                                                                          4. Ensure the values in the Parameters AWS_POLICY_S3_BUCKET, AWS_PROTECT_FN_NAME and AWS_POLICY_LAYER_NAME are all in the Protect Lambda Function AWS Account.

                                                                          5. In case custom VPC hostname configuration is used, you will need to set the ENDPOINT_URL. Refer to Policy Agent - Custom VPC Endpoint Hostname Configuration.

                                                                            AWS_VPC_ENDPOINT_URL

                                                                            <AWS_VPC_ENDPOINT>

                                                                          6. Click Save and Run the Lambda. The Lambda will now assume the Role in Protect Lambda Function AWS Account and update the policy cross accounts.

                                                                          1.3.10.2 - 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.3.10.3 - Policy Agent - Custom VPC Endpoint Hostname Configuration

                                                                            Custom vpc endpoint hostname configuration

                                                                            The Policy Agent uses default endpoint hostnames to communicate with other AWS services (for example, secretsmanager.amazonaws.com). This configuration will only work in VPCs where Amazon-provided DNS is available (default VPC configuration with private DNS option enabled for the endpoint). If your VPC uses custom DNS, follow the instructions below to configure the Policy Agent Lambda to use custom endpoint hostnames.

                                                                            Identify DNS Hostnames

                                                                            To identify DNS hostnames:

                                                                            1. From AWS console, select VPC > Endpoints.

                                                                            2. Select Secrets Manager endpoint from the list of endpoints.

                                                                            3. Under Details > DNS Names, note the private endpoint DNS names adding https:// at the beginning of the endpoint name.

                                                                              For example, https://vpce-1234-4pzomrye.kms.us-west-1.vpce.amazonaws.com

                                                                            4. Note down DNS names for the KMS and Lambda endpoints:

                                                                              AWS_SECRETSMANAGER_ENDPOINT: https://_________________

                                                                              AWS_KMS_ENDPOINT: https://_________________

                                                                              AWS_LAMBDA_ENDPOINT: https://_________________

                                                                            Update the Policy Agent Lambda configuration

                                                                            To update policy agent lambda configuration:

                                                                            1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                                            2. Select the Configuration section and choose Environment variables.

                                                                            3. Select Edit and add the following environment variables with the corresponding endpoint URLs recorded in steps 3-4:

                                                                              ParametersValue
                                                                              AWS_SECRETSMANAGER_ENDPOINT_URL<AWS_SECRETS_ENDPOINT>
                                                                              AWS_KMS_ENDPOINT_URL<AWS KMS ENDPOINT>
                                                                              AWS_LAMBDA_ENDPOINT_URL<AWS LAMBDA ENDPOINT>
                                                                            4. Click Save and Run the Lambda. The Lambda will now use endpoints you have just configured.

                                                                            1.3.10.4 - Redshift Cross-Account Configuration

                                                                            Configure Cloud Protect in a different account from the Redshift cluster

                                                                            Cross-Account Configuration

                                                                            The following figure illustrates the Protegrity Redshift Integration architecture when Protegrity Solution is installed on separate from Amazon Redshift Cluster Account.

                                                                            Redshift Account IAM Configuration

                                                                            This step creates Redshift IAM role with permissions to assume role in separate account.

                                                                            Create Redshift IAM policy:

                                                                            1. Login to the AWS account that hosts the Amazon Redshift cluster.

                                                                            2. In the AWS console, access Services > IAM and click Policies.

                                                                            3. Click Create Policy.

                                                                            4. Select the JSON tab and paste the following JSON snippet:

                                                                              { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "sts:AssumeRole" ], "Resource": "<DBRoleARN>" } ] }
                                                                              
                                                                            5. Replace the resource value with DBRoleARN recorded in Create IAM Account Role

                                                                            6. Click Review policy to continue.

                                                                            7. Enter a name for the policy.

                                                                            8. Click Create Policy.

                                                                            9. Record the policy name.

                                                                              Redshift IAM Policy Name: ___________________

                                                                            Create Redshift IAM Role

                                                                            This step creates Redshift IAM role with permissions to assume role in separate account.

                                                                            Create Redshift IAM Role:

                                                                            1. Login to the AWS account that hosts the Amazon Redshift cluster.

                                                                            2. In the AWS console, access Services > IAM and click Roles.

                                                                            3. Click Create Role.

                                                                            4. Select AWS Service as the trusted entity type, then select Redshift use case from the list of services.

                                                                            5. Select Redshift – Customizable from the use case section.

                                                                            6. Continue by clicking Next:Permissions.

                                                                            7. Filter the list and search for the policy recorded in the step above (Redshift IAM Policy Name).

                                                                            8. Click the Next:Tags button to continue to the next step.

                                                                            9. Click the Next:Review button to continue.

                                                                            10. Enter a role name, such as Redshift2ProtegrityRole.

                                                                            11. Click Create Role.

                                                                            12. Record role ARN:

                                                                              RedshiftIAMRoleARN: ____________________

                                                                            Attach IAM Role to Redshift Cluster

                                                                            This step creates Redshift IAM role with permissions to assume role in separate account.

                                                                            Attach IAM role to the Redshift cluster:

                                                                            1. Login to AWS Console.

                                                                            2. Access Amazon Redshift and select your cluster.

                                                                            3. Select Properties > Cluster Permissions > Manage IAM Roles.

                                                                            4. Select RedshiftIAMRoleARN configured in the step above and click Associate IAM role.

                                                                            5. Save the changes.

                                                                            6. After saving the changes it may take couple of minutes until the cluster IAM role is fully configured.

                                                                            7. You can check configuration status by navigating back to the cluster IAM role settings.

                                                                            8. The status field next to the IAM role will show in-sync once the role is configured.

                                                                            Defining Redshift External Functions

                                                                            The external function for cross-account differs slightly from the reference material in this document. The function requires two roles to be specified. The following is an example of the modified function definition.

                                                                            CREATE OR REPLACE EXTERNAL FUNCTION demo_schema.pty_unprotect_deName(varchar)
                                                                            RETURNS varchar
                                                                            VOLATILE
                                                                            LAMBDA 'ProtectFunctionProductionAlias'
                                                                            IAM_ROLE '<RedshiftIAMRoleARN>,<DBRoleARN>;
                                                                            

                                                                            Replace <ProtectFunctionProductionAlias> with the value recorded in Install through CloudFormation Replace <RedshiftIAMRoleARN> with the value recorded in Create Redshift IAM Role Replace <DBRoleARN> with the value recorded in Create IAM Account Role

                                                                            1.3.10.5 - Sample Redshift External Function

                                                                            Sample redshift external function definitions

                                                                            Sample Redshift External Function

                                                                            Method: Tokenization

                                                                            Type: ALPHA

                                                                             

                                                                            Redshift Data Types

                                                                            Redshift Max Size

                                                                            Protegrity Max Size

                                                                            VARCHAR

                                                                            4K (4,096 bytes)

                                                                            4K (4,096 bytes)

                                                                            CHAR

                                                                             

                                                                             

                                                                             

                                                                            External Function Sample Definitions:

                                                                            CREATE EXTERNAL FUNCTION PTY_PROTECT_ALPHA ( val varchar )
                                                                            RETURNS varchar
                                                                            VOLATILE lambda
                                                                            '<replace_with_protect_function_name>:Production' iam_role 'arn:aws:iam::<REPLACE_WITH_YOUR_AWS_ACCOUNT>:role/<REPLACE_WITH_IAM_ROLE_NAME>';
                                                                            

                                                                             

                                                                            Sample EF Calls:

                                                                            SELECT PTY_PROTECT_ALPHA ('Hello World');
                                                                            
                                                                            SELECT PTY_UNPROTECT_ALPHA('rfDtw sLMJK');
                                                                            

                                                                             

                                                                             

                                                                            Method: Tokenization

                                                                            Type: NUMERIC

                                                                             

                                                                            Redshift Data Types

                                                                            Redshift Max Size

                                                                            Protegrity Max Size

                                                                            DECIMAL

                                                                            4K (4,096 bytes)

                                                                            4K (4,096 bytes)

                                                                            INTEGER

                                                                            BIGINT

                                                                             

                                                                             

                                                                            External Function Sample Definitions:

                                                                            CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_NUMERIC ( val int )
                                                                            RETURNS int
                                                                            VOLATILE lambda
                                                                            '<replace_with_protect_function_name>:Production' iam_role 'arn:aws:iam::<REPLACE_WITH_YOUR_AWS_ACCOUNT>:role/<REPLACE_WITH_IAM_ROLE_NAME>';
                                                                            

                                                                             

                                                                            Sample EF Calls:

                                                                            SELECT PTY_PROTECT_NUMERIC (2147483647);
                                                                            
                                                                            SELECT PTY_UNPROTECT_NUMERIC(-12344556564);
                                                                            

                                                                            1.3.10.6 - Configuring Regular Expression to Extract Policy Username

                                                                            Extract the policy username from the AWS identity.

                                                                            Configuring Regular Expression to Extract Policy Username

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

                                                                            • USERNAME_REGEX Lambda Environment configuration

                                                                              The USERNAME_REGEX configuration can be used to extract policy username from user in the request. The following are allowed values for USERNAME_REGEX:

                                                                              • 1 - Default build-in regular expression is used:

                                                                                ^arn:aws:(?:iam|sts)::[0-9]{12}:(?:role|user|group|assumed\-role|federated\-user)\/([\w\/+=,.\-]{1,1024}|[\w\/+=,.\-@]{1,1024})(?:@[a-zA-Z0-9\-]{1,320}(?:\.\w+)+)?$
                                                                                
                                                                              • ^User regex$ - Custom regex 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

                                                                            arn:aws:iam::123456789012:user/juliet.snow

                                                                            arn:aws:iam::123456789012:user/juliet.snow

                                                                            arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                            arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                            1

                                                                            arn:aws:iam::123456789012:user/juliet.snow

                                                                            juliet.snow

                                                                            arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                            TestSaml

                                                                            ^arn:aws:(?:iam|sts)::[0-9]{12}:((?:role|user|group|assumed-role|federated-user).*)$
                                                                            

                                                                            arn:aws:iam::123456789012:user/juliet.snow

                                                                            user/juliet.snow

                                                                            arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                            assumed-role/TestSaml

                                                                            1.3.10.7 - Associating ESA Data Store With Cloud Protect Agent

                                                                            Configure ESA data store for Policy Agent.

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

                                                                            The Lambda service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range of the VPC subnet the Lambda is associated with. By default, when agent lambda is contacting ESA to register node for policy download, ESA uses agent Lambda VPC 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 lambda, 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 VPC subnet IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent lambda config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                                                                            169.254.144.8110.1.2.173No Proxytrueyes169.254.144.81
                                                                            trueno10.1.2.173
                                                                            falseyes
                                                                            falseno
                                                                            169.254.144.8110.1.2.17334.230.42.110trueyes169.254.144.81
                                                                            trueno34.230.42.110
                                                                            falseyes
                                                                            falseno

                                                                            1.4 - Snowflake

                                                                            Protector for Snowflake on AWS.

                                                                            This section describes the high-level architecture of the product for integration with Snowflake, the installation procedures, and provides guidance on performance. This section focuses on Protegrity-specific aspects and should be consumed with the corresponding Snowflake 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.4.1 - Overview

                                                                            Solution overview and features.

                                                                              Solution Overview

                                                                              Snowflake Protector on AWS 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 Lambda 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 AWS 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 AWS service.

                                                                              Features

                                                                              Snowflake Protector on AWS 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.

                                                                              Deployment Architecture

                                                                              The Protegrity product should be deployed in the customer’s Cloud account within the same AWS region as the Snowflake cluster. The product incorporates Protegrity’s vaultless tokenization engine within an AWS Lambda Function. The encrypted data security policy from an ESA is deployed periodically as a static resource through an AWS Lambda Layer. The policy is decrypted in memory at runtime within the Lambda. 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 Lambda function via the AWS 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 for reporting and alerting purposes via optional component called Log Forwarder explained in details in the next section of this guide.

                                                                              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 additional envelope encryption using Amazon KMS, and deploys the policy into the Lambda Layer used by the serverless product. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator. The policy takes effect immediately for all new requests. There is no downtime for users during this process.

                                                                              The following diagram shows the high-level architecture described above.

                                                                              The following diagram shows a reference architecture for synchronizing the security policy from ESA.

                                                                              The Protegrity Policy Agent requires network access to an Enterprise Security Administrator (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 Guide.

                                                                              Log Forwarding Architecture

                                                                              Audit logs are by default sent to CloudWatch as long as the function’s execution role has the necessary permissions. 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 Amazon Kinesis data stream and the forwarder Lambda function. Amazon Kinesis stream is used to batch audit records before sending them 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 Amazon Kinesis. Due to specifics of the Lambda runtime lifecycle, audit logs may take up to 15 minutes before being sent to Amazon Kinesis. Protector function exposes configuration to minimize this time 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 Amazon Kinesis 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 client certificate to authenticate calls to ESA.

                                                                              To learn more about individual audit log entry structure and purpose of audit logs, refer to Audit Logging section in this document. Installation instructions can be found in 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

                                                                              Request authorization between Snowflake’s AWS VPC to the customer’s AWS API-Gateway occurs using a Snowflake integration enabled by an AWS cross-account IAM role created within the customer’s AWS account. The API Gateway authorizes each request, limiting access to the Snowflake AWS IAM user and external ID established through a Snowflake API Integration object. The following figure illustrates the Protegrity Snowflake Integration architecture.

                                                                              Snowflake’s API Integration Object

                                                                              The Snowflake API Integration Object provides a connection between your Snowflake VPC and your AWS account where the Protegrity product is hosted. Creating this connection requires setting up the API Gateway and the IAM shared account role. These steps are provided in the installation.

                                                                              The following figure shows how trust is established between Snowflake and the product.

                                                                              1.4.2 - Installation

                                                                              Product Installation Guide.

                                                                              1.4.2.1 - Pre-Configuration

                                                                              Configuration steps prior product installation.

                                                                                Determine AWS Region

                                                                                Query the AWS region where the Snowflake cluster is running. This is the region in which Protegrity Serverless must be installed.

                                                                                To determine AWS region:

                                                                                1. Login to Snowflake

                                                                                2. In the SQL console, run the following query.

                                                                                  select current_region();
                                                                                  
                                                                                3. Record the AWS region (e.g. us-east-1).

                                                                                  AWS Region: ___________________

                                                                                Provide AWS sub-account

                                                                                Identify or create an AWS account where the Protegrity solution will be installed. It is recommended that a new AWS sub-account be created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some subsequent installation steps.

                                                                                AWS Account ID: ___________________

                                                                                AWS Region (AwsRegion): ___________________

                                                                                Create S3 bucket for Installing Artifacts

                                                                                This S3 bucket will be used for the artifacts required by the CloudFormation installation steps. This S3 bucket must be created in the region that is defined in Provide AWS sub-account

                                                                                1. Sign in to the AWS Management Console and open the Amazon S3 console.

                                                                                2. Change region to the one determined in Provide AWS sub-account

                                                                                3. Click Create Bucket.

                                                                                4. Enter a unique bucket name:

                                                                                  For example, protegrity-install.us-west-2.example.com

                                                                                5. Upload the installation artifacts to this bucket. Protegrity will provide the following three artifacts:

                                                                                  • protegrity-protect-<version>.zip
                                                                                  • protegrity-agent-<version>.zip
                                                                                  • protegrity-external-extension-<version>.zip
                                                                                  • protegrity-sample-policy-<version>.zip

                                                                                  S3 Bucket name (ArtifactS3Bucket): ___________________

                                                                                Create KMS Key

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

                                                                                To create KMS key:

                                                                                1. In the AWS sub-account where the KMS key will reside, select the region.

                                                                                2. Navigate to Key Management Service > Create Key.

                                                                                3. Configure the key settings:

                                                                                  • Key type: Asymmetric
                                                                                  • Key usage: Encrypt and decrypt
                                                                                  • Key spec: RSA_4096
                                                                                  • Click Next
                                                                                4. Create alias and optional description, such as, Protegrity-Serverless and click Next.

                                                                                5. Define key administrative permissions, the IAM user who will administrate the key.

                                                                                6. Click Next.

                                                                                7. Define the key usage permissions.

                                                                                8. In Other AWS accounts, enter the AWS account id used for the Protegrity Serverless installation.

                                                                                9. Continue on to create the key. If there is a concern this permission is overly broad, then you can return later to restrict access to the role of two Protegrity Serverless Lambda as principals. Click to open the key in the list and record the ARN.

                                                                                  KMS Key ARN (AWS_KMS_KEY_ID): ___________________

                                                                                10. Download the public key from the KMS key. Navigate to the key in KMS console, select the Public key tab, and click Download. Save the PEM file. This public key will be added to the ESA data store as an export key. Refer to Exporting Keys to Datastore for instructions on adding the public key to the data store.

                                                                                  KMS Public Key PEM file: ___________________

                                                                                Create IAM Account Role

                                                                                An IAM role is used to authorize Snowflake to access the future Protect Lambda resource.

                                                                                To create IAM account role:

                                                                                1. From the AWS console, login to the AWS sub-account where Protegrity will be hosted.

                                                                                2. Access IAM, select roles and then Create Role.

                                                                                3. Select AWS account from the list of trusted entities types.

                                                                                4. Select your AWS Account Id as a placeholder value. You will update this field later when configuring Snowflake access.

                                                                                5. Select Require external ID and enter the following placeholder value.

                                                                                  REPLACE_ME_WITH_EXTERNAL_ID

                                                                                6. Click Next.

                                                                                7. Continue and click Next

                                                                                8. Enter a Role name, for example, Snowflake.

                                                                                9. After the role is created, click on the role. Record the following information:

                                                                                  • Role Name (DBRoleName): ____________________
                                                                                  • Role ARN: ____________________

                                                                                1.4.2.2 - Prerequisites

                                                                                Requirements before installing the protector.

                                                                                  AWS Services

                                                                                  The following table describes the AWS services that may be a part of your Protegrity installation.

                                                                                  Service

                                                                                  Description

                                                                                  Lambda

                                                                                  Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                                                                  API Gateway

                                                                                  Provides the endpoint and access control.

                                                                                  KMS

                                                                                  Provides secrets for envelope policy encryption/decryption for Protegrity.

                                                                                  Secrets Manager

                                                                                  Provides secrets management for the ESA credentials .

                                                                                  S3

                                                                                  Intermediate storage location for the encrypted ESA policy layer.

                                                                                  Kinesis

                                                                                  Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                                                                  VPC & NAT Gateway

                                                                                  Optional. Provides a private subnet to communicate with an on-prem ESA.

                                                                                  CloudWatch

                                                                                  Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                                                                  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

                                                                                  Requirement

                                                                                  Detail

                                                                                  Protegrity distribution and installation scripts

                                                                                  These artifacts are provided by Protegrity

                                                                                  Protegrity ESA 10.0+

                                                                                  The Cloud VPC must be able to obtain network access to the ESA

                                                                                  AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                                                                  Snowflake cluster (Enterprise Edition)

                                                                                  Required Skills and Abilities

                                                                                  Role / Skillset

                                                                                  Description

                                                                                  AWS Account Administrator

                                                                                  To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

                                                                                  Protegrity Administrator

                                                                                  The ESA credentials required to extract the policy for the Policy Agent

                                                                                  Network AdministratorTo open firewall to access ESA and evaluate AWS network setup
                                                                                  Snowflake AdministratorAccount Admin access required to setup access

                                                                                  1.4.2.3 - Protect Service Installation

                                                                                  Product Installation Guide.

                                                                                    Preparation

                                                                                    1. Ensure that all the steps in Pre-Configuration are performed.

                                                                                    2. Login to the AWS account console where - Snowflake Protector on AWS will be installed.

                                                                                    3. Ensure that the required CloudFormation templates provided by Protegrity are available on your local computer.

                                                                                    Create Protect Lambda IAM Execution Policy

                                                                                    This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

                                                                                    Perform the following steps to create the Lambda execution role and required policies:

                                                                                    1. From the AWS IAM console, select Policies > Create Policy.

                                                                                    2. Select the JSON tab and copy the following sample policy.

                                                                                      {
                                                                                        "Version": "2012-10-17",
                                                                                        "Statement": [
                                                                                          {
                                                                                            "Sid": "CloudWatchWriteLogs",
                                                                                            "Effect": "Allow",
                                                                                            "Action": [
                                                                                              "logs:CreateLogGroup",
                                                                                              "logs:CreateLogStream",
                                                                                              "logs:PutLogEvents"
                                                                                            ],
                                                                                            "Resource": "*"
                                                                                          },
                                                                                          {
                                                                                            "Sid": "KmsDecrypt",
                                                                                            "Effect": "Allow",
                                                                                            "Action": [
                                                                                              "kms:Decrypt"
                                                                                            ],
                                                                                            "Resource": [
                                                                                              "arn:aws:kms:*:*:key/*"
                                                                                            ]
                                                                                          }
                                                                                        ]
                                                                                      }
                                                                                      
                                                                                    3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                                                                    4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

                                                                                      ProtectLambdaPolicyName:__________________

                                                                                    Create Protect Lambda IAM Role

                                                                                    The following steps create the role to utilize the policy defined in Create Protect Lambda IAM Execution Policy.

                                                                                    To create protect lambda IAM execution role:

                                                                                    1. From the AWS IAM console, select Roles > Create Role.

                                                                                    2. Select AWS Service > Lambda > Next.

                                                                                    3. In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.

                                                                                    4. Click Next

                                                                                    5. Type the role name, for example, ProtegrityProtectRole

                                                                                    6. Click Create role

                                                                                    7. Record the role ARN.

                                                                                      Role ARN (LambdaExecutionRoleArn): ___________________

                                                                                    Installing through CloudFormation

                                                                                    The following steps describe the deployment of the Lambda function.

                                                                                    To install through CloudFormation:

                                                                                    1. Access CloudFormation and select the target AWS Region.

                                                                                    2. Click Create Stack and choose With new resources.

                                                                                    3. Specify the template.

                                                                                    4. Select Upload a template file.

                                                                                    5. Upload the Protegrity-provided CloudFormation template called pty_protect_cf.json and click Next.

                                                                                    6. Specify the stack details. Enter a stack name.

                                                                                    7. Enter the required parameters. All the values were generated in Pre-Configuration.

                                                                                      ParameterDescription
                                                                                      DBRoleNameName of the account role created in the pre-configuration step
                                                                                      ArtifactS3BucketName of S3 bucket created in the pre-configuration step
                                                                                      LambdaExecutionRoleArnThe ARN of Lambda role created in the prior step
                                                                                      MinLogLevelMinimum log level for protect function. Allowed Values: off, severe, warning, info, config, all
                                                                                    8. The log forwarder parameters can be provided later after log forwarder is deployed. If you are not planning to deploy log forwarder you can skip this step.

                                                                                      ParameterDescription
                                                                                      KinesisLogStreamArnThe ARN of the AWS Kinesis stream where audit logs will be sent for aggregation
                                                                                      AuditLogFlushIntervalTime interval in seconds used to accumulate audit logs before sending to Kinesis. Default value: 30. See Log Forwarder Performance section for more details.
                                                                                    9. Click Next with defaults to complete CloudFormation.

                                                                                    10. After CloudFormation is completed, select the Outputs tab in the stack.

                                                                                    11. Record the following values:

                                                                                      • ApiGatewayId: ________________________________
                                                                                      • ProtectFunctionName: __________________________
                                                                                      • ProtectFunctionProductionAlias: __________________________
                                                                                      • ProtectLayerName: _____________________________
                                                                                      • SnowflakeApiAllowedPrefixes: ____________________
                                                                                      • SnowflakeApiAwsRoleARN: _______________________

                                                                                    Snowflake Configuration

                                                                                    The following sections will configure Snowflake to access the API Gateway. The CloudFormation installation installed 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 must be created.

                                                                                    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 <SnowflakeApiAwsRoleARN> and <SnowflakeApiAllowedPrefixes> with values recorded in the last installation step of Installing through CloudFormation, 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 = aws_api_gateway api_aws_role_arn = '<SnowflakeApiAwsRoleARN>' 
                                                                                      enabled = true 
                                                                                      api_allowed_prefixes = ('<SnowflakeApiAllowedPrefixes>');
                                                                                      

                                                                                    Describe the API Integration Object

                                                                                    We require values generated by the Snowflake integration object to complete configuring the API Gateway resource policy.

                                                                                    To describe API integration objects:

                                                                                    1. Run the following query in the console.

                                                                                      DESCRIBE API INTEGRATION protegrity_api;
                                                                                      
                                                                                    2. Record the following output values from the resulting query:

                                                                                      • API_AWS_IAM_USER_ARN: ___________________
                                                                                      • API_AWS_EXTERNAL_ID: ___________________

                                                                                    Update IAM Access Role Policy

                                                                                    This step allows the Snowflake IAM account to assume the role required to invoke the API Gateway resource.

                                                                                    To update API Integration Objects:

                                                                                    1. Return to theAWS Console > IAM > Roles and find the IAM role created earlier. For example, Snowflake.

                                                                                    2. Navigate to Trust Relationships > Edit trust policy.

                                                                                    3. Modify the Policy Document replacing the placeholder values indicated in the following snippet as API_AWS_IAM_USER_ARN and API_AWS_EXTERNAL_ID with the values recorded from the Snowflake integration object in Describe the API Integration Object.

                                                                                      {
                                                                                        "Version": "2012-10-17",
                                                                                        "Statement": [
                                                                                          {
                                                                                            "Effect": "Allow",
                                                                                            "Principal": {
                                                                                              "AWS": "<API_AWS_IAM_USER_ARN>"
                                                                                            },
                                                                                            "Action": "sts:AssumeRole",
                                                                                            "Condition": {
                                                                                              "StringEquals": {
                                                                                                "sts:ExternalId": "<API_AWS_EXTERNAL_ID>"
                                                                                              }
                                                                                            }
                                                                                          }
                                                                                        ]
                                                                                      }
                                                                                      

                                                                                    Test Connectivity

                                                                                    Perform the following steps to verify if 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 '<SnowflakeApiAllowedPrefixes>';
                                                                                      
                                                                                    3. Replace the placeholder value indicated substituting your API Gateway URL captured in the stack outputs (SnowflakeApiAllowedPrefixes).

                                                                                    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

                                                                                    Error

                                                                                    Action

                                                                                    Snowflake: 403 unauthorized

                                                                                    1. Ensure that the resource policy on the API Gateway is correct
                                                                                    2. Ensure that the IAM role Trust is accurate
                                                                                    3. Ensure that the API Gateway is deployed (or try deploying it again)

                                                                                    Snowflake: 5xx error

                                                                                    Try running the Lambda directly. Open the Lambda function and create the following test case:``` { “body”: “{ "data":[ [0," ‘UtfVk UHgcD!’"] ] }”, “headers”: { “sf-context-current-user”: “test”, “sf-custom-x-protegrity-hcop-rules”: “{"jsonpaths":[{"op_type":"unprotect","data_element":"alpha"}]}”, “sf-external-function-current-query-id”: “test-id” } }

                                                                                    
                                                                                    If this step fails, then check the console for the meaningful error.
                                                                                    
                                                                                    </td></tr></tbody>
                                                                                    </table>
                                                                                    

                                                                                    1.4.2.4 - Policy Agent Installation

                                                                                    Install the policy agent.

                                                                                      The following sections will install the Policy Agent. The Policy Agent polls the ESA and deploys the policy to Protegrity Serverless as a static resource. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity Professional Services for further guidance on configuration alternatives in the Cloud.

                                                                                      ESA Server

                                                                                      Policy Agent Lambda requires ESA server running and accessible on TCP port 443.

                                                                                      Note down ESA IP address:

                                                                                      ESA IP Address (EsaIpAddress): ___________________

                                                                                      Certificates on ESA

                                                                                      Whether your ESA is configured with default self-signed certificate or your corporate CA certificate, Policy Agent can validate authenticity of ESA connection using CA certificate. The process for both scenarios is the same:

                                                                                      • Obtain CA certificate
                                                                                      • Convert CA certificate to a value accepted by Policy Agent
                                                                                      • Provide converted CA certificate value to Policy Agent

                                                                                      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. To convert downloaded CA certificate to a value accepted by Policy Agent, open the downloaded 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 or PTY_ESA_CA_SERVER_CERT_SECRET Lambda variable in section Policy Agent Lambda Configuration

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

                                                                                      Identify or Create a new VPC

                                                                                      Establish a VPC where the Policy Agent will be hosted. This VPC will need connectivity to the ESA. The VPC should be in the same account and region established in Pre-Configuration.

                                                                                      VPC name: ___________________

                                                                                      VPC Subnet Configuration

                                                                                      Identify or create a new subnet in the VPC where tha Lambda function will be connected to. It is recommended to use a private subnet.

                                                                                      Subnet name: ___________________

                                                                                      NAT Gateway For ESA Hosted Outside AWS Network

                                                                                      If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                                                                      VPC Endpoints Configuration

                                                                                      If an internal VPC was created, then add VPC Endpoints, which will be used by the Policy Agent to access AWS services. Policy Agent needs access to the following AWS services:

                                                                                      Type

                                                                                      Service name

                                                                                      Interface

                                                                                      com.amazonaws.{REGION}.secretsmanager

                                                                                      Interface

                                                                                      com.amazonaws.{REGION}.kms

                                                                                      Gateway

                                                                                      com.amazonaws.{REGION}.s3

                                                                                      Interface

                                                                                      com.amazonaws.{REGION}.lambda

                                                                                      Identify or Create Security Groups

                                                                                      Policy Agent and cloud-based ESA appliance use AWS security groups to control traffic that is allowed to leave and reach them. Policy Agent runs on schedule and is mostly concerned with allowing traffic out of itself to ESA and AWS services it depends on. ESA runs most of the time and it must allow Policy Agent to connect to it.

                                                                                      Policy Agent security group must allow outbound traffic using rules described in the table below. To edit security group navigate:

                                                                                      From VPC > Security Groups > Policy Agent Security Group configuration.

                                                                                      TypeProtocolPort RangeDestinationReason
                                                                                      Custom TCPTCP443Policy Agent Lambda SGESA Communication
                                                                                      HTTPSTCP443AnyAWS Services

                                                                                      Record Policy Agent security group ID:

                                                                                      Policy Agent Security Group Id: ___________________

                                                                                      Policy Agent will reach out to ESA on port 443. Create following inbound security group rule for cloud-based ESA appliance to allow connections from Policy Agent:

                                                                                      TypeProtocolPort RangeSource
                                                                                      Custom TCPTCP443Policy Agent Lambda SG

                                                                                      Creating ESA Credentials

                                                                                      Policy Agent Lambda requires ESA credentials to be provided as one of the three options.

                                                                                      Option 1: Secrets Manager

                                                                                      Creating secrets manager secret with ESA username and password.

                                                                                      1. From the AWS Secrets Manager Console, select Store New Secret.

                                                                                      2. Select Other Type of Secrets.

                                                                                      3. Specify the username and password key value pair.

                                                                                      4. Select the encryption key or leave default AWS managed key.

                                                                                      5. Specify the Secret Name and record it.

                                                                                        ESA Credentials Secret Name: __________________

                                                                                      Option 2: KMS Encrypted Password

                                                                                      ESA password is encrypted with AWS KMS symmetric key.

                                                                                      1. Create AWS KMS symmetric key which will be used to encrypt ESA password. See Create KMS Key for instructions on how to create KMS symmetric key using AWS console.

                                                                                      2. Record KMS Key ARN.

                                                                                        ESA PASSWORD KMS KEY ARN: __________________

                                                                                      3. Run AWS CLI command to encrypt ESA password. Below you can find sample Linux aws cli command. Replace <key_arn> with KMS symmetric key ARN.

                                                                                        aws kms encrypt --key-id <key_arn> --plaintext $(echo '<esa_password>' | base64 )
                                                                                        
                                                                                      4. Sample output.

                                                                                        {
                                                                                          "CiphertextBlob": "esa_encrypted_password",
                                                                                          "KeyId": "arn:aws:kms:region:aws_account:key/key_id ",
                                                                                          "EncryptionAlgorithm": "SYMMETRIC_DEFAULT"
                                                                                        }
                                                                                        
                                                                                      5. Record ESA username and encrypted password.

                                                                                        ESA USERNAME: __________________

                                                                                        ESA ENCRYPTED PASSWORD: __________________

                                                                                      Option 3: Custom AWS Lambda function

                                                                                      With this option ESA username and password are returned by a custom AWS Lambda function. This method may be used to get the username and password from external vaults.

                                                                                      1. Create AWS Lambda in any AWS supported runtime.

                                                                                        1. There is no input needed.

                                                                                        2. The Lambda function must return the following response schema.

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

                                                                                          For example,

                                                                                          example output: {"username": "admin", "password": "Password1234"}
                                                                                          
                                                                                        3. Sample AWS Lambda function in Python:

                                                                                          import json
                                                                                          
                                                                                          def lambda_handler(event, context):
                                                                                          
                                                                                              return {"username": "admin", "password": "password1234"}
                                                                                          
                                                                                      2. Record the Lambda name:

                                                                                        Custom AWS lambda for ESA credentials: _______________

                                                                                      Create Agent Lambda IAM Policy

                                                                                      Follow the steps below to create Lambda execution policies.

                                                                                      Create Agent Lambda IAM policy

                                                                                      1. From AWS IAM console, select Policies > Create Policy.

                                                                                      2. Select JSON tab and copy the following snippet.

                                                                                        {
                                                                                          "Version": "2012-10-17",
                                                                                          "Statement": [
                                                                                            {
                                                                                              "Sid": "EC2ModifyNetworkInterfaces",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "ec2:CreateNetworkInterface",
                                                                                                "ec2:DescribeNetworkInterfaces",
                                                                                                "ec2:DeleteNetworkInterface"
                                                                                              ],
                                                                                              "Resource": "*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "CloudWatchWriteLogs",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "logs:CreateLogGroup",
                                                                                                "logs:CreateLogStream",
                                                                                                "logs:PutLogEvents"
                                                                                              ],
                                                                                              "Resource": "*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "LambdaUpdateFunction",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "lambda:UpdateFunctionConfiguration"
                                                                                              ],
                                                                                              "Resource": [
                                                                                                "arn:aws:lambda:*:*:function:*"
                                                                                              ]
                                                                                            },
                                                                                            {
                                                                                              "Sid": "LambdaReadLayerVersion",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "lambda:GetLayerVersion",
                                                                                                "lambda:ListLayerVersions"
                                                                                              ],
                                                                                              "Resource": "*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "LambdaDeleteLayerVersion",
                                                                                              "Effect": "Allow",
                                                                                              "Action": "lambda:DeleteLayerVersion",
                                                                                              "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "LambdaPublishLayerVersion",
                                                                                              "Effect": "Allow",
                                                                                              "Action": "lambda:PublishLayerVersion",
                                                                                              "Resource": "arn:aws:lambda:*:*:layer:*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "S3GetObject",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "s3:GetObject"
                                                                                              ],
                                                                                              "Resource": "arn:aws:s3:::*/*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "S3PutObject",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "s3:PutObject"
                                                                                              ],
                                                                                              "Resource": "arn:aws:s3:::*/*"
                                                                                            },
                                                                                            {
                                                                                              "Sid": "KmsEncrypt",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "kms:GetPublicKey"
                                                                                              ],
                                                                                              "Resource": [
                                                                                                "arn:aws:kms:*:*:key/*"
                                                                                              ]
                                                                                            },
                                                                                            {
                                                                                              "Sid": "SecretsManagerGetSecret",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                "secretsmanager:GetSecretValue"
                                                                                              ],
                                                                                              "Resource": [
                                                                                                "arn:aws:secretsmanager:*:*:secret:*"
                                                                                              ]
                                                                                            },
                                                                                            {
                                                                                              "Sid": "LambdaGetConfiguration",
                                                                                              "Effect": "Allow",
                                                                                              "Action": [
                                                                                                  "lambda:GetFunctionConfiguration"
                                                                                              ],
                                                                                              "Resource": [
                                                                                                  "arn:aws:lambda:*:*:function:*"
                                                                                              ]
                                                                                            }
                                                                                          ]
                                                                                        }
                                                                                        
                                                                                      3. Replace wildcard * with the region, account, and resource name information where required.

                                                                                      4. This step is required if KMS is used to encrypt ESA password.

                                                                                        Add policy entry below. Replace ESA PASSWORD KMS KEY ARN with the value recorded in Option 2: KMS Encrypted Password.

                                                                                        
                                                                                          {
                                                                                            "Sid": "KmsDecryptEsaPassword",
                                                                                            "Effect": "Allow",
                                                                                            "Action": [
                                                                                              "kms:Decrypt"
                                                                                            ],
                                                                                            "Resource": [
                                                                                              "**ESA PASSWORD KMS KEY ARN**"
                                                                                            ]
                                                                                          }
                                                                                        
                                                                                      5. Select Next type in the policy name and Create Policy. Record policy name:

                                                                                        Policy Name: ___________________

                                                                                      Create Agent Lambda IAM Role

                                                                                      Perform the following steps to create Agent Lambda execution IAM role.

                                                                                      To create agent Lambda IAM role:

                                                                                      1. From AWS IAM console, select Roles > Create Role.

                                                                                      2. Select AWS Service > Lambda > Next.

                                                                                      3. Select the policy created in Create Agent Lambda IAM policy.

                                                                                      4. Proceed to Name, Review and Create.

                                                                                      5. Type the role name, for example, ProtegrityAgentRole and click Confirm.

                                                                                      6. Select Create role.

                                                                                      7. Record the role ARN.

                                                                                        Agent Lambda IAM Execution Role Name: ___________________

                                                                                      Corporate Firewall Configuration

                                                                                      If an on-premise firewall is used, then the firewall must allow access from the NAT Gateway to an ESA. The firewall must allow access from the NAT Gateway IP to ESA via port 443 and 443.

                                                                                      CloudFormation Installation

                                                                                      Create the Policy Agent in the VPC using the CloudFormation script provided by Protegrity.

                                                                                      1. Access the CloudFormation service.

                                                                                      2. Select the target installation region.

                                                                                      3. Create a stack with new resources.

                                                                                      4. Upload the Policy Agent CloudFormation template (file name: pty_agent_cf.json).

                                                                                      5. Specify the following parameters for Cloud Formation:

                                                                                        ParameterDescriptionNote
                                                                                        VPCVPC where the Policy Agent will be hostedIdentify or Create a new VPC
                                                                                        SubnetSubnet where the Policy Agent will be hostedVPC Subnet Configuration
                                                                                        PolicyAgentSecurityGroupIdSecurity Group Id, which allows communication between the Policy Agent and the ESAIdentify or Create Security Groups
                                                                                        LambdaExecutionRoleArnAgent Lambda IAM execution role ARN allowing access to the S3 bucket, KMS encryption Key, Lambda and Lambda LayerCreate Agent Lambda IAM Role
                                                                                        ArtifactS3BucketS3 bucket name with deployment package for the Policy AgentUse S3 Bucket name recorded in Create S3 bucket for Installing Artifacts
                                                                                        CreateCRONJobSet to True to create a CloudWatch schedule for the agent to run.Default: False

                                                                                      Policy Agent Lambda Configuration

                                                                                      After the CloudFormation stack is deployed, the Policy Agent Lambda must be configured with parameters recorded in earlier steps. From your AWS Console, navigate to lambda and select the following Lambda.

                                                                                      Protegrity_Agent<STACK_NAME>_

                                                                                      Select Configuration tab and scroll down to the Environment variables section. Select Editand replace all entries with the actual values.

                                                                                      Parameter

                                                                                      Description

                                                                                      Notes

                                                                                      PTY_ESA_IP

                                                                                      ESA IP address or hostname

                                                                                      ESA Server

                                                                                      PTY_ESA_CA_SERVER_CERT

                                                                                      ESA self-signed CA certificate or your corporate CA certificate used by policy Agent Lambda 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.

                                                                                      PTY_ESA_CA_SERVER_CERT_SECRET

                                                                                      This configuration option fulfills the same function as PTY_ESA_CA_SERVER_CERT but supports larger configuration values, making it the recommended choice. The value should specify the name of the AWS Secrets Manager secret containing the ESA self-signed CA certificate. The secret value should be set to the json with “PTY_ESA_CA_SERVER_CERT” key and PEM formated CA certificate content value as shown below.

                                                                                      {
                                                                                        "PTY_ESA_CA_SERVER_CERT":"-----BEGIN CERTIFICATE----- MIIF..."
                                                                                      }
                                                                                      

                                                                                      Recorded in step Certificates on ESA

                                                                                      In case ESA is configured with publicly signed certificates, the PTY_ESA_CA_SERVER_CERT_SECRET configuration will be ignored. When both PTY_ESA_CA_SERVER_CERT and PTY_ESA_CA_SERVER_CERT_SECRET are configured the PTY_ESA_CA_SERVER_CERT_SECRET takes precedence.

                                                                                      PTY_ESA_CREDENTIALS_SECRET

                                                                                      ESA username and password (encrypted value by AWS Secrets Manager)

                                                                                      Option 1: Secrets Manager

                                                                                      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.

                                                                                      AWS_KMS_KEY_ID

                                                                                      KMS key id or full ARN e.g. arn:aws:kms:us-west-2:112233445566:key/bfb6c4fb-509a-43ac-b0aa-82f1ca0b52d3

                                                                                      Create KMS Key

                                                                                      AWS_POLICY_S3_BUCKET

                                                                                      S3 bucket where the encrypted policy will be written

                                                                                      S3 bucket of your choice

                                                                                      AWS_POLICY_S3_FILENAME

                                                                                      Filename of the encrypted policy stored in S3 bucket

                                                                                      Default: protegrity-policy.zip

                                                                                      AWS_PROTECT_FN_NAME

                                                                                      Comma separated list of Protect function names or ARNs

                                                                                      ProtectFunctionName(s), recorded in CloudFormation Installation

                                                                                      DISABLE_DEPLOY

                                                                                      This flag can be either 1 or 0. If set to 1, then the agent will not update PTY_PROTECT lambda with the newest policy. Else, the policy will be saved in the S3 bucket and deployed to the Lambda Layer

                                                                                      Default: 0

                                                                                      AWS_POLICY_LAYER_NAME

                                                                                      Lambda layer used to store the Protegrity policy used by the PTY_PROTECT function

                                                                                       

                                                                                      POLICY_LAYER_RETAIN

                                                                                      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: 2

                                                                                      POLICY_PULL_TIMEOUT

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

                                                                                      Default: 20s

                                                                                      ESA_CONNECTION_TIMEOUT

                                                                                      Time in seconds to wait for the ESA response

                                                                                      Default: 5s

                                                                                      LOG_LEVEL

                                                                                      Application and audit logs verbiage level

                                                                                      Default: INFO

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

                                                                                      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

                                                                                      PTY_CORE_CASESENSITIVE

                                                                                      Specifies whether policy usernames should be case sensitive

                                                                                      Default: no

                                                                                      Allowed values:

                                                                                      yes

                                                                                      no

                                                                                      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_ESA_USERNAME

                                                                                      Plaintext ESA username which is used together with PTY_ESA_ENCRYPTED_PASSWORD as an optional ESA credentials

                                                                                      Option 2: KMS Encrypted Password

                                                                                      Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                                                                      PTY_ESA_ENCRYPTED_PASSWORD

                                                                                      ESA password encrypted with KMS symmetric key.

                                                                                      Example AWS cli command to generate the value:

                                                                                      aws kms encrypt --key-id <your key ARN> --plaintext '<your-esa-password-base64>'

                                                                                      Option 2: KMS Encrypted Password

                                                                                      Presence of this parameter will cause PTY_ESA_CREDENTIALS_SECRET to be ignored

                                                                                      Value must be base64 encoded

                                                                                      EMPTY_POLICY_S3

                                                                                      This flag can be either 1 or 0. If set to 1, then the agent will remove the content of the policy file in S3 bucket, but will keep the checksum in the metadata. Else, the policy will be saved in the S3 bucket and not removed.

                                                                                      Default: 0

                                                                                      PTY_ESA_CREDENTIALS_LAMBDA

                                                                                      Lambda function to return ESA credentials

                                                                                      Recorded in step Option 3: Custom AWS Lambda function LAMBDA FOR ESA CREDENTIALS. Presence of PTY_ESA_USERNAME, or PTY_ESA_CREDENTIALS_SECRET will cause this value to be ignored.

                                                                                      The Policy Agent Lambda must have network access and IAM permissions to invoke the custom ESA Credentials Lambda you have created in Option 3: Custom AWS Lambda function.

                                                                                      Test Installation

                                                                                      Open the Lambda and configure Test to execute the lambda and specify the default test event. Wait for around 20 seconds for the Lambda to complete. If policy is downloaded successfully, then a success message appears.

                                                                                      Navigate to the AWS_POLICY_S3_BUCKET bucket and verify that the AWS_POLICY_S3_FILENAME file was created.

                                                                                      Troubleshooting

                                                                                      Lambda Error

                                                                                      Example Error

                                                                                      Action

                                                                                      Task timed out after x seconds

                                                                                      2020-10-06T23:40:54.121Z 2dc84942-b5cc-4be9-aa4c-965f322307e4 Task timed out after 90.09 seconds
                                                                                      
                                                                                      1. Ensure that there is network connectivity between the Lambda and ESA. Check the Security groups and/or Network firewall configuration
                                                                                      2. When using internal VPC, AWS Lambda needs to have access to AWS Network. The Policy Agent Lambda can start using Secrets Manager with Amazon VPC endpoints by creating an Amazon VPC endpoint for Secrets Manager.

                                                                                      ESA connection error. Failed to download certificates

                                                                                      Policy Pull takes a long time

                                                                                      {
                                                                                        "errorMessage": "Timeout! Unable to download policy in 20 seconds.",
                                                                                        "errorType": "Exception",
                                                                                        "stackTrace": [...]
                                                                                      }
                                                                                      
                                                                                      1. Increase POLICY_PULL_TIMEOUT.
                                                                                      2. Ensure that there is at least 1 policy with datastore matching the Lambda Policy Agent. Other considerations:
                                                                                        1. Policy has default datastore.
                                                                                        2. Policy has datastores matching AWS lambda IP range (check the subnet IP Range).
                                                                                        3. Lambda function has static IP, and at least one Data store has matching IP.

                                                                                      ESA connection error. Failed to download certificates. HTTP response code: 401

                                                                                      {
                                                                                        "errorMessage": "ESA connection error. Failed to download certificates. HTTP response code: 401.",
                                                                                        "errorType": "ConnectionError",
                                                                                        "stackTrace": [...]
                                                                                      }
                                                                                      

                                                                                      Ensure that the PTY_ESA_CREDENTIALS_SECRET has correct ESA username and password

                                                                                      An error occurred (AccessDeniedException) when calling xyz operation

                                                                                      xyz Access Denied: Exception
                                                                                      Traceback (most recent call last):
                                                                                        … Exception: xyz Access Denied
                                                                                      

                                                                                      Ensure that the Lambda execution role has permission to call the xyz operation

                                                                                      Access Denied to Secret Manager.

                                                                                      Secrets Manager Access Denied: Exception
                                                                                      Traceback (most recent call last):
                                                                                        … Exception: Secrets Manager Access Denied
                                                                                      
                                                                                      1. Ensure that the Lambda execution role has permissions to get the Secret Manager secret name.
                                                                                      2. Ensure that the Lambda execution role has permission to get the Secret Manager secret Encryption Key.

                                                                                      Master Key xyz unable to generate data key

                                                                                      Ensure that the Lambda can access xyz CMK key

                                                                                      The S3 bucket server-side encryption is enabled, the encryption key type is SSE-KMS but the Policy Agent execution IAM role doesn’t have permissions to encrypt using the KMS key .

                                                                                      [ERROR] PolicyAgentException: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied
                                                                                      

                                                                                      Add the following permissions to the Policy Agent excution role.

                                                                                      kms:Decrypt
                                                                                      kms:GenerateDatakey
                                                                                      

                                                                                      The S3 bucket has bucket policy to only allow access from within the VPC.

                                                                                      An error occurred (AccessDeniedException) when calling the PublishLayerVersion operation: Your access has been denied by S3,
                                                                                      please make sure your request credentials have permission to GetObject for BUCKET_NAME/FILENAME. S3 Error Code: AccessDenied. S3 Error Message: Access Denied
                                                                                      

                                                                                      The Policy Agent publishes a new Lambda Layer version, and the Lambda Layer service uploads the policy file from the s3 bucket and the upload request is originated from the AWS service outside the Policy Agent Lambda VPC. Update the S3 bucket resource policy to allow access from AWS Service. Sample security policy to lock down access to the vpc:

                                                                                      {
                                                                                        "Version": "2012-10-17",
                                                                                        "Statement": [
                                                                                          {
                                                                                            "Sid": "VpcRestrictions",
                                                                                            "Effect": "Deny",
                                                                                            "Principal": {
                                                                                              "AWS": "*"
                                                                                            },
                                                                                            "Action": "s3:*Object",
                                                                                            "Resource": [
                                                                                              "arn:aws:s3:::<s3_bucket_name>/*",
                                                                                              "arn:aws:s3:::<s3_bucket_name>"
                                                                                            ],
                                                                                            "Condition": {
                                                                                              "Bool": {
                                                                                                "aws:ViaAWSService": "false"
                                                                                              },
                                                                                              "StringNotEquals": {
                                                                                                "aws:sourceVpc": "<vpc_id>"
                                                                                              }
                                                                                            }
                                                                                          }
                                                                                        ]
                                                                                      }
                                                                                      

                                                                                      Additional Configuration

                                                                                      Strengthen the KMS IAM policy by granting access only to the required Lambda function(s).

                                                                                      Finalize the IAM policy for the Lambda Execution Role. Ensure to replace wildcard * with the region, account, and resource name information where required.

                                                                                      For example,

                                                                                      "arn:aws:lambda:*:*:function:*" -> "arn:aws:lambda:us-east-1:account:function:function_name"
                                                                                      

                                                                                      Policy Agent Schedule

                                                                                      If specified in CloudFormation Installation, the agent installation created a CloudWatch event rule, which checks for policy update on an hourly schedule. This schedule can be altered to the required frequency.

                                                                                      Under CloudWatch > Events > Rules, find Protegrity_Agent_{stack_name}. Click Action > Edit Set the cron expression. A cron expression can easily be defined using CronMaker, a free online tool. Refer to http://www.cronmaker.com.

                                                                                      1.4.2.5 - Audit Log Forwarder Installation

                                                                                      Install the audit log forwarder.

                                                                                        The following sections show steps how to install Audit Log Forwarder component in the AWS Cloud. The Log Forwarder deployment allows for the audit logs generated by Protector to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protector Service to work properly. See Log Forwarding Architecture section in this document for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. C ontact Protegrity for further guidance on configuration alternatives in the Cloud.

                                                                                        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 (Audit Store) or 24284 (td-agent).

                                                                                        2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                                        3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                                        Certificates on ESA

                                                                                        By default, ESA is configured with self-signed certificates, which can optionally be validated using a self-signed CA certificate supplied in the Log Forwarder configuration. If no CA certificate is provided, the Log Forwarder will skip server certificate validation.

                                                                                        If ESA is configured with publicly signed certificates, this section can be skipped since the forwarder Lambda will use the public CA to validate ESA certificates.

                                                                                        To obtain the 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 PtyEsaCaServerCert cloudformation parameter in section Install through CloudFormation

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

                                                                                        AWS VPC Configuration

                                                                                        Log forwarder Lambda function requires network connectivity to ESA, similar to Policy Agent Lambda function. Therefore, it can be hosted in the same VPC as Policy Agent.

                                                                                        Separate VPC can be used, as long as it provides network connectivity to ESA.

                                                                                        VPC Name: ___________________

                                                                                        VPC Subnet Configuration

                                                                                        Log Forwarder can be connected to the same subnet as Policy Agent or separate one as long as it provides connectivity to ESA.

                                                                                        Subnet Name: ___________________

                                                                                        NAT Gateway For ESA Hosted Outside AWS Network

                                                                                        If ESA server is hosted outside of the AWS Cloud network, the VPC configured for Lambda function must ensure additional network configuration is available to allow connectivity with ESA. For instance if ESA has a public IP, the Lambda function VPC must have public subnet with a NAT server to allow routing traffic outside of the AWS network. A Routing Table and Network ACL may need to be configured for outbound access to the ESA as well.

                                                                                        VPC Endpoint Configuration

                                                                                        Log Forwarder Lambda function requires connectivity to Secrets Manager AWS service. If the VPC identified in the steps before has no connectivity to public internet through the NAT Gateway, then the following service endpoint must be configured:

                                                                                        • com.amazonaws.{REGION}.cloudwatch
                                                                                        • com.amazonaws.{REGION}.secretsmanager
                                                                                        • com.amazonaws.{REGION}.kms

                                                                                        Security Group Configuration

                                                                                        Security groups restrict communication between Log Forwarder Lambda function and the ESA appliance. The following rules must be in place for ESA and Log Forwarder Lambda function.

                                                                                        From VPC > Security Groups > Log Forwarder Security Group configuration.

                                                                                        TypeProtocolPort RangeDestinationReason
                                                                                        Custom TCPTCP9200Log Forwarder Lambda SGESA Communication

                                                                                        Record the name of Log Forwarder security group name.

                                                                                        Log Forwarder Security Group Id: ___________________

                                                                                        The following port must be open for the ESA. If the ESA is running in the Cloud, then create the following security.

                                                                                        ESA Security Group configuration

                                                                                        TypeProtocolPort RangeSource
                                                                                        Custom TCPTCP9200Log Forwarder Lambda SG

                                                                                        Configure ESA Audit Store Credentials

                                                                                        Audit Log Forwarder can optionally authenticate with ESA using certificate-based authentication with a client certificate and certificate key. If used, both the certificate and certificate key will be stored in AWS Secrets Manager.

                                                                                        Download the following certificates from the /etc/ksa/certificates/plug directory of the ESA:

                                                                                        • client.key
                                                                                        • client.pem

                                                                                        After certificates are downloaded, open each 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 commands below depending on your operating system.

                                                                                        Linux Bash:

                                                                                        awk 'NF {printf "%s\\n",$0;}' client.key > private_key.txt
                                                                                        awk 'NF {printf "%s\\n",$0;}' client.pem > public_key.txt
                                                                                        

                                                                                        Windows PowerShell:

                                                                                        (Get-Content '.\client.key') -join '\n' | Set-Content 'private_key.pem'
                                                                                        (Get-Content '.\client.pem') -join '\n' | Set-Content 'public_key.pem'
                                                                                        

                                                                                        For more information on how to configure client certificate authentication for Audit Store on ESA refer to Audit Store Guide.

                                                                                        To create secret with ESA client certificate/key pair in AWS Secrets Manager.

                                                                                        1. From the AWS Secrets Manager Console, select Store New Secret.

                                                                                        2. Select Other Type of Secrets.

                                                                                        3. Specify the private_key and public_key value pair.

                                                                                        4. Select the encryption key or leave default AWS managed key.

                                                                                        5. Specify the Secret Name and record it below.

                                                                                          ESA Client Certificate/Key Pair Secret Name: ___________________

                                                                                          This value will be used to set PtyEsaClientCertificatesSecretId cloudformation parameter in section Install through CloudFormation

                                                                                        Create Audit Log Forwarder IAM Execution Policy

                                                                                        This task defines a policy used by the Protegrity Log Forwarder Lambda function to write CloudWatch logs, access the KMS encryption key to decrypt the policy and access Secrets Manager for log forwarder user credentials.

                                                                                        Perform the following steps to create the Lambda execution role and required policies:

                                                                                        1. From the AWS IAM console, select Policies > Create Policy.

                                                                                        2. Select the JSON tab and copy the following sample policy.

                                                                                          {
                                                                                            "Version": "2012-10-17",
                                                                                            "Statement": [
                                                                                              {
                                                                                                "Sid": "EC2ModifyNetworkInterfaces",
                                                                                                "Effect": "Allow",
                                                                                                "Action": [
                                                                                                  "ec2:CreateNetworkInterface",
                                                                                                  "ec2:DescribeNetworkInterfaces",
                                                                                                  "ec2:DeleteNetworkInterface"
                                                                                                ],
                                                                                                "Resource": "*"
                                                                                              },
                                                                                              {
                                                                                                "Sid": "CloudWatchWriteLogs",
                                                                                                "Effect": "Allow",
                                                                                                "Action": [
                                                                                                  "logs:CreateLogGroup",
                                                                                                  "logs:CreateLogStream",
                                                                                                  "logs:PutLogEvents"
                                                                                                ],
                                                                                                "Resource": "*"
                                                                                              },
                                                                                              {
                                                                                                "Sid": "KmsDecrypt",
                                                                                                "Effect": "Allow",
                                                                                                "Action": [
                                                                                                  "kms:Decrypt"
                                                                                                ],
                                                                                                "Resource": [
                                                                                                  "arn:aws:kms:*:*:key/*"
                                                                                                ]
                                                                                              },
                                                                                              {
                                                                                                  "Sid": "KinesisStreamRead",
                                                                                                  "Effect": "Allow",
                                                                                                  "Action": [
                                                                                                      "kinesis:GetRecords",
                                                                                                      "kinesis:GetShardIterator",
                                                                                                      "kinesis:DescribeStream",
                                                                                                      "kinesis:DescribeStreamSummary",
                                                                                                      "kinesis:ListShards",
                                                                                                      "kinesis:ListStreams"
                                                                                                  ],
                                                                                                  "Resource": "*"
                                                                                              },
                                                                                              {
                                                                                                "Sid": "SecretsManagerGetSecret",
                                                                                                "Effect": "Allow",
                                                                                                "Action": [
                                                                                                  "secretsmanager:GetSecretValue"
                                                                                                ],
                                                                                                "Resource": [
                                                                                                  "arn:aws:secretsmanager:*:*:secret:*"
                                                                                                ]
                                                                                              }
                                                                                            ]
                                                                                          }
                                                                                          
                                                                                        3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                                                                        4. Select Review policy, type in a policy name, for example, ProtegrityLogForwarderLambdaPolicy and Confirm. Record the policy name:

                                                                                          LogForwarderLambdaPolicyName:__________________

                                                                                        Create Log Forwarder IAM Role

                                                                                        Perform the following steps to create Log Forwarder execution IAM role.

                                                                                        To create Log Forwarder IAM role:

                                                                                        1. From AWS IAM console, select Roles > Create Role.

                                                                                        2. Select AWS Service > Lambda > Next.

                                                                                        3. Select the policy created in Create Audit Log Forwarder IAM Execution Policy.

                                                                                        4. Proceed to Name, Review and Create.

                                                                                        5. Type the role name, for example, ProtegrityForwarderRole and click Confirm.

                                                                                        6. Record the role ARN.

                                                                                          Log Forwarder IAM Execution Role Name: ___________________

                                                                                        Installation Artifacts

                                                                                        Audit Log Forwarder installation artifacts are part of the same deployment package as the one used for protect and policy agent services. Follow the steps below to ensure the right artifacts are available for log forwarder installation.

                                                                                        1. Verify that the Protegrity deployment package is available on your local system, if not, you can download it from the Protegrity portal.

                                                                                        2. Extract the pty_log_forwarder_cf.json cloud formation file from the deployment package.

                                                                                        3. Check the S3 deployment bucket identified in section Create S3 bucket for Installing Artifacts. Make sure that all Protegrity deployment zip files are uploaded to the S3 bucket.

                                                                                        Install through CloudFormation

                                                                                        The following steps describe the deployment of the Audit Log Forwarder AWS cloud components.

                                                                                        1. Access CloudFormation and select the target AWS Region in the console.

                                                                                        2. Click Create Stack and choose With new resources.

                                                                                        3. Specify the template.

                                                                                        4. Select Upload a template file.

                                                                                        5. Upload the Protegrity-provided CloudFormation template called pty_log_forwarder_cf.json and click Next.

                                                                                        6. Specify the stack details. Enter a stack name.

                                                                                        7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                                                                                        Parameter

                                                                                        Description

                                                                                        Default Value

                                                                                        Required

                                                                                        LogForwarderSubnets

                                                                                        Subnets where the Log Forwarder will be hosted.

                                                                                         

                                                                                         

                                                                                        LogForwarderSecurityGroups

                                                                                        Security Groups, which allow communication between the Log Forwarder and ESA.

                                                                                         

                                                                                        X

                                                                                        LambdaExecutionRoleArn

                                                                                        The ARN of Lambda role created in the prior step.

                                                                                         

                                                                                        X

                                                                                        ArtifactS3Bucket

                                                                                        Name of S3 bucket created in the pre-configuration step.

                                                                                         

                                                                                        X

                                                                                        LogDestinationEsaIp

                                                                                        IP or FQDN of the ESA instance or cluster.

                                                                                         

                                                                                        X

                                                                                        AuditLogOutput

                                                                                        Audit log processor to target on ESA. Allowed values: audit-store, td-agent

                                                                                        audit-store

                                                                                        X

                                                                                        PtyEsaClientCertificatesSecretId

                                                                                        AWS Secrets Manager secret id containing client certificates used for authentication with ESA Audit Store. It is expected that the public key will be stored in a field public_key and the private key in a field named private_key.

                                                                                        This parameter is optional. If not provided, Log Forwarder will connect to ESA without client certificate authentication.

                                                                                        EsaTlsDisableCertVerify

                                                                                        Disable certificate verification when connecting to ESA if set to 1. This is only for dev purposes, do not disable in production environment.

                                                                                        0

                                                                                        X

                                                                                        PtyEsaCaServerCert

                                                                                        ESA self-signed CA certificate used by log forwarder Lambda to ensure ESA is the trusted server.

                                                                                        Recorded in step Certificates on ESA

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

                                                                                         

                                                                                        EsaConnectTimeout

                                                                                        Time in seconds to wait for the ESA response. Minimum value: 1.

                                                                                        5

                                                                                        X

                                                                                        EsaVirtualHost

                                                                                        ESA virtual hostname. This configuration is optional and it can be used when proxy server is present and supports TLS SNI extension.

                                                                                         

                                                                                         

                                                                                        KinesisLogStreamRetentionPeriodHours

                                                                                        The number of hours for the log records to be stored in Kinesis Stream in case log destination server is not available. Minimum value: 24. See Log Forwarder Performance section for more details.

                                                                                        24

                                                                                        X

                                                                                        KinesisLogStreamShardCount

                                                                                        The number of shards that the Kinesis log stream uses. For greater provisioned throughput, increase the number of shards. Minimum value: 1. See Log Forwarder Performance section for more details.

                                                                                        10

                                                                                        X

                                                                                        MinLogLevel

                                                                                        Minimum log level for protect function. Allowed Values: off, severe, warning, info, config, all

                                                                                        severe

                                                                                        X

                                                                                        1. Click Next with defaults to complete CloudFormation.

                                                                                        2. After CloudFormation is completed, select the Outputstab in the stack.

                                                                                        3. Record the following values

                                                                                          KinesisLogStreamArn: ________________________________

                                                                                        Add Kinesis Put Record permission to the Protect Function IAM Role

                                                                                        1. Login to the AWS account that hosts the Protect Lambda Function.

                                                                                        2. Search for Protect Lambda Function IAM Execution Role Name created in Create Protect Lambda IAM role.

                                                                                        3. Under Permissions policies, select Add Permissions > Create inline policy.

                                                                                        4. In Specify permissions view, switch to JSON.

                                                                                        5. Copy the policy json from below replacing the placeholder value indicated in the following snippet as <Audit Log Kinesis Stream ARN> with the value recorded in the previous step.

                                                                                          {
                                                                                          	"Version": "2012-10-17",
                                                                                          	"Statement": [
                                                                                          		{
                                                                                          			"Sid": "KinesisPutRecords",
                                                                                          			"Effect": "Allow",
                                                                                          			"Action": "kinesis:PutRecords",
                                                                                          			"Resource": "<Audit Log Kinesis Stream ARN>"
                                                                                          		}
                                                                                          	]
                                                                                          }
                                                                                          
                                                                                        6. When you are finished, choose Next.

                                                                                        7. On the Review and create page, type a Name, then choose Create policy.

                                                                                        Test Log Forwarder Installation

                                                                                        Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                                        Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                                        1. Navigate to the log forwarder lambda function.

                                                                                        2. Select the Test tab.

                                                                                        3. Copy the json test event into the Event JSON pane.

                                                                                          {
                                                                                              "Records": [
                                                                                                  {
                                                                                                      "kinesis": {
                                                                                                          "kinesisSchemaVersion": "1.0",
                                                                                                          "partitionKey": "041e96d78c778677ce43f50076a8ae3e",
                                                                                                          "sequenceNumber": "49620336010289430959432297775520367512250709822916263938",
                                                                                                          "data": "eyJpbmdlc3RfdGltZV91dGMiOiIyMDI2LTAzLTI3VDEzOjIzOjEyLjkwNFoiLCJhZGRpdGlvbmFsX2luZm8iOnsiZGVzY3JpcHRpb24iOiJEYXRhIHVucHJvdGVjdCBvcGVyYXRpb24gd2FzIHN1Y2Nlc3NmdWwuIn0sImNsaWVudCI6e30sImNudCI6NCwiY29ycmVsYXRpb25pZCI6InJzLXF1ZXJ5LWlkOjEyMzQiLCJsZXZlbCI6IlNVQ0NFU1MiLCJsb2d0eXBlIjoiUHJvdGVjdGlvbiIsIm9yaWdpbiI6eyJob3N0bmFtZSI6IlBSTy1VUy1QRjNSSEdGOSIsImlwIjoiMTAuMTAuMTAuMTAiLCJ0aW1lX3V0YyI6MTcxMTU1OTEwMH0sInByb2Nlc3MiOnsiaWQiOjJ9LCJwcm90ZWN0aW9uIjp7ImF1ZGl0X2NvZGUiOjgsImRhdGFlbGVtZW50IjoiYWxwaGEiLCJkYXRhc3RvcmUiOiJTQU1QTEVfUE9MSUNZIiwibWFza19zZXR0aW5nIjoiIiwib2xkX2RhdGFlbGVtZW50IjpudWxsLCJvcGVyYXRpb24iOiJVbnByb3RlY3QiLCJwb2xpY3lfdXNlciI6IlBUWURFViJ9LCJwcm90ZWN0b3IiOnsiY29yZV92ZXJzaW9uIjoiMS4yLjErNTUuZzU5MGZlLkhFQUQiLCJmYW1pbHkiOiJjcCIsInBjY192ZXJzaW9uIjoiMy40LjAuMTQiLCJ2ZW5kb3IiOiJyZWRzaGlmdCIsInZlcnNpb24iOiIwLjAuMS1kZXYifSwic2lnbmF0dXJlIjp7ImNoZWNrc3VtIjoiN0VCMkEzN0FDNzQ5MDM1NjQwMzBBNUUxNENCMTA5QzE0OEJGODYwRjE3NEVCMjMxMTAyMEI3RkE1QTY4MjdGQyIsImtleV9pZCI6ImM0MjQ0MzZhLTExMmYtNGMzZi1iMmRiLTEwYmFhOGI1NjJhNyJ9fQ==",
                                                                                                          "approximateArrivalTimestamp": 1626878559.213
                                                                                                      },
                                                                                                      "eventSource": "aws:kinesis",
                                                                                                      "eventVersion": "1.0",
                                                                                                      "eventID": "shardId-000000000000:49620336010289430959432297775520367512250709822916261234",
                                                                                                      "eventName": "aws:kinesis:record",
                                                                                                      "invokeIdentityArn": "arn:aws:iam::555555555555:role/service-role/TestRole",
                                                                                                      "awsRegion": "us-east-1",
                                                                                                      "eventSourceARN": "arn:aws:kinesis:us-east-1:555555555555:stream/CloudProtectEventStream"
                                                                                                  }
                                                                                              ]
                                                                                          }
                                                                                          
                                                                                        4. Select Test to execute the test event.

                                                                                        5. Test is successful if the Log Output of test results contains the following log:

                                                                                          [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                                                                          

                                                                                          If the log is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                        Update Protector With Kinesis Log Stream

                                                                                        In this section, Kinesis log stream ARN will be provided to the Protect Function installation.

                                                                                        1. Navigate to the Protector CloudFormation stack created in the protector installation section.

                                                                                        2. Select Update.

                                                                                        3. Choose Use existing template > Next.

                                                                                        4. Set parameter KinesisLogStreamArn to the output value recorded in Install through CloudFormation.

                                                                                        5. Proceed with Next and Submit the changes.

                                                                                        6. Continue to the next section once stack status indicates UPDATE_COMPLETE.

                                                                                        Update Policy Agent With Log Forwarder Function Target

                                                                                        Log Forwarder Lambda function requires a policy layer which is in sync with the Protegrity Protector. This section will describe the steps to update the policy agent to include updating Log Forwarder Lambda function.

                                                                                        1. Navigate to the Policy Agent Function created in Policy Agent Installation

                                                                                        2. Select Configuration > Environment variables > Edit

                                                                                        3. Edit the value for environment variable AWS_PROTECT_FN_NAME to include the log forwarder function name/arn in the comma separated list of Lambda functions.

                                                                                        4. Save the changes and continue when update completes

                                                                                        5. Navigate to Test tab

                                                                                        6. Add an event {} and select Test to run the Policy Agent function

                                                                                        7. Verify Log forwarder function was updated to use the policy layer by inspecting the log output. Logs should include the following:

                                                                                          
                                                                                          [INFO] 2024-07-09 18:58:04,793.793Z 622d374b-1f73-4123-9a38-abc61973adef iap_agent.policy_deployer:Updating lambda [Protegrity_LogForwarder_<stack ID>] to use layer version [arn:aws:lambda:<aws region>:<aws account number>:layer:Protegrity_Layer_<layer name>:<layer version>]
                                                                                          

                                                                                        Test Full Log Forwarder Installation

                                                                                        Install and configure Protegrity Agent, Protector, and Log Forwarder components.

                                                                                        1. Send a protect operation to the protector using a data element or user which will result in audit log generation

                                                                                        2. Navigate to the CloudWatch log group for the Protect function

                                                                                        3. Select the log stream for the test operation and scroll to the latest logs

                                                                                        4. Expect to see a log similar to the below:

                                                                                          
                                                                                          [2024-07-09T19:28:23.158] [INFO] [kinesis-external-sink.cpp:51] Sending 2 logs to Kinesis ...
                                                                                          [2024-07-09T19:28:23.218] [INFO] [aws-utils.cpp:206] Kinesis send time: 0.060s
                                                                                          
                                                                                        5. Navigate to the CloudWatch log group for the Log Forwarder function

                                                                                        6. Expect to see a new log stream - it may take several minutes for the stream to start

                                                                                        7. Select the new stream and scroll to the most recent logs in the stream

                                                                                        8. Expect to see a log similar to the below:

                                                                                          
                                                                                          [2024-07-09T19:32:31.648] [INFO] [kinesis-log-aggregation-format.cpp:77] Aggregated 1 records into 0 aggregated, 1 forwarded and 0 failed records
                                                                                          

                                                                                        Troubleshooting

                                                                                        Error

                                                                                        Action

                                                                                        Log forwarder log contains severe level secrets permissions error:

                                                                                        [SEVERE] User: <arn> is not authorized to perform: secretsmanager:
                                                                                        GetSecretValue on resource: <secret name> because no identity-based
                                                                                        policy allows the secretsmanager:GetSecretValue action
                                                                                        
                                                                                        1. Verify the permission policy/role attached to the log forwarder function has secretsmanager:GetSecretValue permission for the insights esa user credentials secret.
                                                                                        2. Consult sections Configure ESA Audit Store Credentials and Create Audit Log Forwarder IAM Execution Policy

                                                                                        When testing log forwarder as described in Test Log Forwarder Installation, response contains policy decryption error:

                                                                                        
                                                                                        {
                                                                                          "error_msg": "Failed to decrypt the policy. Please verify
                                                                                            that the function has access to the key service and the key.",
                                                                                          "success": false
                                                                                        }
                                                                                        
                                                                                        1. Verify the permission policy/role attached to the log forwarder function has kms:Decrypt permission for KMS key used to encrypt the Protegrity security policy.
                                                                                        2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                                                                        Cloudformation stack creation fails with error:

                                                                                        
                                                                                        The provided execution role does not have permissions to call
                                                                                        [CreateNetworkInterface|DescribeNetworkInterfaces|DeleteNetworkInterface]
                                                                                        on EC2 (Service: Lambda, Status Code: 400, Request ID: <request id>)"
                                                                                        (RequestToken: <request token>, HandlerErrorCode: InvalidRequest)
                                                                                        
                                                                                        1. Verify the permission policy/role attached to the log forwarder function has ec2:CreateNetworkInterface, ec2:DescribeNetworkInterfaces, ec2:DeleteNetworkInterface permissions
                                                                                        2. Consult section Create Audit Log Forwarder IAM Execution Policy

                                                                                        Severe level kinesis permissions log message in protector function:

                                                                                        
                                                                                        [SEVERE] Kinesis stream client returned 400 error with error message:
                                                                                        User: <function arn> is not authorized to perform: kinesis:PutRecords
                                                                                        on resource: <kinesis stream arn> because no identity-based policy
                                                                                        allows the kinesis:PutRecords action
                                                                                        
                                                                                        1. Verify the permission policy/role attached to the protector function has kinesis:PutRecords permission
                                                                                        2. Consult section Add Kinesis Put Record permission to the Protect Function IAM Role

                                                                                        TLS errors reported in log forwarder function logs:

                                                                                        
                                                                                        [error] [tls] <error message>
                                                                                        
                                                                                        1. If ESA is using self-signed certificate, verify the correct ESA certificate has been given in the format described in Certificates on ESA

                                                                                        1.4.2.6 -

                                                                                        Prerequisites

                                                                                        Requirement

                                                                                        Detail

                                                                                        Protegrity distribution and installation scripts

                                                                                        These artifacts are provided by Protegrity

                                                                                        Protegrity ESA 10.0+

                                                                                        The Cloud VPC must be able to obtain network access to the ESA

                                                                                        AWS AccountRecommend creating a new sub-account for Protegrity Serverless
                                                                                        Snowflake cluster (Enterprise Edition)

                                                                                        1.4.2.7 -

                                                                                        Required Skills and Abilities

                                                                                        Role / Skillset

                                                                                        Description

                                                                                        AWS Account Administrator

                                                                                        To run CloudFormation (or perform steps manually), create/configure a VPC and IAM permissions.

                                                                                        Protegrity Administrator

                                                                                        The ESA credentials required to extract the policy for the Policy Agent

                                                                                        Network AdministratorTo open firewall to access ESA and evaluate AWS network setup
                                                                                        Snowflake AdministratorAccount Admin access required to setup access

                                                                                        1.4.2.8 -

                                                                                        AWS Services

                                                                                        The following table describes the AWS services that may be a part of your Protegrity installation.

                                                                                        Service

                                                                                        Description

                                                                                        Lambda

                                                                                        Provides serverless compute for Protegrity protection operations and the ESA integration to fetch policy updates or deliver audit logs.

                                                                                        API Gateway

                                                                                        Provides the endpoint and access control.

                                                                                        KMS

                                                                                        Provides secrets for envelope policy encryption/decryption for Protegrity.

                                                                                        Secrets Manager

                                                                                        Provides secrets management for the ESA credentials .

                                                                                        S3

                                                                                        Intermediate storage location for the encrypted ESA policy layer.

                                                                                        Kinesis

                                                                                        Required if Log Forwarder is to be deployed. Amazon Kinesis is used to batch audit logs sent from protector function to ESA.

                                                                                        VPC & NAT Gateway

                                                                                        Optional. Provides a private subnet to communicate with an on-prem ESA.

                                                                                        CloudWatch

                                                                                        Application and audit logs, performance monitoring, and alerts. Scheduling for the policy agent.

                                                                                        1.4.3 - Understanding Snowflake Objects

                                                                                        Key concepts in understanding the Protegrity Serverless with Snowflake.

                                                                                        1.4.3.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';
                                                                                                                    
                                                                                        

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

                                                                                        1.4.4 - Performance

                                                                                        Performance benchmarks and considerations.

                                                                                        1.4.4.1 - Performance Considerations

                                                                                        Performance benchmarks and considerations.

                                                                                        Performance Considerations

                                                                                        The following factors may cause variation in real performance versus benchmarks:

                                                                                        • Cold startup: The Lambda 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 Lambda 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.
                                                                                        • Noisy neighbors: There are many multi-tenant components in the Cloud. The same request may differ by 50% between runs regardless of Protegrity. A single execution may not be the best predictor of average performance.
                                                                                        • Lambda memory: AWS provides more virtual cores based on the memory configuration. The initial configuration of 1728 MB provides a good tradeoff between performance and cost with the benchmarked policy. Memory can be increased to optimize for your individual cases.
                                                                                        • Cluster size: Cluster size may make a significant difference depending on the workload.
                                                                                        • Number of operations Number of protect, unprotect and reprotect security operations.
                                                                                        • Lambda concurrency and burst quotas: AWS limits the number of concurrent executions and how quickly lambda can scale to meet demand. This is discussed in an upcoming section of the document.
                                                                                        • Size of data element: Operations on larger text consume time.

                                                                                        1.4.4.2 - Sample Benchmarks

                                                                                        Sample benchmarks for different cluster sizes.

                                                                                        Sample Benchmarks

                                                                                        The following benchmarks were performed against different cluster sizes. These are median times of approximately five runs each. The query unprotected six columns per row (first_name, last_name, email, postal_code, ssn, iban):

                                                                                        Rows x Cols# OpsSmallMediumLargeXL2XL
                                                                                        100K x 6 cols600K5.144.24.34.3
                                                                                        1M x 6 cols6M1110111011
                                                                                        10M x 6 cols60M21.521.520.524.529
                                                                                        100M x 6 cols600M--49.556.587

                                                                                        1.4.4.3 - Concurrency

                                                                                        Guidance on concurrency.

                                                                                        Concurrency

                                                                                        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

                                                                                        1.4.4.4 - Concurrency Tuning

                                                                                        Concurrency tuning considerations.

                                                                                          Lambda Tuning

                                                                                          AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region:

                                                                                          The concurrent executions quota cap is the maximum number of Lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                                                                                          The Burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. After the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response. Snowflake will generally retry until all requests succeed but may abort if a high percentage of failed responses occur.

                                                                                          The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended to select a Snowflake AWS region with the highest burst limits.

                                                                                          API Gateway Tuning

                                                                                          AWS maintains a Throttle quota for the API Gateway. By default, API Gateway limits concurrent requests to 10,000 requests per second and throttles subsequent traffic with a 429 Too Many Requests error response. This quota applies across all APIs in an account and region.

                                                                                          The API Gateway default quota may need to be increased based on the Concurrency table in Lambda Tuning. Keep in mind that hitting quota limits effectively throttles any other API services in the region.

                                                                                          The API Gateway also limits burst. Burst is the maximum number of concurrent requests that API Gateway can fulfill at any instant without returning 429 Too Many Requests error responses. This limit can be increased by AWS, but is not normally an adjustable.

                                                                                          Enable CloudWatch metrics within the API Gateway to monitor max concurrency and investigate throttling errors. See the Concurrency Troubleshooting section on interpreting CloudWatch metrics.

                                                                                          Quotas adjustments are applied for region and account. Throttling is also enabled by default in the API Gateway stage used by the Protegrity Lambda function. The stage configuration throttling must be adjusted if the quota is modified. Stage throttling is shown in the following image.

                                                                                          For example, a test query was executed against a 274 million record table on a 2X-Large Snowflake cluster using a query with 10 UDF columns. Using the reference table in the Concurrency table, the cluster would theoretically generate over 20,000 requests/sec to execute the given query. Using API Gateway’s default settings, the requests exceeding 10,000 requests/sec will be throttled. Therefore, this query may fail intermittently due to a high number of throttling errors.

                                                                                          After requesting a quota increase, AWS modified the account’s API Gateway throttling quota from 10,000 to 24,000, this same query succeeded without throttles. In addition, 8 concurrent queries also succeeded. Eight concurrent queries did not generate 8x the concurrent load due to the cluster’s own resource limitations. This indicates the cluster peaked.

                                                                                          Concurrency Troubleshooting

                                                                                          Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a Snowflake query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your API Gateway or Lambda services in the region.

                                                                                          Snowflake is tolerant of a certain ratio of failed requests and automatically retries. If a high percentage of requests fail, then the query may abort and the last error code will display in the console. For example, 429 Too Many Requests.

                                                                                          CloudWatch Metrics can be manually enabled on the API Gateway to reveal if quotas are being reached. Metrics aggregate errors into two buckets that are 4xx and 5xx. CloudWatch logs can be used to access the actual error code. The following table describes how to interpret the CloudWatch metrics.

                                                                                          Error typePossible issueRemedy
                                                                                          4xx errorsAPI Gateway burst or throttle quota exceededRequest an increase to the API Gateway throttle quota.
                                                                                          5xx errorsLambda concurrent requests or burst quota exceeded. Verify 4xx errors in Lambda Metrics.Request an increase the Lambda concurrent request quota

                                                                                          The following screenshot shows an example of searching CloudWatch Logs using Log Insights:

                                                                                          Cold-Start Performance

                                                                                          Cold-start vs warm execution refers to the state of the Lambda when a request is received. A cold-start undergoes additional initialization, such as, loading the security policy. Warm execution applies to all subsequent requests served by the Lambda. The following table shows an example how these states impact latency and performance.

                                                                                          Execution stateAvg. Execution DurationAvg. Total (w/ network latency)
                                                                                          Cold execution438 ms522 ms
                                                                                          Warm execution< 2ms84 ms

                                                                                          1.4.4.5 - Log Forwarder Performance Tuning

                                                                                          Guidance on concurrency.

                                                                                          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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Amazon Kinesis Stream where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated. 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 Cloud Formation Parameters

                                                                                            • AuditLogFlushInterval: Determines the minimum amount of time required for the audit log to be sent to Amazon Kinesis. Changing flush interval may affect the level of aggregation, which in turn may result in different number of connections and different data rates to Amazon Kinesis. Default value is 30 seconds.

                                                                                              Increasing the flush interval may result in higher aggregation of audit logs, in fewer connections to Amazon Kinesis, in higher latency of audit logs arriving to ESA and in higher data throughput.

                                                                                              Lowering the flush interval may result in lower aggregation of audit logs, in more connections to Amazon Kinesis, in lower latency of audit logs arriving to ESA and in lower data throughput.

                                                                                              It is not recommended to reduce the flush interval from default value in production environment as it may overload the Amazon Kinesis service. However, it may be beneficial to reduce flush interval during testing to make audit records appear on ESA faster.

                                                                                                

                                                                                          • Log Forwarder Cloud Formation Parameters

                                                                                            • Amazon KinesisLogStreamShardCount: The number of shards represents the level of parallel streams in the Amazon Kinesis and it is proportional to the throughput capacity of the stream. If the number of shards is too low and the volume of audit logs is too high, Amazon Kinesis service may be overloaded and some audit records sent from protect function may be lost.

                                                                                              Default value is 10, however you are advised to test with a production-like load to determine whether this is sufficient or not.

                                                                                            • Amazon KinesisLogStreamRetentionPeriodHours: The time for the audit records to be retained in Amazon Kinesis log stream in cases where log forwarder function is unable to read records from the Kinesis stream or send records to ESA, for example due to a connectivity outage. Amazon Kinesis will retain failed audit records and retry periodically until connectivity with ESA is restored or retention period expires.

                                                                                              Default value is 24 hours, however you are advised to review this value to align it with your Recovery Time Objective and Recovery Point Objective SLAs.

                                                                                                

                                                                                          • Monitoring Log Forwarder Resources

                                                                                            • Amazon Kinesis Stream Metrics: Any positive value in Amazon Kinesis PutRecords throttled records metric indicates that audit logs rate from protect function is too high. The recommended action is to increase the Amazon KinesisLogStreamShardCount or optionally increase the AuditLogFlushInterval.

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

                                                                                              [SEVERE] Dropped records: x.
                                                                                              
                                                                                            • Protect Function CloudWatch Logs: If protect function is unable to send logs to Amazon Kinesis, it will log the following message:

                                                                                              [SEVERE] Amazon Kinesis error, retrying in x ms (retry: y/z) ..."
                                                                                              

                                                                                              Any dropped audit log records will be reported with the following log message:

                                                                                              [SEVERE] Failed to send x/y audit logs to Amazon Kinesis.
                                                                                              

                                                                                          1.4.4.6 -

                                                                                          API Gateway Tuning

                                                                                          AWS maintains a Throttle quota for the API Gateway. By default, API Gateway limits concurrent requests to 10,000 requests per second and throttles subsequent traffic with a 429 Too Many Requests error response. This quota applies across all APIs in an account and region.

                                                                                          The API Gateway default quota may need to be increased based on the Concurrency table in Lambda Tuning. Keep in mind that hitting quota limits effectively throttles any other API services in the region.

                                                                                          The API Gateway also limits burst. Burst is the maximum number of concurrent requests that API Gateway can fulfill at any instant without returning 429 Too Many Requests error responses. This limit can be increased by AWS, but is not normally an adjustable.

                                                                                          Enable CloudWatch metrics within the API Gateway to monitor max concurrency and investigate throttling errors. See the Concurrency Troubleshooting section on interpreting CloudWatch metrics.

                                                                                          Quotas adjustments are applied for region and account. Throttling is also enabled by default in the API Gateway stage used by the Protegrity Lambda function. The stage configuration throttling must be adjusted if the quota is modified. Stage throttling is shown in the following image.

                                                                                          For example, a test query was executed against a 274 million record table on a 2X-Large Snowflake cluster using a query with 10 UDF columns. Using the reference table in the Concurrency table, the cluster would theoretically generate over 20,000 requests/sec to execute the given query. Using API Gateway’s default settings, the requests exceeding 10,000 requests/sec will be throttled. Therefore, this query may fail intermittently due to a high number of throttling errors.

                                                                                          After requesting a quota increase, AWS modified the account’s API Gateway throttling quota from 10,000 to 24,000, this same query succeeded without throttles. In addition, 8 concurrent queries also succeeded. Eight concurrent queries did not generate 8x the concurrent load due to the cluster’s own resource limitations. This indicates the cluster peaked.

                                                                                          1.4.4.7 -

                                                                                          Cold-Start Performance

                                                                                          Cold-start vs warm execution refers to the state of the Lambda when a request is received. A cold-start undergoes additional initialization, such as, loading the security policy. Warm execution applies to all subsequent requests served by the Lambda. The following table shows an example how these states impact latency and performance.

                                                                                          Execution stateAvg. Execution DurationAvg. Total (w/ network latency)
                                                                                          Cold execution438 ms522 ms
                                                                                          Warm execution< 2ms84 ms

                                                                                          1.4.4.8 -

                                                                                          Concurrency Troubleshooting

                                                                                          Hitting up against quota limits may indicate that quota adjustments are required. Exceeding quota limits may cause a Snowflake query to fail or reduce performance. In the worst case, significant throttling can impact the performance of all your API Gateway or Lambda services in the region.

                                                                                          Snowflake is tolerant of a certain ratio of failed requests and automatically retries. If a high percentage of requests fail, then the query may abort and the last error code will display in the console. For example, 429 Too Many Requests.

                                                                                          CloudWatch Metrics can be manually enabled on the API Gateway to reveal if quotas are being reached. Metrics aggregate errors into two buckets that are 4xx and 5xx. CloudWatch logs can be used to access the actual error code. The following table describes how to interpret the CloudWatch metrics.

                                                                                          Error typePossible issueRemedy
                                                                                          4xx errorsAPI Gateway burst or throttle quota exceededRequest an increase to the API Gateway throttle quota.
                                                                                          5xx errorsLambda concurrent requests or burst quota exceeded. Verify 4xx errors in Lambda Metrics.Request an increase the Lambda concurrent request quota

                                                                                          The following screenshot shows an example of searching CloudWatch Logs using Log Insights:

                                                                                          1.4.4.9 -

                                                                                          Lambda Tuning

                                                                                          AWS maintains quotas for Lambda concurrent execution. Two of these quotas impact concurrency and compete with other Lambdas in the same account and region:

                                                                                          The concurrent executions quota cap is the maximum number of Lambda instances that can serve requests for an account and region. The default AWS quota may be inadequate based on peak concurrency based on the table in the previous section. This quota can be increased with an AWS support ticket.

                                                                                          The Burst concurrency quota limits the rate at which Lambda will scale to accommodate demand. This quota is also per account and region. The burst quota cannot be adjusted. AWS will quickly scale until the burst limit is reached. After the burst limit is reached, functions will scale at a reduced rate per minute (e.g. 500). If no Lambda instances can serve a request, the request will fail with a 429 Too Many Requests response. Snowflake will generally retry until all requests succeed but may abort if a high percentage of failed responses occur.

                                                                                          The burst limit is a fixed value and varies significantly by AWS region. The highest burst (3,000) is currently available in the following regions: US West (Oregon), US East (N.Virginia), and Europe (Ireland). Other regions can burst between 500 and 1,000. It is recommended to select a Snowflake AWS region with the highest burst limits.

                                                                                          1.4.5 - Audit Logging

                                                                                          Audit log description/formatting

                                                                                            Audit Logging

                                                                                            Audit records and application logs stream to Amazon CloudWatch Logs or optionally be sent to ESA. 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 Amazon CloudWatch. Third-party solutions may be used if they are supported by Amazon Cloudwatch or AWS Lambda logging extensions. For more information about forwarding your audit records to ESA, contact Protegrity. For more information about Amazon CloudWatch, refer to the Amazon CloudWatch User Guide.

                                                                                            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

                                                                                            Example Audit Records

                                                                                            The following are sample audit messages:

                                                                                            Protect Success:

                                                                                            {
                                                                                                  "additional_info": {
                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                    "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",
                                                                                                    "ip": "127.0.0.1",
                                                                                                    "time_utc": 1635363966
                                                                                                  },
                                                                                                  "protection": {
                                                                                                    "dataelement": "deAddress",
                                                                                                    "operation": "Protect",
                                                                                                    "audit_code": 6,
                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                    "policy_user": "test_user"
                                                                                                  },
                                                                                                  process":{
                                                                                                    "name":"protect",
                                                                                                    "id":"13",
                                                                                                    "module":"coreprovider",
                                                                                                    "thread_id":"573580544",
                                                                                                    "user":"sbx_user1051",
                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                    "version":"UNKNOWN"
                                                                                                  },
                                                                                                  "client": {
                                                                                                    "ip":"169.254.62.117"
                                                                                                  },
                                                                                                  "protector": {
                                                                                                    "family": "cp",
                                                                                                    "version": "4.0.0.102",
                                                                                                    "vendor": "aws.snowflake",
                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                    "lambda_version":"4.0.1"
                                                                                                  },
                                                                                                  "signature": {
                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                    "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                  }
                                                                                                }
                                                                                            

                                                                                            User permission denied:

                                                                                            {
                                                                                                  "additional_info": {
                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                    "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",
                                                                                                    "ip": "127.0.0.1",
                                                                                                    "time_utc": 1635363966
                                                                                                  },
                                                                                                  "protection": {
                                                                                                    "dataelement": "deAddress",
                                                                                                    "operation": "Protect",
                                                                                                    "audit_code": 3,
                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                    "policy_user": "test_user"
                                                                                                  },
                                                                                                  process":{
                                                                                                    "name":"protect",
                                                                                                    "id":"13",
                                                                                                    "module":"coreprovider",
                                                                                                    "thread_id":"573580544",
                                                                                                    "user":"sbx_user1051",
                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                    "version":"UNKNOWN"
                                                                                                  },
                                                                                                  "client": {
                                                                                                    "ip":"169.254.62.117"
                                                                                                  },
                                                                                                  "protector": {
                                                                                                    "family": "cp",
                                                                                                    "version": "4.0.0.102",
                                                                                                    "vendor": "aws.snowflake",
                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                    "lambda_version":"4.0.1"
                                                                                                  },
                                                                                                  "signature": {
                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                    "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                  }
                                                                                                }
                                                                                            

                                                                                            Data element not found:

                                                                                            {
                                                                                                  "additional_info": {
                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                    "description": "The data element could not be found in the policy.",
                                                                                                    "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",
                                                                                                    "ip": "127.0.0.1",
                                                                                                    "time_utc": 1635363966
                                                                                                  },
                                                                                                  "protection": {
                                                                                                    "dataelement": "deAddress",
                                                                                                    "operation": "Protect",
                                                                                                    "audit_code": 2,
                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                    "policy_user": "test_user"
                                                                                                  },
                                                                                                  process":{
                                                                                                    "name":"protect",
                                                                                                    "id":"13",
                                                                                                    "module":"coreprovider",
                                                                                                    "thread_id":"573580544",
                                                                                                    "user":"sbx_user1051",
                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                    "version":"UNKNOWN"
                                                                                                  },
                                                                                                  "client": {
                                                                                                    "ip":"169.254.62.117"
                                                                                                  },
                                                                                                  "protector": {
                                                                                                    "family": "cp",
                                                                                                    "version": "4.0.0.102",
                                                                                                    "vendor": "aws.snowflake",
                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                    "lambda_version":"4.0.1"
                                                                                                  },
                                                                                                  "signature": {
                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                    "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                  }
                                                                                                }
                                                                                            

                                                                                            1.4.6 - 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.4.7 - Upgrading To The Latest Version

                                                                                            Instructions for upgrading the protector.

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

                                                                                              After downloading the deployment package from the Protegrity Portal, unzip the package to extract the artifact files. In the AWS Console, navigate to the S3 bucket that was previously created to upload deployment artifacts (see: Create S3 bucket for Installing Artifacts).

                                                                                              Upload the following artifacts to the S3 bucket:

                                                                                              - -
                                                                                              • protegrity-protect-<version>.zip
                                                                                              • protegrity-agent-<version>.zip
                                                                                              • protegrity-external-extension-<version>.zip
                                                                                              • protegrity-sample-policy-<version>.zip
                                                                                              • protegrity-protect-<version>.zip
                                                                                              • protegrity-agent-<version>.zip
                                                                                              • protegrity-external-extension-<version>.zip
                                                                                              • protegrity-sample-policy-<version>.zip
                                                                                              • protegrity-protect-<version>.zip
                                                                                              • protegrity-agent-<version>.zip
                                                                                              • protegrity-external-extension-<version>.zip
                                                                                              • protegrity-sample-policy-<version>.zip
                                                                                              • protegrity-athena-protect-udfs-<version>.jar
                                                                                              • protegrity-external-extension-<version>.zip
                                                                                              • protegrity-agent-<version>.zip
                                                                                              • protegrity-sample-policy-<version>.zip

                                                                                              If the release version matches your existing deployment, you don’t need to upload it again. Save the following artifacts on your local system so that you have them available during the next steps:

                                                                                              - -
                                                                                              • pty_protect_cf.json
                                                                                              • pty_agent_cf.json
                                                                                              • pty_protect_cf.json
                                                                                              • pty_agent_cf.json
                                                                                              • pty_protect_api_cf.json
                                                                                              • pty_agent_cf.json
                                                                                              • pty_log_forwarder_cf.json
                                                                                              • pty_athena_protect_cf.json
                                                                                              • pty_agent_cf.json

                                                                                              Perform the following steps to upgrade the Agent Lambda and Protect Lambda separately.

                                                                                              Disable Protegrity Agent Function CloudWatch Event Rule

                                                                                              Cloud Watch Event Rule is used to periodically run Protegrity Agent Function to synchronize policy from ESA. This functionality is optional when deploying Protegrity Serverless Solution. If the Event Rule is enabled, it must be disabled temporarily for the time of the upgrade process.

                                                                                              Follow the steps below to determine if your deployment uses Event Rule and disable it.

                                                                                              1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                                              2. Select Resources tab from the top portion of the screen.

                                                                                              3. Check if there is a resource with ScheduledRule LogicalID. If there is no such resource you can skip to Upgrading Policy Agent Lambda section. If the scheduled rule is there, continue with the next steps in this section.

                                                                                              4. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                                              5. Select Disable from the top-right portion of the screen. This will disable the rule. You will re-enable it after the upgrade process is complete.

                                                                                              Upgrading Policy Agent Lambda

                                                                                              1. Go to AWS Lambda console and select existing Protegrity Agent Lambda.

                                                                                              2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish. The version of Agent Lambda you just created will serve as restore point in the case you needed to rollback the upgrade.

                                                                                              3. Go to Lambda Configuration > Environment variables.

                                                                                              4. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                                                aws lambda get-function-configuration --function-name \
                                                                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                --query Environment > <function_name>_env_config.json
                                                                                                
                                                                                              5. Go to AWS Cloud Formation and select existing Protegrity Agent deployment stack.

                                                                                              6. Select Update. Check Replace current template > Upload a template file.

                                                                                              7. Upload pty_agent_cf.json file and select Next.

                                                                                              8. Click Next until Review window and then select Update stack.

                                                                                              9. Wait for the Cloud Formation to complete.

                                                                                              10. Navigate back to Agent Lambda Function.

                                                                                              1. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                                                aws lambda update-function-configuration --function-name \
                                                                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                --environment file://./<function_name>_env_config.json
                                                                                                
                                                                                              2. If you are upgrading from versions prior to v3.0, backup and remove existing policy from the bucket defined by AWS_POLICY_S3_BUCKET property, so that the policy can be re-downloaded and re-encrypted with new ‘key commitment’ feature.

                                                                                              3. If you are upgrading from version prior to 1.6.1 please follow the steps below, otherwise the upgrade process is completed.

                                                                                              4. From AWS Console, navigate to IAM > Policies

                                                                                              5. Search for the Agent Lambda IAM Policy created in Create Agent Lambda IAM policy

                                                                                              6. Click on the policy, then select Edit Policy. Select JSON tab.

                                                                                              7. Add the following statement to the list of policy statements.

                                                                                                
                                                                                                {
                                                                                                  "Sid": "LambdaGetConfiguration",
                                                                                                  "Effect": "Allow",
                                                                                                  "Action": [
                                                                                                      "lambda:GetFunctionConfiguration"
                                                                                                  ],
                                                                                                  "Resource": [
                                                                                                      "arn:aws:lambda:*:*:function:*"
                                                                                                  ]
                                                                                                }
                                                                                                
                                                                                              8. Click Review Policy, then Save Changes. Wait for the changes to save.

                                                                                              Upgrading Log Forwarder Lambda

                                                                                              • Publish Log Forwarder Lambda Version

                                                                                                Publishing a version of the Log Forwarder Lambda allows to roll-back to pre-existing version if upgrade fails

                                                                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                                                2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                                                3. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                                                  Log Forwarder Lambda version number for roll-backs: ___________________

                                                                                              • Disable Kinesis Trigger

                                                                                                Disabling Kinesis trigger ensures there are no unprocessed or re-processed events while function is upgraded.

                                                                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                                                2. Select Configuration tab > Triggers
                                                                                                3. Check Kinesis trigger and click Edit button
                                                                                                4. Uncheck Activate trigger and click Save
                                                                                                5. Wait for function to stop processing events by monitoring function in Monitor tab
                                                                                              • Upgrade Forwarder Lambda Version

                                                                                                Upgrade Log Forwarder function with new code

                                                                                                1. Go to AWS Cloud Formation and select existing Protegrity Log Forwarder deployment stack.
                                                                                                2. Select Update Stack > Make a direct update.
                                                                                                3. Select Replace existing template > Upload a template file.
                                                                                                4. Upload pty_log_forwarder_cf file and select Next.
                                                                                                5. Click Next until Review window and then select Update stack.
                                                                                                6. Wait for the Cloud Formation to complete.
                                                                                              • Enable Kinesis Trigger

                                                                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                                                2. Select Configuration tab > Triggers
                                                                                                3. Check Kinesis trigger and click Edit button
                                                                                                4. Check Activate trigger and click Save Log Forwarder function will now start processing events from where it left off when Kinesis trigger was disabled.
                                                                                              • Monitor and roll-back

                                                                                                Monitor Log Forwarder function for errors in its CloudWatch logs and in Montior tab. To roll back function to the previous version if any errors occur follow these steps:

                                                                                                1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                                                2. Select Configuration tab > Triggers

                                                                                                3. Expand Details section of Kinesis trigger and record UUID value

                                                                                                4. Execute the following AWS CLI command to move Kinesis trigger to previous version of Log Forwarder Lambda that was created earlier and recorded as Log Forwarder Lambda version number for roll-backs. Substitute kinesis-mapping-uuid, log-forwarder-function-name, version-for-roll-backs with your values:

                                                                                                  
                                                                                                  aws lambda update-event-source-mapping --uuid <kinesis-mapping-uuid> --function-name <log-forwarder-function-name>:<version-for-roll-backs>
                                                                                                  
                                                                                                5. Find Kinesis trigger attached to previous version of Log Forwarder Lambda by navigating Versions tab > Version number link in the Versions column Kinesis trigger is now moved to previous version of Log Forwarder Lambda function.

                                                                                              Upgrading Protect Lambda

                                                                                              Diagram below illustrates upgrade steps.

                                                                                              Snowflake Function Upgrade Steps

                                                                                              Redshift Function Upgrade Steps

                                                                                              Cloud API Function Upgrade Steps

                                                                                              Athena Function Upgrade Steps

                                                                                              • Publish Protect Lambda Version

                                                                                                Publishing a version of the Protect Lambda allows updating it without interruptions to the existing traffic.

                                                                                                1. Go to AWS Lambda console and select existing Protegrity Protect Lambda.

                                                                                                2. Go to Lambda Configuration > Environment variables.

                                                                                                3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                                                  aws lambda get-function-configuration --function-name \
                                                                                                  arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                  --query Environment > <function_name>_env_config.json
                                                                                                  
                                                                                                4. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                                                5. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                                                  Protect Lambda version number: ___________________

                                                                                                6. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                                                  CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                                      RETURNS varchar
                                                                                                      VOLATILE lambda
                                                                                                      'Protegrity_Protect_test:<protect_lambda_version_number>' iam_role
                                                                                                      'arn:aws:iam::123456789212:role/example_role';
                                                                                                  
                                                                                              • Run protect service upgrade

                                                                                                In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                                                                                                1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                                                2. Select Update. Check Replace current template > Upload a template file.

                                                                                                3. Upload pty_protect_cf.json file and select Next.

                                                                                                4. Update ProtectFunctionProductionVersion parameter with Protect Lambda version number recorded in step 3.

                                                                                                5. Click Next until Review window and then select Update stack.

                                                                                                6. Wait for the Cloud Formation to complete.

                                                                                                7. Go back to Lambda console and select Protect Lambda.

                                                                                                8. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                                                  aws lambda update-function-configuration --function-name \
                                                                                                  arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                  --environment file://./<function_name>_env_config.json
                                                                                                  
                                                                                                9. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                                                                                                10. The upgraded Protect Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.

                                                                                              • Finalize upgrade

                                                                                                In this step, the Protect Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                                                                                                1. Go back to Protegrity AWS Cloud Formation deployment stack.

                                                                                                2. Select Update. Check Use Current template.

                                                                                                3. Update ProtectFunctionProductionVersion parameter with the following value: $LATEST.

                                                                                                4. Click Next until Review window and then select Update stack.

                                                                                                5. Go back to Lambda console and select Protect Lambda.

                                                                                                6. From the Lambda console, verify that Latest alias points to $LATEST version.

                                                                                                7. Test your function to make sure it works as expected.

                                                                                                8. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                                                  CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                                      RETURNS varchar
                                                                                                      VOLATILE lambda
                                                                                                      'Protegrity_Protect_test:Production' iam_role
                                                                                                      'arn:aws:iam::123456789212:role/example_role';
                                                                                                  
                                                                                                9. If you need to rollback to older version of Protect Lambda, you can re-run the cloud formation with ProtectFunctionProductionVersion parameter set to the previous version of Protect Lambda.

                                                                                              Re-enable Protegrity Agent Function CloudWatch Event Rule

                                                                                              If the Event Rule was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to re-enable Policy Agent Event rule.

                                                                                              1. Go to the Protegrity Agent Cloud Formation Stack.

                                                                                              2. Select Resources tab from the top portion of the screen.

                                                                                              3. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                                              4. Select Enable from the top-right portion of the screen. This will enable the rule. You will re-enable it after the upgrade process is complete.

                                                                                              1.4.8 - Known Limitations

                                                                                              Known product limitations.

                                                                                              Known Limitations

                                                                                              Known product limitations:

                                                                                              • FPE is supported only for ASCII values.
                                                                                              • Only the protect and unprotect operations are supported. The reprotect operation is not currently supported.

                                                                                              1.4.9 - Appendices

                                                                                              Additional references for the protector.

                                                                                              1.4.9.1 - Sample Snowflake External Function

                                                                                              A collection of sample Snowflake functions.

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              

                                                                                               

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              

                                                                                               

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              

                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                              
                                                                                              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 '<AWS API GATEWAY URL>/SF_CUSTOMER';
                                                                                               
                                                                                              

                                                                                              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.

                                                                                              1.4.9.2 - Installing the Policy Agent and Protector in Different AWS Accounts

                                                                                              Example steps to install Agent in a different AWS account than the Protector

                                                                                                The Policy Agent Lambda function and Protect Lambda functions can be installed in separate AWS accounts. However, additional configuration is required to authorize the Policy Agent to provision the security policy to a remote Protect Lambda function.

                                                                                                Create Agent Lambda IAM policy

                                                                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                                                                2. From the AWS IAM console, select Policies > Create Policy.

                                                                                                3. Select the JSON tab and copy the following snippet.

                                                                                                  {
                                                                                                    "Version": "2012-10-17",
                                                                                                    "Statement": [
                                                                                                      {
                                                                                                        "Sid": "LambdaUpdateFunction",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                          "lambda:UpdateFunctionConfiguration"
                                                                                                        ],
                                                                                                        "Resource": [
                                                                                                          "arn:aws:lambda:*:*:function:*"
                                                                                                        ]
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "LambdaReadLayerVersion",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                          "lambda:GetLayerVersion",
                                                                                                          "lambda:ListLayerVersions"
                                                                                                        ],
                                                                                                        "Resource": "*"
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "LambdaDeleteLayerVersion",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": "lambda:DeleteLayerVersion",
                                                                                                        "Resource": "arn:aws:lambda:*:*:layer:*:*"
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "LambdaPublishLayerVersion",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": "lambda:PublishLayerVersion",
                                                                                                        "Resource": "arn:aws:lambda:*:*:layer:*"
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "S3GetObject",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                          "s3:GetObject"
                                                                                                        ],
                                                                                                        "Resource": "arn:aws:s3:::*/*"
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "S3PutObject",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                          "s3:PutObject"
                                                                                                        ],
                                                                                                        "Resource": "arn:aws:s3:::*/*"
                                                                                                      },
                                                                                                      {
                                                                                                        "Sid": "LambdaGetConfiguration",
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                            "lambda:GetFunctionConfiguration"
                                                                                                        ],
                                                                                                        "Resource": [
                                                                                                            "arn:aws:lambda:*:*:function:*"
                                                                                                        ]
                                                                                                      }
                                                                                                    ]
                                                                                                  }
                                                                                                  
                                                                                                4. Replace the wildcards (*) with the region, account, and resource name information where required.

                                                                                                5. Select Review policy, type in the policy name, and confirm. Record policy name:

                                                                                                  Agent Lambda Cross Account Policy Name: ___________________

                                                                                                Create Policy Agent cross-account IAM Role

                                                                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                                                                2. From the AWS IAM console, select Roles > Create Role

                                                                                                3. Select AWS Service > Lambda . Proceed to Permissions.

                                                                                                4. Select Policy created in the step above. Proceed to Tags.

                                                                                                5. Specify Tag, proceed to the final screen. Type in policy name and confirm. Record the name.

                                                                                                  Policy Agent Cross Account IAM Role Name: ___________________

                                                                                                Allow the Policy Agent Cross-Account Role to be Assumed by the Policy Agent IAM Role

                                                                                                1. Login to the AWS account that hosts the Protect Lambda function.

                                                                                                2. Navigate to the previously created IAM Role (Agent Lambda Cross-Account IAM Role Name).

                                                                                                3. Navigate to Trust Relationships > Edit Trust Relationships.

                                                                                                4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda IAM Execution Role ARN> with ARN of Agent Lambda IAM Role that was created in Agent Installation.

                                                                                                  {
                                                                                                    "Version": "2012-10-17",
                                                                                                    "Statement": [
                                                                                                      {
                                                                                                        "Effect": "Allow",
                                                                                                  
                                                                                                     "Principal": {
                                                                                                  
                                                                                                              "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                                                                  
                                                                                                        },
                                                                                                        "Action": "sts:AssumeRole"
                                                                                                      }
                                                                                                    ]
                                                                                                  }
                                                                                                  
                                                                                                5. Click Update Trust Policy.

                                                                                                Add Assume Role to the Policy Agent Execution IAM Role

                                                                                                1. Login to the AWS account that hosts the Policy Agent.

                                                                                                2. Navigate to the Agent Lambda IAM Execution Role that was created in Agent Installation.

                                                                                                  {
                                                                                                    "Version": "2012-10-17",
                                                                                                    "Statement": [
                                                                                                      {
                                                                                                        "Effect": "Allow",
                                                                                                  
                                                                                                     "Principal": {
                                                                                                  
                                                                                                              "AWS": "<Agent Lambda IAM Execution Role Name>"
                                                                                                  
                                                                                                        },
                                                                                                        "Action": "sts:AssumeRole"
                                                                                                      }
                                                                                                    ]
                                                                                                  }
                                                                                                  
                                                                                                3. Add Inline Policy.

                                                                                                4. Modify the Policy Document, replacing the placeholder value indicated in the following snippet as <Agent Lambda Cross-Account IAM ARN> with the value recorded in Create Policy Agent cross-account IAM Role.

                                                                                                  {
                                                                                                    "Version": "2012-10-17",
                                                                                                    "Statement": [
                                                                                                      {
                                                                                                        "Effect": "Allow",
                                                                                                        "Action": [
                                                                                                          "sts:AssumeRole"
                                                                                                        ],
                                                                                                        "Resource": "<Agent Lambda Cross-Account IAM  ARN>."
                                                                                                      }
                                                                                                    ]
                                                                                                  }
                                                                                                  
                                                                                                5. When you are finished, choose Review Policy.

                                                                                                6. On the Review policy page, type a Name, then choose Create Policy.

                                                                                                Update the Policy Agent Lambda Configuration

                                                                                                1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                                                                2. Select Configuration tab | Environment variables.

                                                                                                3. Select Edit and add the following environment variables with the value from Agent Lambda Cross-Account IAM ARN:

                                                                                                  ParameterValue
                                                                                                  AWS_ASSUME_ROLEAgent Lambda Cross-Account IAM ARN
                                                                                                4. Ensure the values in the Parameters AWS_POLICY_S3_BUCKET, AWS_PROTECT_FN_NAME and AWS_POLICY_LAYER_NAME are all in the Protect Lambda Function AWS Account.

                                                                                                5. In case custom VPC hostname configuration is used, you will need to set the ENDPOINT_URL. Refer to Policy Agent - Custom VPC Endpoint Hostname Configuration.

                                                                                                  AWS_VPC_ENDPOINT_URL

                                                                                                  <AWS_VPC_ENDPOINT>

                                                                                                6. Click Save and Run the Lambda. The Lambda will now assume the Role in Protect Lambda Function AWS Account and update the policy cross accounts.

                                                                                                1.4.9.3 - 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.4.9.4 - Policy Agent - Custom VPC Endpoint Hostname Configuration

                                                                                                  Custom vpc endpoint hostname configuration

                                                                                                  The Policy Agent uses default endpoint hostnames to communicate with other AWS services (for example, secretsmanager.amazonaws.com). This configuration will only work in VPCs where Amazon-provided DNS is available (default VPC configuration with private DNS option enabled for the endpoint). If your VPC uses custom DNS, follow the instructions below to configure the Policy Agent Lambda to use custom endpoint hostnames.

                                                                                                  Identify DNS Hostnames

                                                                                                  To identify DNS hostnames:

                                                                                                  1. From AWS console, select VPC > Endpoints.

                                                                                                  2. Select Secrets Manager endpoint from the list of endpoints.

                                                                                                  3. Under Details > DNS Names, note the private endpoint DNS names adding https:// at the beginning of the endpoint name.

                                                                                                    For example, https://vpce-1234-4pzomrye.kms.us-west-1.vpce.amazonaws.com

                                                                                                  4. Note down DNS names for the KMS and Lambda endpoints:

                                                                                                    AWS_SECRETSMANAGER_ENDPOINT: https://_________________

                                                                                                    AWS_KMS_ENDPOINT: https://_________________

                                                                                                    AWS_LAMBDA_ENDPOINT: https://_________________

                                                                                                  Update the Policy Agent Lambda configuration

                                                                                                  To update policy agent lambda configuration:

                                                                                                  1. From the AWS console, navigate to Lambda, and select the Policy Agent Lambda function.

                                                                                                  2. Select the Configuration section and choose Environment variables.

                                                                                                  3. Select Edit and add the following environment variables with the corresponding endpoint URLs recorded in steps 3-4:

                                                                                                    ParametersValue
                                                                                                    AWS_SECRETSMANAGER_ENDPOINT_URL<AWS_SECRETS_ENDPOINT>
                                                                                                    AWS_KMS_ENDPOINT_URL<AWS KMS ENDPOINT>
                                                                                                    AWS_LAMBDA_ENDPOINT_URL<AWS LAMBDA ENDPOINT>
                                                                                                  4. Click Save and Run the Lambda. The Lambda will now use endpoints you have just configured.

                                                                                                  1.4.9.5 - 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.4.9.6 - Configuring Regular Expression to Extract Policy Username

                                                                                                  Extract the policy username from the AWS identity.

                                                                                                  Configuring Regular Expression to Extract Policy Username

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

                                                                                                  • USERNAME_REGEX Lambda Environment configuration

                                                                                                    The USERNAME_REGEX configuration can be used to extract policy username from user in the request. The following are allowed values for USERNAME_REGEX:

                                                                                                    • 1 - Default build-in regular expression is used:

                                                                                                      ^arn:aws:(?:iam|sts)::[0-9]{12}:(?:role|user|group|assumed\-role|federated\-user)\/([\w\/+=,.\-]{1,1024}|[\w\/+=,.\-@]{1,1024})(?:@[a-zA-Z0-9\-]{1,320}(?:\.\w+)+)?$
                                                                                                      
                                                                                                    • ^User regex$ - Custom regex 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

                                                                                                  arn:aws:iam::123456789012:user/juliet.snow

                                                                                                  arn:aws:iam::123456789012:user/juliet.snow

                                                                                                  arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                                                  arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                                                  1

                                                                                                  arn:aws:iam::123456789012:user/juliet.snow

                                                                                                  juliet.snow

                                                                                                  arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                                                  TestSaml

                                                                                                  ^arn:aws:(?:iam|sts)::[0-9]{12}:((?:role|user|group|assumed-role|federated-user).*)$
                                                                                                  

                                                                                                  arn:aws:iam::123456789012:user/juliet.snow

                                                                                                  user/juliet.snow

                                                                                                  arn:aws:sts::123456789012:assumed-role/TestSaml

                                                                                                  assumed-role/TestSaml

                                                                                                  1.4.9.7 - Associating ESA Data Store With Cloud Protect Agent

                                                                                                  Configure ESA data store for Policy Agent.

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

                                                                                                  The Lambda service uses multiple network interfaces, internal network interface with ephemeral IP range of 169.254.x.x and external network interface with IP range of the VPC subnet the Lambda is associated with. By default, when agent lambda is contacting ESA to register node for policy download, ESA uses agent Lambda VPC 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 lambda, 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 VPC subnet IPProxy IPESA config - ASSIGN_DATASTORE_USING_NODE_IPAgent lambda config - PTY_ADDIPADDRESSHEADERAgent node registration IP
                                                                                                  169.254.144.8110.1.2.173No Proxytrueyes169.254.144.81
                                                                                                  trueno10.1.2.173
                                                                                                  falseyes
                                                                                                  falseno
                                                                                                  169.254.144.8110.1.2.17334.230.42.110trueyes169.254.144.81
                                                                                                  trueno34.230.42.110
                                                                                                  falseyes
                                                                                                  falseno

                                                                                                  1.5 - Amazon S3

                                                                                                  Cloud Storage Protector - Amazon.

                                                                                                  This document describes high-level architecture of the Cloud Storage Protector on AWS, the installation procedures and provides guidance on performance. This document should be used in conjunction with the Cloud API on AWS Protegrity 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.5.1 - Overview

                                                                                                  Solution overview and features.

                                                                                                    Solution Overview

                                                                                                    S3 Protector automatically protects files that are uploaded to an Amazon S3 source bucket and writes the processed result to an output bucket. Amazon S3 event notifications trigger the protector, and Cloud Protect API applies the configured Protegrity protection rules to the selected columns in each file.

                                                                                                    For most deployments, users only need to decide where files arrive, where protected files should be written, and which mapping.json rules apply to each dataset. The service then processes the file automatically.

                                                                                                    The solution requires Protegrity Cloud Protect API on AWS. Cloud Protect API provides the endpoint used by S3 Protector to perform Protegrity operations as part of cloud-based data pipelines.

                                                                                                    Protected files can be used as source for a data lake or downstream database ingestion. For example:

                                                                                                    • Snowflake Snowpipe can be used to automatically ingest protected files as they are written by the S3 Protector.
                                                                                                    • Amazon Redshift provides a mechanism for bulk loading data from Amazon S3 using the COPY INTO command.

                                                                                                    Like other Protegrity products, S3 Protector uses the data security policy maintained on Enterprise Security Appliance (ESA). The ESA policy user supplied during setup acts as the service account for the deployment. For more information about policy user configuration, refer to the Enterprise Security Administrator Guide.

                                                                                                    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 Storage Protector - Amazon S3 service.

                                                                                                    Features

                                                                                                    Protegrity S3 Protector provides the following features:

                                                                                                    • Fine-grained field-level protection for structured data with the following formats supported:

                                                                                                      File FormatSuffix
                                                                                                      CSV.csv
                                                                                                      JSON.json
                                                                                                      Parquet.parquet
                                                                                                      Excel.xlsx
                                                                                                    • Role-based access control (RBAC) to protect and unprotect (re-identify) data depending on 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.5.2 - Architecture

                                                                                                    Deployment architecture and connectivity

                                                                                                      Deployment Architecture

                                                                                                      The Protegrity S3 solution should be deployed in the customer’s Cloud account within the same AWS region as the Protegrity Cloud Protect API. The Cloud Protect API is required.

                                                                                                      Two S3 Buckets are required for processing data with S3 Protector:

                                                                                                      • Source bucket for collecting data and triggering protection job.
                                                                                                      • Target bucket for processed files.

                                                                                                      The following diagram shows the high-level architecture of the S3 Protector.

                                                                                                      The ruleset for processing a type of input dataset is defined by a metadata file called mapping.json. The mapping.json provides:

                                                                                                      • processing instructions for each column of the input data file
                                                                                                      • specification for reading the input data file
                                                                                                      • specification for writing the processed data file

                                                                                                      Input and output data file specifications provide flexibility for common file structures. Column instructions define the protect operation and data element to apply for each column. The mapping.json can be loaded from multiple locations. Review Mapping File section for details.

                                                                                                      The Protegrity S3 protector invokes the Cloud Protect API to execute the policy on the data. The processed data is saved to the specified target S3 bucket.

                                                                                                      The target bucket can be the basis of a data lake or a staging area to load databases. For example, Snowflake Snowpipe can be used to automatically ingest the processed (ie. Protected) data into Snowflake. Amazon Redshift provides a similar mechanism for bulk loading data from Amazon S3.

                                                                                                      For more information about installing and managing the Cloud API component, refer to the Cloud API on AWS Protegrity documentation.

                                                                                                      AWS Lambda Timeout

                                                                                                      S3 Protector runs in AWS Lambda. Each Lambda invocation has a maximum execution time called a timeout. When you install this product with the supplied CloudFormation template, the timeout is set to 15 minutes, the maximum timeout allowed by AWS. If S3 Protector runs out of time while processing a file, it will fail with Status: timeout, which will appear in the logs similar to the following:

                                                                                                      REPORT RequestId: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa	Duration: 300000.00 ms	Billed Duration: 300000 ms	Memory Size: 1728 MB	Max Memory Used: 654 MB	Init Duration: 3868.74 ms	Status: timeout
                                                                                                      

                                                                                                      When S3 Protector runs out of time, an output upload may remain incomplete. Incomplete uploads do not appear in the S3 console, however you are still charged for them. Review AWS documentation on how to manage incomplete multipart uploads, for example:

                                                                                                      1. AWS CLI Documentation
                                                                                                      2. AWS Knowledge Center blog post

                                                                                                      There is no way to automatically re-start this product from where it has timed out while processing a file. To reduce the likelihood of a timeout error, consider the following:

                                                                                                      1. Increase function timeout to its maximum of 15 minutes
                                                                                                      2. Ensure LARGE_FILE_DISPATCH_THRESHOLD_BYTES is smaller than the file size to enable file processing in chunks. Files larger than this size will be processed in parallel by multiple S3 Protector instances.
                                                                                                      3. Reduce LARGE_FILE_CHUNK_SIZE_BYTES to make separate file chunks smaller.
                                                                                                      4. Increase FILE_CHUNK_SIZE to reduce the number of read/write operations for large files.
                                                                                                      5. Review MAX_BATCH_SIZE and MAX_PARALLEL_PROTECT_CALLS to balance throughput with Cloud API capacity.
                                                                                                      6. Ensure sufficient concurrency of Cloud Protect API functions.
                                                                                                      7. Increase memory allocated to the Lambda function, which also increases CPU and network throughput.

                                                                                                      Parquet Timestamp

                                                                                                      Parquet files define file schema with a data type for each column. S3 Protector uses Pandas library to process data in the source file. Pandas library represents timestamps as 64-bit integers representing microseconds since the UNIX epoch. The supported date range for this representation is between ‘1677-09-21 00:12:43.145224’ and ‘2262-04-11 23:47:16.854775’. To correctly handle timestamps outside of this range, S3 Protector will treat every timestamp column in a source file as a string column. The schema of protected file will differ from the source file, where every protected timestamp column will be converted to a string column.

                                                                                                      1.5.3 - Installation

                                                                                                      Instructions for installing Cloud Storage Protector Service.

                                                                                                      1.5.3.1 - Prerequisites

                                                                                                      Requirements before installing the protector.

                                                                                                        AWS Services

                                                                                                        The following table describes the AWS services that may be a part of your Protegrity installation.

                                                                                                        ServiceDescription
                                                                                                        LambdaProvides serverless compute for S3 Protector.
                                                                                                        S3Input and Output data to be processed with S3 Protector.
                                                                                                        CloudWatchApplication and audit logs, performance monitoring, and alerts.

                                                                                                        Prerequisites

                                                                                                        RequirementDetail
                                                                                                        S3 Protector distribution and installation scriptsThese artifacts are provided by Protegrity
                                                                                                        Protegrity Cloud Protect API distribution and installation scriptsThese artifacts are provided by Protegrity
                                                                                                        AWS AccountRecommend using the same AWS account as the Protegrity Cloud API deployment.

                                                                                                        Required Skills and Abilities

                                                                                                        Role / SkillsetDescription
                                                                                                        AWS Account AdministratorTo run CloudFormation (or perform steps manually), create/configure S3, VPC and IAM permissions.
                                                                                                        Protegrity AdministratorThe ESA credentials required to read the policy configuration.

                                                                                                        What’s Next

                                                                                                        1.5.3.2 - Pre-Configuration

                                                                                                        Configuration steps before installing the protector.

                                                                                                          Provide AWS sub-account

                                                                                                          Identify or create an AWS account where the Protegrity solution will be installed. The installation instructions assume the same AWS account and region are used for Cloud Protect API deployment.

                                                                                                          AWS Account ID: ___________________

                                                                                                          AWS Region: ___________________

                                                                                                          Create S3 bucket for Installing Artifacts

                                                                                                          This S3 bucket will be used for the artifacts required by the CloudFormation installation steps. This S3 bucket must be created in the region that is defined in Provide AWS sub-account.

                                                                                                          To create S3 bucket for installing artifacts:

                                                                                                          1. Sign in to the AWS Management Console and open the Amazon S3 console.

                                                                                                          2. Change region to the one determined in Provide AWS sub-account

                                                                                                          3. Click Create Bucket.

                                                                                                          4. Enter a unique bucket name:

                                                                                                            For example, protegrity-install.us-west-2.example.com.

                                                                                                          5. Upload the installation artifacts to this bucket. Protegrity will provide the following artifacts.

                                                                                                            • protegrity-s3-protector-<version>.zip

                                                                                                            Artifact S3 Bucket Name: ___________________

                                                                                                          Cloud Protect API function

                                                                                                          Protegrity Cloud Protect API on AWS is required for the S3 Protector installation. The binaries of the Cloud Protect API on AWS are distributed with the S3 Protector installation package. See the Cloud Protect API on AWS documentation on how to create a new installation if one is not already available in your account/region. With Cloud Protect API on AWS installed, follow the below instructions to obtain the ARN of the protector lambda function.

                                                                                                          Follow these steps to obtain Cloud API Lambda ARN.

                                                                                                          1. Access the AWS Management Console.

                                                                                                          2. Navigate to the Cloud Protect API function in the AWS Lambda service.

                                                                                                          3. Open the Cloud Protect API function.

                                                                                                          4. From the Lambda view, choose Aliases, then click on Production alias.

                                                                                                          5. At the top right, copy the Lambda function ARN and record it. The Cloud API Production Alias ARN will be used later in this installation guide when creating IAM policy and deploying S3 Protector with Cloud Formation template.

                                                                                                          Cloud Protect API function ARN: ____________________

                                                                                                          S3 Buckets For Input And Output Data

                                                                                                          Two S3 buckets are required. One bucket is used for incoming files. The second bucket is used for files processed by the S3 Protector. The buckets must be different. The S3 buckets should be created in the region that is defined in Provide AWS sub-account.

                                                                                                          Identify existing bucket names or follow the steps below to create new buckets.

                                                                                                          1. Sign in to the AWS Management Console and open the Amazon S3 console.

                                                                                                          2. Change region to the one determined in Provide AWS sub-account

                                                                                                          3. Select Create Bucket.

                                                                                                          4. Enter a globally unique bucket name. For example: in.us-west-2.example.com or out.us-west-2.example.com.

                                                                                                          5. Scroll down and configure S3 bucket security features. It is strongly recommend to keep Block all public access on. It is also recommend to enable server-side encryption.

                                                                                                          6. Record bucket names. They will be required later in this installation guide.

                                                                                                          Input S3 Bucket Name: ____________________

                                                                                                          Output S3 Bucket Name: ____________________

                                                                                                          What’s Next

                                                                                                          1.5.3.3 - S3 Protector Service Installation

                                                                                                          Install the S3 protector service.

                                                                                                            Preparation

                                                                                                            Ensure that all the steps in Pre-Configuration are performed.

                                                                                                            1. Login to the AWS sub-account console where Protegrity will be installed.

                                                                                                            2. Ensure that the required CloudFormation templates provided by Protegrity are available on your local computer.

                                                                                                            Create S3 Protector Lambda IAM Execution Policy

                                                                                                            The below steps create an IAM policy for use by the Protegrity Lambda function. The policy grants permissions to:

                                                                                                            • Write logs to CloudWatch
                                                                                                            • Read from the input S3 bucket
                                                                                                            • Read S3 object tags for optional file-specific mapping selection
                                                                                                            • Create temporary objects in the source bucket when optional large-file processing is enabled
                                                                                                            • Write to output S3 bucket
                                                                                                            • Invoke Cloud Protect API function

                                                                                                            Steps

                                                                                                            1. From the AWS IAM console, select PoliciesCreate Policy.

                                                                                                            2. Select the JSON tab and copy the following sample policy:

                                                                                                            {
                                                                                                              "Version": "2012-10-17",
                                                                                                              "Statement": [
                                                                                                                {
                                                                                                                  "Sid": "CloudWatchWriteLogs",
                                                                                                                  "Effect": "Allow",
                                                                                                                  "Action": [
                                                                                                                    "logs:CreateLogGroup",
                                                                                                                    "logs:CreateLogStream",
                                                                                                                    "logs:PutLogEvents"
                                                                                                                  ],
                                                                                                                  "Resource": "*"
                                                                                                                },
                                                                                                                {
                                                                                                                  "Sid": "SourceS3Access",
                                                                                                                  "Effect": "Allow",
                                                                                                                  "Action": [
                                                                                                                    "s3:GetObject",
                                                                                                                    "s3:GetObjectVersion",
                                                                                                                    "s3:GetObjectAcl",
                                                                                                                    "s3:ListBucket",
                                                                                                                    "s3:DeleteObject",
                                                                                                                    "s3:PutObject",
                                                                                                                    "s3:GetObjectTagging"
                                                                                                                  ],
                                                                                                                  "Resource": [
                                                                                                                    "arn:aws:s3:::PLACEHOLDER_S3_IN_BUCKET_NAME",
                                                                                                                    "arn:aws:s3:::PLACEHOLDER_S3_IN_BUCKET_NAME/*"
                                                                                                                  ]
                                                                                                                },
                                                                                                                {
                                                                                                                  "Sid": "WriteS3Out",
                                                                                                                  "Effect": "Allow",
                                                                                                                  "Action": [
                                                                                                                    "s3:PutObject",
                                                                                                                    "s3:ListBucket",
                                                                                                                    "s3:PutObjectAcl",
                                                                                                                    "s3:DeleteObject"
                                                                                                                  ],
                                                                                                                  "Resource": [
                                                                                                                    "arn:aws:s3:::PLACEHOLDER_S3_OUT_BUCKET_NAME",
                                                                                                                    "arn:aws:s3:::PLACEHOLDER_S3_OUT_BUCKET_NAME/*"
                                                                                                                  ]
                                                                                                                },
                                                                                                                {
                                                                                                                  "Sid": "InvokeCloudProtectApi",
                                                                                                                  "Effect": "Allow",
                                                                                                                  "Action": [
                                                                                                                    "lambda:InvokeFunction"
                                                                                                                  ],
                                                                                                                  "Resource": [
                                                                                                                    "PLACEHOLDER_CLOUD_PROTECT_API_ARN"
                                                                                                                  ]
                                                                                                                }
                                                                                                              ]
                                                                                                            }
                                                                                                            
                                                                                                            1. Replace the PLACEHOLDER values with the values recorded in earlier steps:

                                                                                                              • Cloud Protect API prerequisites
                                                                                                              • S3 Data Buckets prerequisites
                                                                                                            2. Select Review policy, type in a policy name (e.g., ProtegrityS3ProtectorLambdaPolicy) and Confirm.

                                                                                                            3. Record the policy name.

                                                                                                              S3 Protector Function Policy Name: __________________


                                                                                                            Create S3 Protector Lambda IAM Role

                                                                                                            The following steps create the role to utilize the policy defined in the previous section.

                                                                                                            Steps

                                                                                                            1. From the AWS IAM console, select RoleCreate Role.

                                                                                                            2. Select AWS ServiceLambdaPermissions.

                                                                                                            3. In the list, search and select the policy created in the previous step.

                                                                                                            4. Proceed to Tags.

                                                                                                            5. Proceed to final step of the wizard.

                                                                                                            6. Type the role name (e.g., ProtegrityS3ProtectorLambdaRole) and click Confirm.

                                                                                                            7. Record the role ARN.

                                                                                                              Protegrity S3 Protector Lambda Role ARN: ___________________


                                                                                                            Install through CloudFormation

                                                                                                            The following steps describe deployment of the S3 Protector Lambda Function using CloudFormation.

                                                                                                            1. Access CloudFormation and select the target AWS Region in the console.

                                                                                                            2. Click Create Stack and choose With new resources.

                                                                                                            3. Specify the template.

                                                                                                            4. Select Upload a template file.

                                                                                                            5. Upload the Protegrity-provided CloudFormation template called pty_s3_protector_cf.json and click Next.

                                                                                                            6. Specify the stack details. Enter a stack name.

                                                                                                            7. Enter the required parameters. All the values were generated in the pre-configuration steps.

                                                                                                            CloudFormation Parameters

                                                                                                            ParameterDescriptionDefault Value
                                                                                                            ArtifactS3BucketThe name of the S3 bucket containing deployment package for S3 Protector. Use Artifact S3 Bucket Name recorded in prerequisites.
                                                                                                            Allowed pattern: [a-zA-Z0-9.\-_]+
                                                                                                            CloudApiProtectorLambdaArnThe ARN of the Cloud Protect API Lambda which will be invoked by S3 Protector Lambda. Use Cloud Protect API function ARN recorded in prerequisites.
                                                                                                            Allowed pattern: arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}(-gov)?-[a-z]+-\d{1}:\d{12}:function:[a-zA-Z0-9-_\.]+(:(\$LATEST|[a-zA-Z0-9-_]+))?
                                                                                                            DeleteInputFilesDelete the input files after they have been successfully processed.
                                                                                                            Allowed values: [true, false]
                                                                                                            true
                                                                                                            FileChunkSizeThe number of rows read from the source file per iteration. Bounded by application memory. Independent of MaxBatchSize.
                                                                                                            Allowed pattern: [0-9]+
                                                                                                            100000
                                                                                                            IncludeHeaderAdd header to output data.
                                                                                                            Allowed values: [true, false]
                                                                                                            true
                                                                                                            LambdaExecutionRoleArnS3 Protector Lambda IAM execution role ARN allowing access to CloudWatch logs and S3 bucket. Use Protegrity S3 Protector Lambda Role ARN recorded previously.
                                                                                                            Allowed pattern: arn:(aws[a-zA-Z-]*)?:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+
                                                                                                            LargeFileChunkSizeBytesTarget byte size of each dispatch chunk when large-file dispatch is active. Must be between 104857600 (100 MB) and 10737418240 (10 GB). Only used when LargeFileDispatchThresholdBytes is set. Recommended minimum: 104857600 (100 MB).104857600
                                                                                                            LargeFileDispatchThresholdBytesFiles at or above this byte size are split into parallel dispatch chunks. Leave empty to disable large-file dispatch - all files are processed in a single Lambda invocation. When set, must be >= 104857600 (100 MB). Recommended minimum: 262144000 (250 MB).262144000
                                                                                                            MappingConfigBucketThe name of the S3 bucket containing mapping.json configuration files. When set, mapping files are read from this dedicated bucket instead of the source data bucket, keeping the source bucket free of non-data objects. Leave empty to use the source bucket.
                                                                                                            MaxBatchSizeThe maximum number of rows to process in single Cloud API invocation. Bounded by the 6 MB Lambda payload limit.
                                                                                                            Allowed pattern: [0-9]+
                                                                                                            25000
                                                                                                            MaxParallelProtectCallsMaximum number of concurrent Cloud API protect Lambda invocations per file chunk. 0 = unlimited (all batches across all columns run fully concurrently) .
                                                                                                            Allowed pattern: [0-9]+
                                                                                                            1000
                                                                                                            MinLogLevelMinimum log level for S3 protector function.
                                                                                                            Allowed values: [off, severe, warning, info, config, all]
                                                                                                            severe
                                                                                                            OutputFileCompressionTypeCompression type to apply to processed files in the output s3 bucket.
                                                                                                            Allowed values: [gzip, none]
                                                                                                            gzip
                                                                                                            OutputFileFormatFormat of the processed file saved in the output s3 bucket.
                                                                                                            Allowed values: [csv, json, parquet, preserve_input_format, use_mapping_spec, xlsx]
                                                                                                            preserve_input_format
                                                                                                            OutputFileNamePostfixPostfix to append to processed file names in the output s3 bucket.
                                                                                                            Allowed values: [none, timestamp]
                                                                                                            timestamp
                                                                                                            OutputS3BucketNameThe name of the output S3 bucket where protected files will be saved. Use Output S3 Bucket Name recorded in prerequisites.
                                                                                                            Allowed pattern: [a-zA-Z0-9.\-_]+
                                                                                                            PolicyUserThe name of the authorized user in the Protegrity security policy. This is the user which will be applied to every protect operation.
                                                                                                            PreserveParquetFooterMetadataWhen true, key-value metadata stored in the Parquet file footer of the source file is copied verbatim into the footer of the output file. Has no effect when the output format is not Parquet.false
                                                                                                            LambdaFunctionProductionVersionS3 Protector Lambda version handling service requests.
                                                                                                            Allowed pattern: ([0-9]+|\$LATEST)
                                                                                                            $LATEST
                                                                                                            1. Click Next with defaults to complete CloudFormation.

                                                                                                            2. After CloudFormation is completed, select the Outputs tab in the stack.

                                                                                                            3. Record the S3 Protector Lambda Name and Arn.

                                                                                                              S3 Protector Lambda Name: __________________________

                                                                                                              S3 Protector Lambda Arn: ________________________________


                                                                                                            Test S3 Protector Function Configuration

                                                                                                            Perform the following steps to verify that S3 Protector Function can read files from input S3 bucket, call Cloud API protector and write data to output S3 bucket.

                                                                                                            Before you begin:

                                                                                                            1. Update S3 Protector Cloud Formation stack with temporary settings used for testing:
                                                                                                              • In AWS Cloud Formation console, go to Stacks
                                                                                                              • Select Cloud Formation stack deployed in the installation step
                                                                                                              • In the stack details pane, choose Update
                                                                                                              • Select Use existing template and then choose Next
                                                                                                              • Change the following parameters:
                                                                                                            ParameterValueNote
                                                                                                            DeleteInputFilesfalseFor testing purposes input file will not be deleted after it’s processed.
                                                                                                            MinLogLevelconfigConfig level prints verbose log messages.
                                                                                                            OutputFileCompressionTypenoneFor testing purposes compression is disabled for quicker visual verification of the output file.
                                                                                                            • Select Next and then Submit. Wait until the changes are deployed.
                                                                                                            1. Upload sample data file to S3 input bucket.

                                                                                                            data.csv:

                                                                                                            first name,last name,email
                                                                                                            tusqB,FrjKe,ebMgF.VoiDd@bqclblD.wOt
                                                                                                            JXVVW,acg,BikPa.ufb@UmPxcTD.bLh
                                                                                                            mDNJ,IZWCYkbnrAs,NWXD.GdrzMJwmwJG@fMZsuSE.Qlp
                                                                                                            jIqColWOss,XKfz,NVabzoUSgx.XRHM@BQleCST.Mnb
                                                                                                            muUxYvz,FLZxCHlca,eiNjzCm.UMRNYANwn@isvxpAV.PJk
                                                                                                            
                                                                                                            1. Upload mapping.json to the input S3 bucket next to the input data file. Replace placeholders with data element names configured in your security policy. If your Cloud Protect API Function uses sample policy you can replace “protect” with “unprotect” for operation and use “alpha” as data element.
                                                                                                            {
                                                                                                             "columns":{
                                                                                                                "first name":{
                                                                                                                  "operation":"protect",
                                                                                                                  "data_element":"<data_element_1_name>"
                                                                                                                },
                                                                                                                "last name":{
                                                                                                                  "operation":"protect",
                                                                                                                  "data_element":"<data_element_2_name>"
                                                                                                                },
                                                                                                                "email":{
                                                                                                                  "operation":"protect",
                                                                                                                  "data_element":"<data_element_3_name>"
                                                                                                                }
                                                                                                             }
                                                                                                            }
                                                                                                            

                                                                                                            Execute S3 Protector Function in AWS console:

                                                                                                            With the input data file and mapping file uploaded, follow the steps below to trigger the S3 Protect Function.

                                                                                                            1. Sign in to the AWS Management Console and go to Lambda console.

                                                                                                            2. Select Lambda Function recorded in S3 Protector Lambda Name in Install through CloudFormation section.

                                                                                                            3. On the S3 Protector Function page, choose Test tab.

                                                                                                            4. Copy the json test event into the Event JSON pane - replace bucket name placeholder with your input bucket name.

                                                                                                              {
                                                                                                                "Records": [
                                                                                                                  {
                                                                                                                    "s3": {
                                                                                                                      "bucket": {
                                                                                                                        "name": "<PLACEHOLDER_S3_IN_BUCKET_NAME>"
                                                                                                                      },
                                                                                                                      "object": {
                                                                                                                        "key": "data.csv"
                                                                                                                      }
                                                                                                                    }
                                                                                                                  }
                                                                                                                ]
                                                                                                              }
                                                                                                              
                                                                                                            5. Select Test to execute the test event.

                                                                                                            Verify execution results:

                                                                                                            1. Execution is successful if the output of test contains the following:
                                                                                                            {
                                                                                                              "statusCode": 200,
                                                                                                              "body": {
                                                                                                                "target": "s3://<PLACEHOLDER_S3_OUT_BUCKET_NAME>/data.<timestamp>.csv"
                                                                                                              }
                                                                                                            }
                                                                                                            

                                                                                                            If the expected output is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                                            1. Download the output file mentioned in the response body in the “target” field. Verify that it was processed according to your mapping.json. If sample policy was used with “unprotect” and “alpha” data element, the output file should contain values below:
                                                                                                            first name,last name,email
                                                                                                            Lorem,Ipsum,lorem.ipsum@example.com
                                                                                                            Dolor,Sit,dolor.sit@example.com
                                                                                                            Amet,Consectetur,amet.consectetur@example.com
                                                                                                            Adipiscing,Elit,adipiscing.elit@example.com
                                                                                                            Vivamus,Elementum,vivamus.elementum@example.com
                                                                                                            

                                                                                                            Restore production configuration:

                                                                                                            After S3 Protector Function configuration has been verified, make sure that the following configuration was restored for production environment:

                                                                                                            • Cloud Formation configuration - restore values changed in pre-configuration steps at the beginning of this section.
                                                                                                            • IAM permissions - remove any additional S3 read/write IAM permissions used to manually upload test datasets to S3.

                                                                                                            Configure S3 Lambda Triggers

                                                                                                            Follow the steps below to configure Amazon S3 event notification on the input bucket. This will allow Amazon S3 to send an event to S3 Protector Lambda function when an object is created or updated.

                                                                                                            Steps to Add S3 Lambda trigger:

                                                                                                            1. Sign in to the AWS Management Console and open the Amazon Lambda console.

                                                                                                            2. Select Lambda Function recorded in S3 Protector Lambda Name in the installation section.

                                                                                                            3. On the S3 Protector Function page, choose Aliases, then click on Production alias.

                                                                                                            4. In the Function overview pane, choose Add trigger.

                                                                                                            5. Select S3.

                                                                                                            6. Under Bucket, select the bucket recorded in Input S3 Bucket Name in prerequisites section.

                                                                                                            7. Under Event types, select All object create events.

                                                                                                            8. Optionally enter a file prefix.

                                                                                                            9. Enter a file suffix that matches your incoming data, for example .csv, .parquet, or .json. You can find the full list of supported file formats in the Features section.

                                                                                                            10. Under Recursive invocation, select the check box to acknowledge that using the same Amazon S3 bucket for input and output is not recommended.

                                                                                                            11. Choose Add.

                                                                                                            12. Repeat these steps for additional file suffixes supported by S3 Protector.


                                                                                                            Example Usage

                                                                                                            This section describes typical usage of S3 Protector.

                                                                                                            Prepare data for testing:

                                                                                                            Sample datasets and mapping.json files are provided in appendix sections:

                                                                                                            • CSV with no header
                                                                                                            • CSV with pipe delimiter

                                                                                                            Create a new folder in the input S3 bucket:

                                                                                                            A new folder must be created in the S3 input bucket for each distinct file schema. Each folder can have a mapping.json file corresponding to the dataset type expected. It is recommended that input folders use S3 encryption:

                                                                                                            • From the AWS S3 console, search and select the S3 input bucket created earlier for input files
                                                                                                            • Click the Create folder button
                                                                                                            • Provide a descriptive name for the type of dataset, e.g. sales orders
                                                                                                            • In Server-side encryption, select Enable
                                                                                                            • Use the default key type, Amazon S3 key (SSE-S3)
                                                                                                            • Click Create folder

                                                                                                            Upload the mapping.json and dataset to the folder:

                                                                                                            The appropriate mapping.json file must be uploaded to the folder prior to uploading the dataset.

                                                                                                            • Choose one of the sample dataset and mapping.json pairs from the appendix. Replace the data elements in mapping.json with similar data elements from your security policy
                                                                                                            • From the AWS console, navigate to Amazon S3, search and select the S3 input bucket created earlier for incoming files
                                                                                                            • Navigate to the desired folder
                                                                                                            • Click the Upload button
                                                                                                            • Click Add files
                                                                                                            • Upload the mapping.json file
                                                                                                            • Click the Upload button
                                                                                                            • Now repeat the above step for the sample dataset

                                                                                                            Verify output:

                                                                                                            Verify the output file was created:

                                                                                                            • From the AWS console, navigate to Amazon S3, search and select the S3 output or target bucket created earlier for writing processed files
                                                                                                            • Navigate to the corresponding folder
                                                                                                            • There should be a non-zero byte file with protected values
                                                                                                            • Select the file
                                                                                                            • From the menu select Actions | Query with S3 Select
                                                                                                            • Click the Run SQL query
                                                                                                            • Click the Formatted tab of the resultset
                                                                                                            • Verify the data is protected

                                                                                                            Troubleshooting / Logs:

                                                                                                            Logs are written to CloudWatch. This could provide helpful information if the results are not as expected:

                                                                                                            • From the AWS console, navigate to the Lambda service | Functions
                                                                                                            • Select and open the Lambda we created for protecting S3 files
                                                                                                            • At the top of function’s workspace, click the Monitoring tab
                                                                                                            • Click the button View logs in CloudWatch
                                                                                                            • Click the latest log stream
                                                                                                            • Scroll to the bottom of the stream for the latest log entries

                                                                                                            Troubleshooting

                                                                                                            By default, S3 Protector is set to log minimal information. It is beneficial to increase S3 Protector log level to either ‘config’ or ‘all’ while troubleshooting any error conditions. Use the CloudFormation installation steps to increase ‘MinLogLevel’ function configuration.

                                                                                                            S3 Protector Error States

                                                                                                            Error StateDescriptionAction
                                                                                                            400 ErrorA configuration error has occurred. The standard log should provide a descriptive error message. File processing has not started. Nothing was written to target bucket.Review the log for descriptive error message. Most likely some configuration parameters will need to be updated before S3 Protector can be re-started for failed file. Use the CloudFormation installation steps to update function configuration.
                                                                                                            500 PermissionErrorS3 Protector does not have enough permissions to access AWS resources.Review S3 Protector IAM Policy
                                                                                                            500 ExceptionAn error has occurred. The log may provide additional details. File processing may have started and a partial file may have been written to the target S3 bucket. While S3 Protector does not write unprotected data to partially processed files, S3 Protector automatically removes these files on error.Review error log for additional information.
                                                                                                            Status: timeoutS3 Protector ran out of time while processing large files.Review S3 Protector Timeout Section
                                                                                                            AWS Lambda crashAny AWS Lambda function may crash due to intermittent failures. If this occurs a partial file may have been written to the target S3 bucket. Due to the crash, S3 will assume this file to be an incomplete multi-part upload. Incomplete uploads do not appear as a standard S3 files, they are not shown in AWS S3 console. You are still charged for incomplete uploads.1. Discover and abort incomplete multi-part uploads for target bucket (e.g. using AWS CLI)
                                                                                                            2. Restart S3 Protector for failed file

                                                                                                            Restarting S3 Protector

                                                                                                            If S3 Protector fails, it is possible to start S3 Protector for existing source file without re-uploading the file again by using AWS Lambda console. With the input data file and mapping file uploaded, follow the steps below to trigger the S3 Protect Function.

                                                                                                            Steps

                                                                                                            1. Sign in to the AWS Management Console and go to Lambda console.

                                                                                                            2. Select Lambda Function recorded in S3 Protector Lambda Name in the CloudFormation installation section.

                                                                                                            3. On the S3 Protector Function page, choose Test tab.

                                                                                                            4. Copy the json test event into the Event JSON pane - replace bucket name placeholder with your input bucket name:

                                                                                                            {
                                                                                                              "Records": [
                                                                                                                {
                                                                                                                  "s3": {
                                                                                                                    "bucket": {
                                                                                                                      "name": "<PLACEHOLDER_S3_IN_BUCKET_NAME>"
                                                                                                                    },
                                                                                                                    "object": {
                                                                                                                      "key": "data.csv"
                                                                                                                    }
                                                                                                                  }
                                                                                                                }
                                                                                                              ]
                                                                                                            }
                                                                                                            
                                                                                                            1. Select Test to execute the test event.

                                                                                                            1.5.3.4 -

                                                                                                            Prerequisites

                                                                                                            RequirementDetail
                                                                                                            S3 Protector distribution and installation scriptsThese artifacts are provided by Protegrity
                                                                                                            Protegrity Cloud Protect API distribution and installation scriptsThese artifacts are provided by Protegrity
                                                                                                            AWS AccountRecommend using the same AWS account as the Protegrity Cloud API deployment.

                                                                                                            1.5.3.5 -

                                                                                                            AWS Services

                                                                                                            The following table describes the AWS services that may be a part of your Protegrity installation.

                                                                                                            ServiceDescription
                                                                                                            LambdaProvides serverless compute for S3 Protector.
                                                                                                            S3Input and Output data to be processed with S3 Protector.
                                                                                                            CloudWatchApplication and audit logs, performance monitoring, and alerts.

                                                                                                            1.5.3.6 -

                                                                                                            Required Skills and Abilities

                                                                                                            Role / SkillsetDescription
                                                                                                            AWS Account AdministratorTo run CloudFormation (or perform steps manually), create/configure S3, VPC and IAM permissions.
                                                                                                            Protegrity AdministratorThe ESA credentials required to read the policy configuration.

                                                                                                            1.5.4 - Mapping File Configuration

                                                                                                            Key concepts for defining the mapping.json file

                                                                                                            1.5.4.1 - Mapping File

                                                                                                            The mapping.json is used for configuring how S3 Protector transforms the input data.

                                                                                                            Overview

                                                                                                            S3 Protector uses a mapping.json file to determine how columns in the source file are mapped to Protegrity data elements for protection. The Lambda resolves the mapping file location using the following precedence order (highest to lowest):

                                                                                                            PrioritySourceDescription
                                                                                                            1 — S3 Object TagAWS S3 object tag MAPPING_LOCATION on the source fileIf the source S3 object has a tag with the key MAPPING_LOCATION, its value is used to locate the mapping file. The value can be a full S3 URI (s3://bucket/path/to/mapping.json) pointing to an exact file, or a bucket name for a hierarchical folder walk. This takes precedence over all other methods. Requires s3:GetObjectTagging permission on the source bucket.
                                                                                                            2 — MAPPING_CONFIG_BUCKET (mirror bucket)MAPPING_CONFIG_BUCKET environment variableWhen set, S3 Protector looks for the mapping file in this dedicated bucket, using the same folder path as the source file (mirroring the source bucket’s folder structure). Use this to centralise mapping files without tagging every individual object or using source bucket.
                                                                                                            3 — Source bucketSource S3 bucket (used by default)If neither a tag nor MAPPING_CONFIG_BUCKET resolves a mapping file, S3 Protector falls back to loading mapping.json from the same bucket and folder as the source file.

                                                                                                            Using S3 Object Tags for Mapping File Resolution

                                                                                                            Add a tag to the source S3 object to point to a specific mapping file. The tag key is always MAPPING_LOCATION. The tag value supports two formats:

                                                                                                            Tag keyTag value formatExampleBehaviour
                                                                                                            MAPPING_LOCATIONFull S3 URI — s3://bucket/path/to/mapping.jsons3://my-config-bucket/configs/customer_a/mapping.jsonLoads exactly that file. Raises an error if the file is not found. No hierarchical folder walk is performed.
                                                                                                            MAPPING_LOCATIONBucket name onlymy-config-bucketPerforms the same hierarchical mapping.json folder walk as MAPPING_CONFIG_BUCKET, starting from the source file’s folder within the named bucket.

                                                                                                            IAM note: The Lambda execution role must have s3:GetObjectTagging on the source bucket when using tag-based resolution.

                                                                                                            Configuration Structure

                                                                                                            The mapping.json file must be formatted in valid JSON with the key-values configuration pairs described below:

                                                                                                            {
                                                                                                              "ignored-columns": ["<ignored-col-name-1>", "<ignored-col-name-n>"],
                                                                                                              "columns": {
                                                                                                                "<col-name-1>": {
                                                                                                                  "operation": "[protect|unprotect]",
                                                                                                                  "data_element": "<data-element-name>"
                                                                                                                },
                                                                                                                "<col-name-2>": {
                                                                                                                  "operation": "[protect|unprotect]",
                                                                                                                  "data_element": "<data-element-name>"
                                                                                                                }
                                                                                                              },
                                                                                                              "input": {
                                                                                                                "format": "<file-format>",
                                                                                                                "spec": { "<reader-arg>": "<value>" }
                                                                                                              },
                                                                                                              "output": {
                                                                                                                "format": "<file-format>",
                                                                                                                "spec": { "<writer-arg>": "<value>" }
                                                                                                              }
                                                                                                            }
                                                                                                            

                                                                                                            Data Columns Transformation

                                                                                                            Every source file column must appear in either ‘columns’ or ‘ignored-columns’.

                                                                                                            1. “columns” (required) - Maps input data columns to Protegrity security operation such as ‘protect’ or ‘unprotect’. Each operation is applied using provided data element.

                                                                                                            2. “ignored-columns” (optional) - Lists the names of input data columns which do not require any Protegrity security operations applied. Data for these columns will be left unprocessed and will be written to target file as is.

                                                                                                            Input Data Configuration

                                                                                                            The “input” optional configuration contains the following key-values pairs:

                                                                                                            format

                                                                                                            Specifies the format of the input data files. If format is not provided in the mapping json, the format will be inferred from the file extension.

                                                                                                            spec

                                                                                                            Provides additional configuration for input file processing. This allows processing of non-default file formats. For example, pipe delimited files, header-less files, and various JSON record structures.

                                                                                                            The properties within the input spec block correspond with the Python Pandas reader functions arguments. For more information about supported format arguments refer to the Pandas documentation. Below you can find a list of links to Pandas official online documentation for each format supported by S3 Protector:

                                                                                                            • CSV - read_csv

                                                                                                            • Excel - read_excel

                                                                                                            • Parquet - read_parquet

                                                                                                            • JSON - read_json

                                                                                                            Output Data Configuration

                                                                                                            The “output” optional configuration contains the following key-values pairs:

                                                                                                            format

                                                                                                            Specifies the format of the output data files. The format in the mapping json is only used when S3 Protector Function deployment parameter OutputFileFormat is set to use_mapping_spec. See the CloudFormation installation section for the full list of the output format configuration.

                                                                                                            spec

                                                                                                            Provides additional configuration for the output file processing.

                                                                                                            The properties within the output spec block correspond with the Python Pandas DataFrame output function arguments. For more information about supported format arguments refer to the Pandas documentation. Below you can find a list of links to Pandas official online documentation for each format supported by S3 Protector:

                                                                                                            • CSV - DataFrame.to_csv

                                                                                                            • Excel - DataFrame.to_excel

                                                                                                            • Parquet - DataFrame.to_parquet

                                                                                                            • JSON - DataFrame.to_json

                                                                                                            1.5.4.2 - Column Mapping Rules

                                                                                                            In order to ensure highest level of security, the S3 Protector requires users to define processing rules for all data columns. Every column that appears in a source file must be mentioned in the ‘mapping.json’ file. A column may appear in either ‘columns’ section or ‘ignored-columns’ section, but not both.

                                                                                                            Common Error Conditions

                                                                                                            The table below summaries common error conditions that may occur when creating a ‘mapping.json’ file:

                                                                                                            MappingError Message
                                                                                                            A column name appears in ‘mapping.json’ but does not exist in the source file.Columns [‘column name’] in the mapping file have no matches in the input data columns
                                                                                                            Source file column name appears neither in ‘columns’ nor ‘ignored-columns’ sections.Input file contains data columns which are not defined in the mapping file.
                                                                                                            Source file column name appears in both ‘columns’ and ‘ignored-columns’ sections.Ignored column [‘column-name’] is present in ‘columns’ list. Column must be defined in either ‘columns’ or ‘ignored-columns’, but not both.
                                                                                                            Source file column name appears more than once in either ‘columns’ or ‘ignored-columns’ section.Duplicate column [“column-name”] found in ‘ignored-columns’.

                                                                                                            1.5.5 - Large File Processing

                                                                                                            Known product limitations.

                                                                                                            Overview

                                                                                                            S3 Protector processes files uploaded to Amazon S3 by invoking an AWS Lambda function for each ObjectCreated event. A single Lambda invocation is bounded by a hard 15-minute timeout and a maximum of 10 240 MB RAM. Large-file processing removes those ceilings by automatically splitting supported files into chunks, protecting each chunk in a separate parallel Processor Lambda, and reassembling the results into a single output file.

                                                                                                            Two complementary mechanisms handle large files:

                                                                                                            MechanismWhat it does
                                                                                                            Row-level streamingReads the source file in row chunks instead of loading it entirely into RAM. Controlled by FILE_CHUNK_SIZE. Supported for CSV, Parquet, and JSON Lines (NDJSON). Not supported by JSON array files.
                                                                                                            Byte-range dispatchSplits files that meet or exceed a configurable byte threshold across N parallel Processor Lambdas, each handling one byte-range chunk. A Dispatcher coordinates the split; a Merger reassembles the parts. Controlled by LARGE_FILE_DISPATCH_THRESHOLD_BYTES and LARGE_FILE_CHUNK_SIZE_BYTES. Supported for CSV, Parquet, and both JSON Lines and JSON array.

                                                                                                            Dispatch and row-level streaming are complementary: a dispatched chunk is still streamed row-by-row inside each Processor Lambda, keeping per-invocation memory bounded.


                                                                                                            How Dispatch Works: Step by Step

                                                                                                            1 — Dispatcher

                                                                                                            When a regular data file (.csv, .parquet, .json) arrives in the source bucket and its size meets or exceeds LARGE_FILE_DISPATCH_THRESHOLD_BYTES, the Lambda acts as a Dispatcher:

                                                                                                            1. Reads the file’s byte size.
                                                                                                            2. Splits the file into byte-range chunks of approximately LARGE_FILE_CHUNK_SIZE_BYTES each, aligned on natural record boundaries (newline for CSV and JSON Lines, row-group boundary for Parquet, }, { separator for JSON arrays).
                                                                                                            3. Writes one manifest file per chunk into the source bucket. Each manifest is a small JSON object that describes the chunk’s byte range (or row-group indices for Parquet), the total chunk count, and a snapshot of the mapping configuration.
                                                                                                            4. Returns immediately. The Dispatcher never reads or transforms any record data.

                                                                                                            2 — Processor (one per chunk)

                                                                                                            Each manifest landing in S3 fires a separate ObjectCreated event that triggers a new Processor Lambda invocation:

                                                                                                            1. Reads the manifest from S3.
                                                                                                            2. Fetches only the byte range (or row groups) assigned to this chunk.
                                                                                                            3. Protects (tokenises) the data by calling the Cloud API Lambda.
                                                                                                            4. Writes the protected output as a .part file into the staging parts directory in the source bucket.
                                                                                                            5. Deletes the manifest file. Manifest deletion is the chunk-completion signal.

                                                                                                            3 — Merger (inline, triggered by the last Processor)

                                                                                                            After all chunks complete, the Merger:

                                                                                                            1. Acquires a merge lock by creating a merge.lock file in the staging parts directory.
                                                                                                            2. Assembles all .part files into the single final output object in the target bucket.
                                                                                                            3. Deletes the .part files from the staging directory on confirmed merge success.
                                                                                                            4. Releases the merge lock.
                                                                                                            5. Optionally deletes the original source file when DELETE_INPUT_FILES=true.

                                                                                                            Staging Directory Layout

                                                                                                            All transient dispatch artifacts are stored under a per-job staging directory in the source bucket. The directory is named by appending .dispatch/ to the source file key:

                                                                                                            {source_key}.dispatch/
                                                                                                                manifests/
                                                                                                                    chunk_0000.manifest.json
                                                                                                                    chunk_0001.manifest.json
                                                                                                                    chunk_NNNN.manifest.json
                                                                                                                parts/
                                                                                                                    chunk_0000.part
                                                                                                                    chunk_0001.part
                                                                                                                    chunk_NNNN.part
                                                                                                                    merge.lock              ← transient lock, present only during final merge
                                                                                                            

                                                                                                            Example — for a source file data/large.csv in bucket my-source-bucket:

                                                                                                            s3://my-source-bucket/data/large.csv.dispatch/
                                                                                                                manifests/chunk_0000.manifest.json
                                                                                                                manifests/chunk_0001.manifest.json
                                                                                                                parts/chunk_0000.part
                                                                                                                parts/chunk_0001.part
                                                                                                                parts/merge.lock
                                                                                                            

                                                                                                            Manifest files (manifests/chunk_NNNN.manifest.json)

                                                                                                            • Created by: the Dispatcher at job start.
                                                                                                            • Contents: byte range (or row-group indices for Parquet), total chunk count, source and output bucket/key, a snapshot of mapping.json captured at dispatch time (so all Processors use identical column configuration even if mapping.json is replaced mid-job), and the raw OUTPUT_FILE_FORMAT value.
                                                                                                            • Removed by: the Processor Lambda responsible for that chunk, immediately after writing its .part file. Manifest deletion signals chunk completion.
                                                                                                            • When NOT removed: if bucket doesn’t have a trigger for .json files; if a Processor Lambda fails before completing its write, its manifest is left in place. The manifest count in CloudWatch Logs will not reach zero and the merge will not proceed.

                                                                                                            Part files (parts/chunk_NNNN.part)

                                                                                                            • Created by: each Processor Lambda, written to the source bucket’s staging directory.
                                                                                                            • Contents: the protected output for the assigned byte range (or row groups). Format matches the resolved output format (CSV, Parquet, JSON Lines, or JSON array wrapper).
                                                                                                            • Removed by: the Merger after all chunks have completed and the final output object has been successfully assembled via UploadPartCopy.
                                                                                                            • When NOT removed: if the merge step fails, the .part files are left in place and the merge lock is released. Check CloudWatch Logs, fix the root cause, delete the entire .dispatch/ directory, and restart file processing.

                                                                                                            Merge lock (parts/merge.lock)

                                                                                                            • Created by: the first Processor to reach the merge step.
                                                                                                            • Removed by: the merging Processor, whether the merge succeeded or failed.
                                                                                                            • Lifetime: seconds to a few minutes, the duration of the final merge operation.

                                                                                                            When the staging directory is NOT cleaned up

                                                                                                            The entire .dispatch/ staging directory remains if:

                                                                                                            • Source bucket does not have a trigger for .json files.
                                                                                                            • One or more Processor Lambdas failed before writing their .part file.
                                                                                                            • The merge step raised an error.

                                                                                                            Recovery: Check CloudWatch Logs for the error, delete s3://{source-bucket}/{source_key}.dispatch/ manually, then restart file processing.

                                                                                                            Note: The Dispatcher will not proceed if the .dispatch/ directory already exists. Delete the staging directory before retrying.


                                                                                                            Environment Variable Reference

                                                                                                            Dispatch Variables

                                                                                                            VariableDefaultRangeDescription
                                                                                                            LARGE_FILE_DISPATCH_THRESHOLD_BYTES262144000 (250 MB)100 MB – 100 GBSize (in bytes), files of this size or larger are split across multiple Processor Lambdas. Omit or leave empty to disable dispatch entirely. Performance: lower values trigger dispatch sooner, increasing parallelism for medium-sized files at the cost of dispatch overhead.
                                                                                                            LARGE_FILE_CHUNK_SIZE_BYTES157286400 (150 MB)100 MB – 10 GBSize (in bytes) of each byte-range chunk assigned to one Processor Lambda. Performance: smaller chunks → more parallel Lambdas → faster wall-clock time, but higher Lambda concurrency consumption. Larger chunks → fewer Lambdas → less concurrency pressure, but each invocation takes longer. The maximum supported number of chunks per job is 9999.

                                                                                                            Supported formats for dispatch: CSV, Parquet, JSON (both JSON Lines and JSON array).
                                                                                                            XLSX dispatch is not supported.

                                                                                                            Row-Level Streaming Variables

                                                                                                            VariableDefaultRangeDescription
                                                                                                            FILE_CHUNK_SIZE100000100 – 100 000 000Number of rows read from the source file at a time during streaming I/O. Performance: larger values reduce S3 read round-trips at the cost of higher peak RAM usage per invocation. Reduce if the Lambda runs out of memory on wide rows; increase to reduce latency on narrow rows. Applies to CSV, Parquet, and JSON Lines. Does not apply to JSON array files — those load the entire assigned byte range into RAM as one DataFrame.
                                                                                                            MAX_BATCH_SIZE25000100 – 100 000 000Maximum number of values sent to the Cloud API Lambda in a single invocation payload. Performance: the AWS Lambda synchronous invocation payload limit is 6 MB. Increasing this reduces the number of Cloud API calls (lower latency), but risks hitting the 6 MB limit for wide columns. Keep MAX_BATCH_SIZEFILE_CHUNK_SIZE.

                                                                                                            Parallelism Variable

                                                                                                            VariableDefaultRangeDescription
                                                                                                            MAX_PARALLEL_PROTECT_CALLS10000 – 10 000Maximum number of concurrent asyncio tasks that call the Cloud API Lambda in parallel within a single Processor Lambda invocation. Performance: higher values increase throughput by overlapping network I/O to the Cloud API, at the cost of more open connections and memory per task.

                                                                                                            Scenario A — Large CSV / JSON Lines files, row-level streaming only (no dispatch)

                                                                                                            Suitable when files are up to ~1 GB and stay within the 15-minute Lambda timeout.

                                                                                                            FILE_CHUNK_SIZE              = 150000
                                                                                                            MAX_BATCH_SIZE               = 25000
                                                                                                            MAX_PARALLEL_PROTECT_CALLS   = 1000
                                                                                                            OUTPUT_FILE_FORMAT           = preserve_input_format
                                                                                                            OUTPUT_FILE_COMPRESSION_TYPE = gzip
                                                                                                            MIN_LOG_LEVEL                = info
                                                                                                            

                                                                                                            Memory footprint per invocation: approximately FILE_CHUNK_SIZE × avg_row_bytes × 2 (current chunk + output buffer).

                                                                                                            Scenario B — Very large CSV / Parquet / JSON files, parallel dispatch enabled

                                                                                                            Suitable for files from 256 MB to several GB.

                                                                                                            LARGE_FILE_DISPATCH_THRESHOLD_BYTES = 1048576000   # 1 GB — enable dispatch above this
                                                                                                            LARGE_FILE_CHUNK_SIZE_BYTES         = 157286400    # 150 MB per Processor Lambda
                                                                                                            FILE_CHUNK_SIZE                     = 150000
                                                                                                            MAX_BATCH_SIZE                      = 25000
                                                                                                            MAX_PARALLEL_PROTECT_CALLS          = 1000
                                                                                                            OUTPUT_FILE_FORMAT                  = preserve_input_format
                                                                                                            OUTPUT_FILE_COMPRESSION_TYPE        = gzip
                                                                                                            MIN_LOG_LEVEL                       = info
                                                                                                            

                                                                                                            Each Processor Lambda handles one ~150 MB byte range. A 1.5 GB file produces ~10 parallel invocations that each finish in a fraction of the total serial time.


                                                                                                            Troubleshooting

                                                                                                            SymptomLikely causeFix
                                                                                                            Lambda times out on large filesFile too large for serial processingEnable dispatch for this file (LARGE_FILE_DISPATCH_THRESHOLD_BYTES)
                                                                                                            Lambda runs out of memoryFILE_CHUNK_SIZE too large, or cross-format conversionReduce FILE_CHUNK_SIZE; use the same input and output format
                                                                                                            Output file not produced after all chunks succeedProcessor Lambda(s) failed before writing .part filesCheck CloudWatch Logs, delete the .dispatch/ staging directory and restart file processing
                                                                                                            .part files accumulate and are never deletedMerge failedCheck CloudWatch Logs, delete the .dispatch/ staging directory and restart file processing
                                                                                                            RuntimeError: Dispatch directory already existsPrevious dispatch run did not completeCheck CloudWatch Logs, delete the .dispatch/ staging directory and restart file processing
                                                                                                            Cloud API payload errorsMAX_BATCH_SIZE too largeReduce MAX_BATCH_SIZE until request fits under 6 MB

                                                                                                            Check CloudWatch Logs

                                                                                                            Use the following CloudWatch Logs Insights query to surface errors across all Lambda invocations for a job:

                                                                                                            fields @timestamp, @message
                                                                                                            | filter @message like /(?i)error/ or @message like /Status: timeout/
                                                                                                            | sort @timestamp desc
                                                                                                            | limit 1000
                                                                                                            

                                                                                                            Restart File Processing

                                                                                                            Before retrying, delete the entire .dispatch/ staging directory so the Dispatcher does not abort on startup.

                                                                                                            Then trigger S3 Protector by either re-uploading the source file or invoking the Lambda directly with a synthetic S3 test event. Replace my-source-bucket and data/large.csv with the values for your job:

                                                                                                            {
                                                                                                              "Records": [
                                                                                                                {
                                                                                                                  "s3": {
                                                                                                                    "bucket": {
                                                                                                                      "name": "my-source-bucket",
                                                                                                                      "arn": "arn:aws:s3:::my-source-bucket"
                                                                                                                    },
                                                                                                                    "object": {
                                                                                                                      "key": "data/large.csv"
                                                                                                                    }
                                                                                                                  }
                                                                                                                }
                                                                                                              ]
                                                                                                            }
                                                                                                            

                                                                                                            1.5.6 - Performance

                                                                                                            Benchmarks and performance tuning

                                                                                                              Performance Considerations

                                                                                                              The following factors may affect S3 Protector performance:

                                                                                                              1. Number of protected columns in a file: Affects the number of requests to Cloud API. The more protected columns, the longer it will take to process the file. Review Performance section in Cloud API on AWS documentation on how to monitor and configure Cloud API for best performance.

                                                                                                              2. Maximum batch size: MAX_BATCH_SIZE determines the maximum number of rows to process in a single Cloud API invocation. This value is applied to all columns. The higher the batch size, the higher the Cloud API throughput. This value controls the size of a single request to Cloud API. The request size is limited by AWS Lambda infrastructure to 6 MB. Review AWS Lambda quotas and limitations for latest information.

                                                                                                              3. Maximum parallel protect calls: MAX_PARALLEL_PROTECT_CALLS controls how many protect requests can be sent at the same time across the file being processed. The default is 1000. Lower values can reduce pressure on Cloud API; higher values can improve throughput if Cloud API has enough capacity.

                                                                                                              4. File streaming read size: FILE_CHUNK_SIZE controls how many rows S3 Protector reads into memory at a time from source file. Lower values reduce peak memory usage. Higher values may improve throughput. This does not apply to JSON arrays. Applies to all other file types including JSON lines.

                                                                                                              5. Large-file threshold: LARGE_FILE_DISPATCH_THRESHOLD_BYTES Files larger than this threshold are processed in parallel by multiple S3 Protector instances. Does not apply to XLS files.

                                                                                                              6. Large-file chunk size: LARGE_FILE_CHUNK_SIZE_BYTES controls the target size of each chunk when large files are processed in parallel. For JSON array files, each chunk must fit into a single Lambda’s memory; this constraint does not apply to JSON lines files.

                                                                                                              7. Function timeout: Default S3 Protector execution time is set to 15 minutes, the maximum value imposed by AWS Lambda infrastructure. If S3 Protector runs out of time when processing a file, ensure LARGE_FILE_DISPATCH_THRESHOLD_BYTES is smaller than the files size and LARGE_FILE_CHUNK_SIZE_BYTES is small enough to fit file processing into 15 minute timeout.

                                                                                                              8. Cloud API performance: S3 Protector uses Cloud API to apply protect operations to data in the file. Performance of Cloud API directly affects the performance of S3 Protector. Review Performance section in Cloud API on AWS documentation.


                                                                                                              Benchmarks

                                                                                                              Single S3 Protector Instance Per File

                                                                                                              The following table shows throughput and latency for three different files when large file processing is not enabled. Each file has 21 columns, 6 of which were protected by S3 Protector with tokenization data elements. The remaining 15 columns were configured to pass through without applying protection.

                                                                                                              Two of the default S3 Protector settings were updated for this benchmark:

                                                                                                              1. Default function timeout was increased to its maximum of 15 minutes
                                                                                                              2. ‘MaxBatchSize’ was increased from default ‘25000’ to ‘50000’ (via CloudFormation template)

                                                                                                              Performance Results

                                                                                                              Rows x ColumnsProtected ColumnsNumber of Protect OperationsFile Size (MB)Total Duration (s)Throughput (MB/s)Throughput (Operations/s)
                                                                                                              100k x 216600,0002254.34118k/s
                                                                                                              1m x 2166,000,000220504.36119k/s
                                                                                                              10m x 21660,000,0002,2005104.31118k/s

                                                                                                              Multiple S3 Protector Instances Per File

                                                                                                              The following results show wall-clock duration and throughput when large-file dispatch is enabled and each file is split across multiple parallel S3 Protector instances.

                                                                                                              Test configuration:

                                                                                                              • Lambda memory: 1700 MB
                                                                                                              • LARGE_FILE_CHUNK_SIZE_BYTES: 109 MB per chunk
                                                                                                              • FILE_CHUNK_SIZE: 150,000 rows
                                                                                                              • MAX_BATCH_SIZE: 75,000
                                                                                                              • Each file has 31 columns; 9 protected with tokenization data elements

                                                                                                              Performance Results

                                                                                                              FormatFile SizeParallel ChunksTotal DurationThroughput (MB/s)
                                                                                                              CSV5 GB461m 7s~77
                                                                                                              Parquet5 GB281m 43s~50
                                                                                                              JSON array5 GB4659s~86
                                                                                                              JSON lines5 GB4652s~99
                                                                                                              CSV20 GB1861m 52s~183
                                                                                                              Parquet20 GB2941m 51s~185
                                                                                                              JSON array20 GB1892m 9s~159
                                                                                                              JSON lines20 GB1831m 32s~223
                                                                                                              CSV100 GB9306m 36s~259
                                                                                                              Parquet100 GB6005m 5s~336
                                                                                                              JSON array100 GB9168m 52s~227

                                                                                                              Throughput scales with file size because larger files produce more parallel Processor Lambda invocations, increasing overall concurrency.

                                                                                                              1.5.7 - Known Limitations

                                                                                                              Known product limitations.

                                                                                                              Known Limitations

                                                                                                              Known product limitations:

                                                                                                              • For .json files, supported tabular layouts are flat JSON arrays and JSON Lines. Deeply nested JSON structures are not supported.
                                                                                                              • Legacy Excel format (.xls) is not supported.
                                                                                                              • Excel files support is limited to single worksheet tab.
                                                                                                              • Parallel file processing in chunks is available for CSV, Parquet, and JSON files. Excel files do not support parallel processing.
                                                                                                              • Parquet timestamps are supported for protect/unprotect operations, but the output type of protected/unprotected timestamp will be converted to string.
                                                                                                              • FPE is supported only for ASCII values.
                                                                                                              • Only the protect and unprotect operations are supported. The reprotect operation is not currently supported.
                                                                                                              • For processing large files in parallel chunks source and target buckets must be in the same region.
                                                                                                              • Entire file is loaded into RAM for processing if file output format is different from input format.
                                                                                                              • Single-row-group Parquet files cannot be processed in parallel chunks.
                                                                                                              • AWS Lambda timeout of 15 minutes applies to each invocation.

                                                                                                              1.5.8 - Upgrading To The Latest Version

                                                                                                              Upgrading S3 Protector Lambda

                                                                                                                Upgrade Process Overview

                                                                                                                The diagram below illustrates upgrade steps:


                                                                                                                Publish S3 Protector Lambda Version

                                                                                                                Publishing a version of the S3 Protector Lambda allows updating it without interruptions to the existing traffic.

                                                                                                                Procedure

                                                                                                                1. Go to AWS Lambda console and select existing Protegrity S3 Protector Lambda.

                                                                                                                2. Go to Lambda ConfigurationEnvironment variables.

                                                                                                                3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                                                                aws lambda get-function-configuration --function-name \
                                                                                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                --query Environment > <function_name>_env_config.json
                                                                                                                
                                                                                                                1. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                                                                2. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                                                                S3 Protector Lambda version number: ___________________


                                                                                                                Run Protect Service Upgrade

                                                                                                                In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                                                                                                                Procedure

                                                                                                                1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                                                                2. Select Update Stack > Make a direct update.

                                                                                                                3. Select Replace existing template > Upload a template file.

                                                                                                                4. Upload pty_s3_protector_cf.json file and select Next.

                                                                                                                5. Update LambdaFunctionProductionVersion parameter with S3 Protector Lambda version number recorded in step 3.

                                                                                                                6. Click Next until Review window and then select Update stack.

                                                                                                                7. Wait for the Cloud Formation to complete.

                                                                                                                8. Go back to Lambda console and select S3 Protector Lambda.

                                                                                                                9. Go to ConfigurationEnvironment variables. Replace placeholder values with values recorded in previous step.

                                                                                                                  Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                                                                aws lambda update-function-configuration --function-name \
                                                                                                                arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                --environment file://./<function_name>_env_config.json
                                                                                                                
                                                                                                                1. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                                                                                                                2. The upgraded S3 Protector Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.


                                                                                                                Finalize Upgrade

                                                                                                                In this step, the S3 Protector Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                                                                                                                Procedure

                                                                                                                1. Go back to Protegrity AWS Cloud Formation deployment stack.

                                                                                                                2. Select Update Stack > Make a direct update.

                                                                                                                3. Select Use existing template and then choose Next

                                                                                                                4. Update LambdaFunctionProductionVersion parameter with the following value: $LATEST.

                                                                                                                5. Click Next until Review window and then select Update stack.

                                                                                                                6. Go back to Lambda console and select S3 Protector Lambda.

                                                                                                                7. From the Lambda console, verify that Latest alias points to $LATEST version.

                                                                                                                8. Test your function to make sure it works as expected.

                                                                                                                9. If you need to rollback to older version of S3 Protector Lambda, you can re-run the cloud formation with LambdaFunctionProductionVersion parameter set to the previous version of S3 Protector Lambda.

                                                                                                                1.5.9 - Appendices

                                                                                                                Additional references for the protector.

                                                                                                                1.5.9.1 - Sample Configuration

                                                                                                                A dataset snippet and corresponding mapping.json file are provided.

                                                                                                                  CSV Format - No Header

                                                                                                                  Dataset

                                                                                                                  Patricia,Young,Patricia.Young@liu.info,8/25/1975,343494236548351
                                                                                                                  Ronald,Hess,Ronald.Hess@cobb.org,3/22/1977,5289549212515680
                                                                                                                  Anna,Rose,Anna.Rose@robinson.net,8/3/1983,4387393325002340
                                                                                                                  Maureen,Morgan,Maureen.Morgan@whitehead.com,10/23/1975,6011769162504860
                                                                                                                  Ryan,Lee,Ryan.Lee@summers-richards.com,4/6/1975,373509629162404
                                                                                                                  

                                                                                                                  Mapping.json - Header Specified In Input Spec Section

                                                                                                                  {
                                                                                                                  "input": {
                                                                                                                     "format": "csv",
                                                                                                                     "spec": {
                                                                                                                        "names": ["first_name","last_name","email","credit_card","birthdate"]
                                                                                                                     }
                                                                                                                  },
                                                                                                                     "columns":{
                                                                                                                        "first_name":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deName"
                                                                                                                        },
                                                                                                                        "last_name":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deName"
                                                                                                                        },
                                                                                                                        "email":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deEmail"
                                                                                                                        },
                                                                                                                        "credit_card": {
                                                                                                                        "operation":"protect",
                                                                                                                        "data_element":"deCCN"
                                                                                                                        },
                                                                                                                        "birthdate": {
                                                                                                                        "operation":"protect",
                                                                                                                        "data_element":"deDOB"
                                                                                                                        }
                                                                                                                     }
                                                                                                                  }
                                                                                                                  

                                                                                                                  CSV Format - Pipe Delimiter

                                                                                                                  Dataset

                                                                                                                  POLICY_NUM|ACTION_TAKEN_DATE|ACTION_TAKEN_TIME|PERSON_DOB|ADDR_LINE_1|ADDR_LINE_2|ADDR_CITY|ADDR_STATE|ADDR_ZIP|PERSON_NAME|PERSON_SSN
                                                                                                                  sbBksoknql8O|7/8/2011|08.00.07|9/23/1952|123 Maple Street|Apt 2B|Springfield|IL|62704|Abraham Duppstadt|755-30-1679  
                                                                                                                  SdiWx5Egtxrd|7/22/2011|14.53.29|3/5/1957|456 Elm Avenue|Suite 300|Boulder|CO|80302|Christena Macklem|366-99-6352  
                                                                                                                  QGOlnMvcJ50a|7/25/2011|07.14.10|7/20/1962|789 Pine Road|Unit 5|Madison|WI|53703|Ulrike Rehling|011-87-2771  
                                                                                                                  MW5wPE5paWgN|7/29/2011|14.00.29|9/23/1961|321 Oak Lane|Building A|Austin|TX|78701|Summer Mauceri|806-32-5716  
                                                                                                                  QGOlnMvcJ50a|7/29/2011|14.00.29|5/29/1986|654 Cedar Boulevard|Floor 4|Portland|OR|97209|Ora Scharpman|273-48-6482
                                                                                                                  

                                                                                                                  Mapping.json

                                                                                                                  {
                                                                                                                     "input": {
                                                                                                                        "format": "csv",
                                                                                                                        "spec": {
                                                                                                                          "sep": "|",
                                                                                                                          "encoding": "utf-8"
                                                                                                                        }
                                                                                                                     },
                                                                                                                     "output": {
                                                                                                                        "format": "csv",
                                                                                                                        "spec": {
                                                                                                                          "encoding": "utf-8",
                                                                                                                          "compression": "gzip"
                                                                                                                        }
                                                                                                                     },
                                                                                                                     "columns":{
                                                                                                                        "PERSON_NAME":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deName"
                                                                                                                        },
                                                                                                                        "PERSON_SSN":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deSSN"
                                                                                                                        },
                                                                                                                        "ADDR_LINE_1":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deAddress"
                                                                                                                        },
                                                                                                                        "ADDR_LINE_2":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deAddress"
                                                                                                                        },
                                                                                                                        "ADDR_CITY":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deCity"
                                                                                                                        },
                                                                                                                        "POLICY_NUM":{
                                                                                                                           "operation":"protect",
                                                                                                                           "data_element":"deIBAN"
                                                                                                                        }
                                                                                                                     }
                                                                                                                  }
                                                                                                                  

                                                                                                                  JSON Format

                                                                                                                  Dataset

                                                                                                                  [
                                                                                                                     {
                                                                                                                        "Region": "Region 1",
                                                                                                                        "Order Date": "01/12/2012",
                                                                                                                        "Registration": "2016-01-01 01:01:01.001",
                                                                                                                        "Order ID": 10,
                                                                                                                        "Unit Price": 1.01
                                                                                                                     },
                                                                                                                     {
                                                                                                                        "Region": "Region 2",
                                                                                                                        "Order Date": "27/07/2012",
                                                                                                                        "Registration": "2016-02-03 17:04:03.002",
                                                                                                                        "Order ID": 20,
                                                                                                                        "Unit Price": 456.01
                                                                                                                     },
                                                                                                                     {
                                                                                                                        "Region": "Region 3",
                                                                                                                        "Order Date": "27/07/2012",
                                                                                                                        "Registration": "2016-02-03 01:09:31.003",
                                                                                                                        "Order ID": 30,
                                                                                                                        "Unit Price": 7.99
                                                                                                                     },
                                                                                                                     {
                                                                                                                        "Region": "Region 4",
                                                                                                                        "Order Date": "27/07/2012",
                                                                                                                        "Registration": "2016-02-03 00:36:21.004",
                                                                                                                        "Order ID": 40,
                                                                                                                        "Unit Price": 89.99
                                                                                                                     }
                                                                                                                  ]
                                                                                                                  

                                                                                                                  Mapping.json

                                                                                                                  {
                                                                                                                     "columns": {
                                                                                                                        "Region": {
                                                                                                                           "operation": "protect",
                                                                                                                           "data_element": "deAddress"
                                                                                                                        },
                                                                                                                        "Order Date": {
                                                                                                                           "operation": "protect",
                                                                                                                           "data_element": "deDate2"
                                                                                                                        },
                                                                                                                        "Registration": {
                                                                                                                           "operation": "protect",
                                                                                                                           "data_element": "deDOB"
                                                                                                                        },
                                                                                                                        "Order ID": {
                                                                                                                           "operation": "protect",
                                                                                                                           "data_element": "deNumeric"
                                                                                                                        },
                                                                                                                        "Unit Price": {
                                                                                                                           "operation": "protect",
                                                                                                                           "data_element": "deDecimal"
                                                                                                                        }
                                                                                                                     }
                                                                                                                  }
                                                                                                                  

                                                                                                                  1.5.9.2 - Amazon S3 Security Best Practices Examples

                                                                                                                  Amazon S3 Security Best Practices Examples

                                                                                                                  Block Public Access to Your Amazon S3 Storage

                                                                                                                  Enabling Block Public Access helps protect your resources by preventing public access from being granted through the resource policies or access control lists (ACLs) that are directly attached to S3 resources.

                                                                                                                  In addition to enabling Block Public Access, carefully inspect the following policies to confirm that they don’t grant public access:

                                                                                                                  • Identity-based policies attached to associated AWS principals (for example, IAM roles)
                                                                                                                  • Resource-based policies attached to S3 bucket (referred to as bucket policies)

                                                                                                                  Review Bucket Access Using IAM Access Analyzer for S3

                                                                                                                  IAM Access Analyzer helps you identify the resources in your organization and accounts, such as Amazon S3 buckets or IAM roles, shared with an external entity. This lets you identify unintended access to your resources and data, which is a security risk.

                                                                                                                  IAM Access Analyzer for S3 is available at no extra cost on the Amazon S3 console. IAM Access Analyzer for S3 is powered by AWS Identity and Access Management (IAM) IAM Access Analyzer. To use IAM Access Analyzer for S3 in the Amazon S3 console, you must visit the IAM console and enable IAM Access Analyzer on a per-Region basis.


                                                                                                                  Enable Server-Side Encryption

                                                                                                                  All Amazon S3 buckets have encryption configured by default, and all new objects that are uploaded to an S3 bucket are automatically encrypted at rest. Server-side encryption with Amazon S3 managed keys (SSE-S3) is the default encryption configuration for every bucket in Amazon S3.

                                                                                                                  Amazon S3 also provides these server-side encryption options:

                                                                                                                  • Server-side encryption with AWS Key Management Service (AWS KMS) keys (SSE-KMS)
                                                                                                                  • Dual-layer server-side encryption with AWS Key Management Service (AWS KMS) keys (DSSE-KMS)
                                                                                                                  • Server-side encryption with customer-provided keys (SSE-C)

                                                                                                                  1.6 -

                                                                                                                  The following diagram shows a reference architecture for synchronizing the security policy from ESA.

                                                                                                                  The Protegrity Policy Agent requires network access to an Enterprise Security Administrator (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 Guide.

                                                                                                                  1.7 -

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

                                                                                                                  Create Protect Lambda IAM Execution Policy

                                                                                                                  This task defines a policy used by the Protegrity Lambda function to write CloudWatch logs and access the KMS encryption key to decrypt the policy.

                                                                                                                  Perform the following steps to create the Lambda execution role and required policies:

                                                                                                                  1. From the AWS IAM console, select Policies > Create Policy.

                                                                                                                  2. Select the JSON tab and copy the following sample policy.

                                                                                                                    {
                                                                                                                      "Version": "2012-10-17",
                                                                                                                      "Statement": [
                                                                                                                        {
                                                                                                                          "Sid": "CloudWatchWriteLogs",
                                                                                                                          "Effect": "Allow",
                                                                                                                          "Action": [
                                                                                                                            "logs:CreateLogGroup",
                                                                                                                            "logs:CreateLogStream",
                                                                                                                            "logs:PutLogEvents"
                                                                                                                          ],
                                                                                                                          "Resource": "*"
                                                                                                                        },
                                                                                                                        {
                                                                                                                          "Sid": "KmsDecrypt",
                                                                                                                          "Effect": "Allow",
                                                                                                                          "Action": [
                                                                                                                            "kms:Decrypt"
                                                                                                                          ],
                                                                                                                          "Resource": [
                                                                                                                            "arn:aws:kms:*:*:key/*"
                                                                                                                          ]
                                                                                                                        }
                                                                                                                      ]
                                                                                                                    }
                                                                                                                    
                                                                                                                  3. For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.

                                                                                                                  4. Select Next, type in a policy name, for example, ProtegrityProtectLambdaPolicy and Create Policy. Record the policy name:

                                                                                                                    ProtectLambdaPolicyName:__________________

                                                                                                                  1.9 -

                                                                                                                  Create Protect Lambda IAM Role

                                                                                                                  The following steps create the role to utilize the policy defined in Create Protect Lambda IAM Execution Policy.

                                                                                                                  To create protect lambda IAM execution role:

                                                                                                                  1. From the AWS IAM console, select Roles > Create Role.

                                                                                                                  2. Select AWS Service > Lambda > Next.

                                                                                                                  3. In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.

                                                                                                                  4. Click Next

                                                                                                                  5. Type the role name, for example, ProtegrityProtectRole

                                                                                                                  6. Click Create role

                                                                                                                  7. Record the role ARN.

                                                                                                                    Role ARN (LambdaExecutionRoleArn): ___________________

                                                                                                                  1.10 -

                                                                                                                  Upgrading Policy Agent Lambda

                                                                                                                  1. Go to AWS Lambda console and select existing Protegrity Agent Lambda.

                                                                                                                  2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish. The version of Agent Lambda you just created will serve as restore point in the case you needed to rollback the upgrade.

                                                                                                                  3. Go to Lambda Configuration > Environment variables.

                                                                                                                  4. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                                                                    aws lambda get-function-configuration --function-name \
                                                                                                                    arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                    --query Environment > <function_name>_env_config.json
                                                                                                                    
                                                                                                                  5. Go to AWS Cloud Formation and select existing Protegrity Agent deployment stack.

                                                                                                                  6. Select Update. Check Replace current template > Upload a template file.

                                                                                                                  7. Upload pty_agent_cf.json file and select Next.

                                                                                                                  8. Click Next until Review window and then select Update stack.

                                                                                                                  9. Wait for the Cloud Formation to complete.

                                                                                                                  10. Navigate back to Agent Lambda Function.

                                                                                                                  1. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                                                                    aws lambda update-function-configuration --function-name \
                                                                                                                    arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                    --environment file://./<function_name>_env_config.json
                                                                                                                    
                                                                                                                  2. If you are upgrading from versions prior to v3.0, backup and remove existing policy from the bucket defined by AWS_POLICY_S3_BUCKET property, so that the policy can be re-downloaded and re-encrypted with new ‘key commitment’ feature.

                                                                                                                  3. If you are upgrading from version prior to 1.6.1 please follow the steps below, otherwise the upgrade process is completed.

                                                                                                                  4. From AWS Console, navigate to IAM > Policies

                                                                                                                  5. Search for the Agent Lambda IAM Policy created in Create Agent Lambda IAM policy

                                                                                                                  6. Click on the policy, then select Edit Policy. Select JSON tab.

                                                                                                                  7. Add the following statement to the list of policy statements.

                                                                                                                    
                                                                                                                    {
                                                                                                                      "Sid": "LambdaGetConfiguration",
                                                                                                                      "Effect": "Allow",
                                                                                                                      "Action": [
                                                                                                                          "lambda:GetFunctionConfiguration"
                                                                                                                      ],
                                                                                                                      "Resource": [
                                                                                                                          "arn:aws:lambda:*:*:function:*"
                                                                                                                      ]
                                                                                                                    }
                                                                                                                    
                                                                                                                  8. Click Review Policy, then Save Changes. Wait for the changes to save.

                                                                                                                  1.11 -

                                                                                                                  Upgrading Log Forwarder Lambda

                                                                                                                  • Publish Log Forwarder Lambda Version

                                                                                                                    Publishing a version of the Log Forwarder Lambda allows to roll-back to pre-existing version if upgrade fails

                                                                                                                    1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                                                                    2. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                                                                    3. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                                                                      Log Forwarder Lambda version number for roll-backs: ___________________

                                                                                                                  • Disable Kinesis Trigger

                                                                                                                    Disabling Kinesis trigger ensures there are no unprocessed or re-processed events while function is upgraded.

                                                                                                                    1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                                                                    2. Select Configuration tab > Triggers
                                                                                                                    3. Check Kinesis trigger and click Edit button
                                                                                                                    4. Uncheck Activate trigger and click Save
                                                                                                                    5. Wait for function to stop processing events by monitoring function in Monitor tab
                                                                                                                  • Upgrade Forwarder Lambda Version

                                                                                                                    Upgrade Log Forwarder function with new code

                                                                                                                    1. Go to AWS Cloud Formation and select existing Protegrity Log Forwarder deployment stack.
                                                                                                                    2. Select Update Stack > Make a direct update.
                                                                                                                    3. Select Replace existing template > Upload a template file.
                                                                                                                    4. Upload pty_log_forwarder_cf file and select Next.
                                                                                                                    5. Click Next until Review window and then select Update stack.
                                                                                                                    6. Wait for the Cloud Formation to complete.
                                                                                                                  • Enable Kinesis Trigger

                                                                                                                    1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.
                                                                                                                    2. Select Configuration tab > Triggers
                                                                                                                    3. Check Kinesis trigger and click Edit button
                                                                                                                    4. Check Activate trigger and click Save Log Forwarder function will now start processing events from where it left off when Kinesis trigger was disabled.
                                                                                                                  • Monitor and roll-back

                                                                                                                    Monitor Log Forwarder function for errors in its CloudWatch logs and in Montior tab. To roll back function to the previous version if any errors occur follow these steps:

                                                                                                                    1. Go to AWS Lambda console and select existing Protegrity Log Forwarder Lambda.

                                                                                                                    2. Select Configuration tab > Triggers

                                                                                                                    3. Expand Details section of Kinesis trigger and record UUID value

                                                                                                                    4. Execute the following AWS CLI command to move Kinesis trigger to previous version of Log Forwarder Lambda that was created earlier and recorded as Log Forwarder Lambda version number for roll-backs. Substitute kinesis-mapping-uuid, log-forwarder-function-name, version-for-roll-backs with your values:

                                                                                                                      
                                                                                                                      aws lambda update-event-source-mapping --uuid <kinesis-mapping-uuid> --function-name <log-forwarder-function-name>:<version-for-roll-backs>
                                                                                                                      
                                                                                                                    5. Find Kinesis trigger attached to previous version of Log Forwarder Lambda by navigating Versions tab > Version number link in the Versions column Kinesis trigger is now moved to previous version of Log Forwarder Lambda function.

                                                                                                                  1.12 -

                                                                                                                  Upgrading Protect Lambda

                                                                                                                  Diagram below illustrates upgrade steps.

                                                                                                                  Snowflake Function Upgrade Steps

                                                                                                                  Redshift Function Upgrade Steps

                                                                                                                  Cloud API Function Upgrade Steps

                                                                                                                  Athena Function Upgrade Steps

                                                                                                                  • Publish Protect Lambda Version

                                                                                                                    Publishing a version of the Protect Lambda allows updating it without interruptions to the existing traffic.

                                                                                                                    1. Go to AWS Lambda console and select existing Protegrity Protect Lambda.

                                                                                                                    2. Go to Lambda Configuration > Environment variables.

                                                                                                                    3. Record environment variables values. You will use them later to configure upgraded Lambda Function. You can use the aws cli command below to save the function variables into the local json file:

                                                                                                                      aws lambda get-function-configuration --function-name \
                                                                                                                      arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                      --query Environment > <function_name>_env_config.json
                                                                                                                      
                                                                                                                    4. Click Actions in top right portion of the screen. Select Publish new version. Click Publish.

                                                                                                                    5. Record the Lambda version number. It will be displayed at the top of the screen. You can also retrieve it from the Lambda function view, under Versions tab.

                                                                                                                      Protect Lambda version number: ___________________

                                                                                                                    6. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                                                                      CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                                                          RETURNS varchar
                                                                                                                          VOLATILE lambda
                                                                                                                          'Protegrity_Protect_test:<protect_lambda_version_number>' iam_role
                                                                                                                          'arn:aws:iam::123456789212:role/example_role';
                                                                                                                      
                                                                                                                  • Run protect service upgrade

                                                                                                                    In this step, the Protect service including Lambda $LATEST version will be updated using Cloud Formation template. The Lambda version created in previous step will be used to serve existing traffic during the upgrade process.

                                                                                                                    1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                                                                    2. Select Update. Check Replace current template > Upload a template file.

                                                                                                                    3. Upload pty_protect_cf.json file and select Next.

                                                                                                                    4. Update ProtectFunctionProductionVersion parameter with Protect Lambda version number recorded in step 3.

                                                                                                                    5. Click Next until Review window and then select Update stack.

                                                                                                                    6. Wait for the Cloud Formation to complete.

                                                                                                                    7. Go back to Lambda console and select Protect Lambda.

                                                                                                                    8. Go to Configuration > Environment variables. Replace placeholder values with values recorded in previous step. Alternatively, you can run the following aws cli command to update function configuration using json file saved in the previous steps:

                                                                                                                      aws lambda update-function-configuration --function-name \
                                                                                                                      arn:aws:lambda:<aws_region>:<aws_account>:function:<function_name> \
                                                                                                                      --environment file://./<function_name>_env_config.json
                                                                                                                      
                                                                                                                    9. Navigate to Aliases tab. Verify that Production alias points to the lambda version you specified in the cloud formation template.

                                                                                                                    10. The upgraded Protect Lambda is configured with a sample policy. Run Agent Lambda Function before continuing with next steps.

                                                                                                                  • Finalize upgrade

                                                                                                                    In this step, the Protect Lambda will be configured to serve traffic using $LATEST version upgraded in the previous step.

                                                                                                                    1. Go back to Protegrity AWS Cloud Formation deployment stack.

                                                                                                                    2. Select Update. Check Use Current template.

                                                                                                                    3. Update ProtectFunctionProductionVersion parameter with the following value: $LATEST.

                                                                                                                    4. Click Next until Review window and then select Update stack.

                                                                                                                    5. Go back to Lambda console and select Protect Lambda.

                                                                                                                    6. From the Lambda console, verify that Latest alias points to $LATEST version.

                                                                                                                    7. Test your function to make sure it works as expected.

                                                                                                                    8. If you are upgrading a Cloud Protect Redshift version 1.x to 2.x/3x, you must recreate your Redshift external function definitions with Protect Lambda Function version appended to the Lambda Function name. See example below.

                                                                                                                      CREATE OR REPLACE EXTERNAL FUNCTION PTY_PROTECT_TEST ( val varchar )
                                                                                                                          RETURNS varchar
                                                                                                                          VOLATILE lambda
                                                                                                                          'Protegrity_Protect_test:Production' iam_role
                                                                                                                          'arn:aws:iam::123456789212:role/example_role';
                                                                                                                      
                                                                                                                    9. If you need to rollback to older version of Protect Lambda, you can re-run the cloud formation with ProtectFunctionProductionVersion parameter set to the previous version of Protect Lambda.

                                                                                                                  1.13 -

                                                                                                                  Re-enable Protegrity Agent Function CloudWatch Event Rule

                                                                                                                  If the Event Rule was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to re-enable Policy Agent Event rule.

                                                                                                                  1. Go to the Protegrity Agent Cloud Formation Stack.

                                                                                                                  2. Select Resources tab from the top portion of the screen.

                                                                                                                  3. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                                                                  4. Select Enable from the top-right portion of the screen. This will enable the rule. You will re-enable it after the upgrade process is complete.

                                                                                                                  1.14 -

                                                                                                                  Disable Protegrity Agent Function CloudWatch Event Rule

                                                                                                                  Cloud Watch Event Rule is used to periodically run Protegrity Agent Function to synchronize policy from ESA. This functionality is optional when deploying Protegrity Serverless Solution. If the Event Rule is enabled, it must be disabled temporarily for the time of the upgrade process.

                                                                                                                  Follow the steps below to determine if your deployment uses Event Rule and disable it.

                                                                                                                  1. Go to AWS Cloud Formation and select existing Protegrity deployment stack.

                                                                                                                  2. Select Resources tab from the top portion of the screen.

                                                                                                                  3. Check if there is a resource with ScheduledRule LogicalID. If there is no such resource you can skip to Upgrading Policy Agent Lambda section. If the scheduled rule is there, continue with the next steps in this section.

                                                                                                                  4. Click on the Physical ID link in the ScheduledRule row. The link opens Policy Agent Event Rule configuration.

                                                                                                                  5. Select Disable from the top-right portion of the screen. This will disable the rule. You will re-enable it after the upgrade process is complete.

                                                                                                                  1.15 -

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

                                                                                                                  After downloading the deployment package from the Protegrity Portal, unzip the package to extract the artifact files. In the AWS Console, navigate to the S3 bucket that was previously created to upload deployment artifacts (see: Create S3 bucket for Installing Artifacts).

                                                                                                                  Upload the following artifacts to the S3 bucket:

                                                                                                                  - -
                                                                                                                  • protegrity-protect-<version>.zip
                                                                                                                  • protegrity-agent-<version>.zip
                                                                                                                  • protegrity-external-extension-<version>.zip
                                                                                                                  • protegrity-sample-policy-<version>.zip
                                                                                                                  • protegrity-protect-<version>.zip
                                                                                                                  • protegrity-agent-<version>.zip
                                                                                                                  • protegrity-external-extension-<version>.zip
                                                                                                                  • protegrity-sample-policy-<version>.zip
                                                                                                                  • protegrity-protect-<version>.zip
                                                                                                                  • protegrity-agent-<version>.zip
                                                                                                                  • protegrity-external-extension-<version>.zip
                                                                                                                  • protegrity-sample-policy-<version>.zip
                                                                                                                  • protegrity-athena-protect-udfs-<version>.jar
                                                                                                                  • protegrity-external-extension-<version>.zip
                                                                                                                  • protegrity-agent-<version>.zip
                                                                                                                  • protegrity-sample-policy-<version>.zip

                                                                                                                  If the release version matches your existing deployment, you don’t need to upload it again. Save the following artifacts on your local system so that you have them available during the next steps:

                                                                                                                  - -
                                                                                                                  • pty_protect_cf.json
                                                                                                                  • pty_agent_cf.json
                                                                                                                  • pty_protect_cf.json
                                                                                                                  • pty_agent_cf.json
                                                                                                                  • pty_protect_api_cf.json
                                                                                                                  • pty_agent_cf.json
                                                                                                                  • pty_log_forwarder_cf.json
                                                                                                                  • pty_athena_protect_cf.json
                                                                                                                  • pty_agent_cf.json

                                                                                                                  Perform the following steps to upgrade the Agent Lambda and Protect Lambda separately.

                                                                                                                  2 - Azure

                                                                                                                  Protegrity products for Azure.

                                                                                                                  2.1 - Cloud API

                                                                                                                  Protector with a REST API on Azure.

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

                                                                                                                  Solution overview and features.

                                                                                                                    Solution Overview

                                                                                                                    Cloud API Protector on Azure 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 Azure service.

                                                                                                                    Features

                                                                                                                    Cloud API Protector on Azure 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.1.2 - Architecture

                                                                                                                    Deployment architecture and connectivity

                                                                                                                      Deployment Architecture

                                                                                                                      Protegrity’s Cloud API on Azure should be deployed in the Customer’s Cloud account. The product incorporates Protegrity’s vaultless tokenization engine within an Azure Function App. The encrypted data security policy from an ESA is deployed periodically as a static resource through an Azure Blob Storage container. The policy is decrypted in memory at runtime within the Function App. This architecture allows Protegrity Serverless 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 REST request includes a micro-batch of data to process and parameters such as operation and data element. The function applies the data 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 via another serverless component called the Protegrity Policy Agent. The agent operates on a configurable schedule, fetches policy from ESA, performs envelope encryption using Azure Key Vault, and deploys the policy into the Azure Blob Storage container which is accessed by Protector Function App. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator.

                                                                                                                      The following diagram shows the high-level architecture described above.

                                                                                                                      The following diagram shows a reference architecture for synchronizing the security policy from ESA.

                                                                                                                      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 Azure Blob Storage and Application Insights. The Cloud Protect product can also be configured to send audit logs to ESA. Such configuration requires deploying audit Log Forwarder component which is available as part of Cloud Protect deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

                                                                                                                      The audit log forwarding solution includes Azure Event Hubs data-streaming service and an Azure Function App deployment called Log Forwarder. Protect function delivers audit logs to Azure Event Hub instance, Event Hub instance batches audit logs and delivers them to Log Forwarder function. Log Forwarder function then delivers audit logs to ESA. Audit log aggregation occurs on both Protect and Log Forwarder functions. Aggregation rules are described in the Understanding the log aggregation section. If Log Forwarder cannot deliver audit logs to ESA due to temporary ESA connection loss, it will send undelivered audit logs to a dead-letter queue Event Hub. Audit logs in dead-letter queue Event Hub can be re-delivered to ESA using another instance of Log Forwarder, which can be configured to run either manually or on schedule.

                                                                                                                      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 function which verifies individual logs signature. The signature verification is done upon arrival from Azure Event Hub 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 client certificate to authenticate calls to ESA.

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

                                                                                                                      Forwarding of audit logs requires network access from the cloud to the ESA.

                                                                                                                      Access Control

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

                                                                                                                      • Azure role-based access control (Azure RBAC).
                                                                                                                      • Function access keys. Requests must include an API access key in the request.
                                                                                                                      • OpenID Connect. OpenID is a simple identity layer on top of the OAuth 2.0 protocol. Authorization is performed in the Protegrity Function App code.

                                                                                                                      For more information on Azure Function security concepts, refer to Azure documentation:

                                                                                                                      REST API Authentication and Authorization

                                                                                                                      The Rest API supports built-in authentication and authorization provided by Azure Function app. More information is available in the following Azure documentation:

                                                                                                                      App Service Authentication/Authorization Overview

                                                                                                                      REST API Policy Authorization

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

                                                                                                                      2.1.3 - Installation

                                                                                                                      Product Installation Guide.

                                                                                                                      2.1.3.1 - Prerequisites

                                                                                                                      Requirements before installing the protector.

                                                                                                                        Azure Services

                                                                                                                        The following table describes the Azure services that may be part of your Protegrity installation.

                                                                                                                        All permissions in the table must be granted with the Resource group scope.

                                                                                                                        Service

                                                                                                                        Description

                                                                                                                        Microsoft Entra ID Application

                                                                                                                        Allows authentication with Azure Function app

                                                                                                                        Azure Managed Identity

                                                                                                                        Allows functions assume user-defined managed identity

                                                                                                                        Function App

                                                                                                                        Provides serverless compute for Protegrity protection operations and ESA integration to fetch policy updates or deliver audit logs.

                                                                                                                        API Management Service

                                                                                                                        Provides the end-point and access control

                                                                                                                        Azure Key Vault

                                                                                                                        Provides cryptographic keys for envelope encryption/decryption of the policy. Stores secrets required during deployment, e.g., ESA credentials

                                                                                                                        Blob storage

                                                                                                                        Intermediate storage location for the encrypted ESA policy package

                                                                                                                        Application Insights

                                                                                                                        Application and audit logs, performance monitoring, and alerts

                                                                                                                        Azure Event Hubs

                                                                                                                        Required if audit logs are to be sent to ESA. Set up and configuration of a new Event Hub is covered in section Audit Log Forwarder Installation.

                                                                                                                        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

                                                                                                                        Requirement

                                                                                                                        Detail

                                                                                                                        Protegrity distribution and installation scripts

                                                                                                                        These artifacts are provided by Protegrity

                                                                                                                        Protegrity ESA 10.0+

                                                                                                                        The Cloud VNet must be able to obtain network access to the ESA

                                                                                                                        Azure Account (Azure Global or US Government Subscription)

                                                                                                                        Recommend creating a new resource group for Protegrity.

                                                                                                                        Required Skills and Abilities

                                                                                                                        Role / Skillset

                                                                                                                        Description

                                                                                                                        Azure Account Administrator

                                                                                                                        Ability to run Azure Resource Manager (or perform steps manually), create/configure Entra ID Application Registrations

                                                                                                                        Protegrity Administrator

                                                                                                                        The ESA credentials required to extract the policy for the Policy Agent

                                                                                                                        Snowflake Administrator

                                                                                                                        Account Admin access required to setup Snowflake integration

                                                                                                                        Network Administrator

                                                                                                                        Needed to open firewall to access ESA and evaluate Azure network setup

                                                                                                                        2.1.3.2 - Pre-Configuration

                                                                                                                        Configuration steps prior product installation.

                                                                                                                          Resource Group

                                                                                                                          Identify or create a new Azure Resource Group where the Protegrity solution will be installed. It is recommended that a new Resource group is created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some of the subsequent installation steps.

                                                                                                                          Azure Subscription ID (AzureSubscriptionID): ____________________

                                                                                                                          Azure Resource Group ID (ApiResourceGroupID): ___________________

                                                                                                                          Azure Region (ApiRegion): ___________________

                                                                                                                          Key Vault

                                                                                                                          Key Vault is required to store secrets and encrypt policy deployment package. Identify existing Key Vault or create new.

                                                                                                                          To create Key Vault:

                                                                                                                          1. From the Azure Console select Create a resource.

                                                                                                                          2. Navigate to Key Vault > Create.

                                                                                                                          3. Select a Resource group.

                                                                                                                          4. Enter a Key vault name.

                                                                                                                          5. Select a Region. For the best performance, use the same region for all resources.

                                                                                                                          6. Set the Pricing tier to Standard.

                                                                                                                          7. Under Access configuration, select Vault access policy as the Permission model.

                                                                                                                          8. Under Networking, ensure that Enable public access is selected.

                                                                                                                          9. Under Review + create, click Create.

                                                                                                                          10. Record Key Vault Name:

                                                                                                                            Key Vault Name (PolicyKeyValue): ___________________

                                                                                                                          Function App Storage

                                                                                                                          Create Storage Account

                                                                                                                          Create a storage account to host Protegrity deployment packages provided in installation artifact bundle. Note that turning on the firewall or restricting access to selected virtual networks or IP address ranges will require additional configuration and is beyond the scope of this document.

                                                                                                                          To create Function App storage:

                                                                                                                          1. From the Azure Console select Create a resource.

                                                                                                                          2. Navigate to Storage account > Create.

                                                                                                                          3. Select the Resource group where the Protegrity solution will be deployed.

                                                                                                                          4. Enter a Storage account name.

                                                                                                                          5. Select the Region where the Protegrity solution will be deployed.

                                                                                                                          6. Set the Preferred storage type to Azure Blob Storage or Azure Data Lake Storage

                                                                                                                          7. Set the Primary workload to Cloud native

                                                                                                                          8. Setting for Performance should be set to Standard.

                                                                                                                          9. Setting for Redundancy should be set to Geo-redundant storage (GRS).

                                                                                                                          10. Continue to Advanced setup and verify Enable hierarchical namespace is unchecked

                                                                                                                          11. Adjust the Networking and Data protection configurations according to your security requirements or use the default values.

                                                                                                                          12. Under Review + create, click Create.

                                                                                                                          13. Record the storage account name

                                                                                                                            Storage Account Name (StorageAccountName): ____________________

                                                                                                                          14. Record the storage blob service URL. Navigate to created Storage Account, select Settings, Endpoints, record the value of Blob Service

                                                                                                                            Storage Account Blob Service Url (StorageAccountBlobServiceUrl): ____________________

                                                                                                                          Upload Files

                                                                                                                          Create a deployment container using the Azure Blob Service.

                                                                                                                          1. Go Storage Account created in the previous step.

                                                                                                                          2. Under Data storage section, select Containers and click + Container .

                                                                                                                          3. Type in container name and click Create .

                                                                                                                          4. Upload the following installation artifacts to the container:

                                                                                                                          • protegrity-protect-azure-<version>.zip
                                                                                                                          • protegrity-agent-azure-<version>.zip
                                                                                                                          1. Record Protect function blob URL:

                                                                                                                            Protect Function Blob URL (ProtectFuncURL): ____________________

                                                                                                                          2. Record Forward function blob URL. Both Protect and Forward functions use the same protegrity-protect-azure-<version>.zip distribution:

                                                                                                                            Forward Function Blob URL (ForwardFuncURL): ____________________

                                                                                                                          3. Record Agent function blob URL:

                                                                                                                            Agent Function Blob URL (AgentFuncURL): ____________________

                                                                                                                          Create Protect Function Policy Blob

                                                                                                                          Create a blob container for encrypted Protegrity security policy using Azure Blob Service. Agent will store encrypted policy in this container. Both Protect and Log Forwarder functions will load policy from this container.

                                                                                                                          1. Go Storage Account created in the previous step.

                                                                                                                          2. Under Data storage section, select Containers and click + Container .

                                                                                                                          3. Type in container name and click Create .

                                                                                                                          4. Right-click the container name, and select Container properties to obtain URL.

                                                                                                                            Append the name of the policy file to the container URL, e.g, https://<your-storage-account>.blob.core.windows.net/<your-policy-container>/<your-policy-file-name>.zip. Record the blob url.

                                                                                                                            Protect Function Policy Blob URL (ProtectFuncPolicyBlobUrl): ____________________

                                                                                                                          Create Agent Policy Blob Container

                                                                                                                          The Agent function uploads an encrypted policy zip package to a blob container which is used as a staging storage. Create the policy staging container

                                                                                                                          To prepare the policy blob container:

                                                                                                                          1. Under Storage account created in previous step, select Data storage > Containers and click + Container .

                                                                                                                          2. Type in a container name and click Create .

                                                                                                                            Agent Policy Blob Container Name (AgentPolicyBlobContainer): ___________________

                                                                                                                          2.1.3.3 - Protect Service Installation

                                                                                                                          Product Installation Guide.

                                                                                                                            Preparation

                                                                                                                            1. Ensure that all the steps in Pre-Configuration are performed.

                                                                                                                            2. Login to the Azure account console where Protegrity will be installed.

                                                                                                                            3. Ensure the Azure Resource Manager templates provided by Protegrity are available on your local computer.

                                                                                                                            Register an Entra ID App

                                                                                                                            A Microsoft Entra ID App provides the mechanism for Client to authenticate with the Function App instance. Creating an Entra ID app requires appropriate permissions to the Azure Subscription and is typically performed by the Azure Account Administrator.

                                                                                                                            To register an Entra ID App:

                                                                                                                            1. In the Azure portal navigate to Microsoft Entra ID.

                                                                                                                            2. Click + Add and select App registration.

                                                                                                                            3. Enter a Name and select Accounts in any organizational directory.

                                                                                                                            4. Leave the Redirect URI empty and select Register.

                                                                                                                            5. After registration is complete record the application name and application id displayed in the overview window.

                                                                                                                              Entra ID Application Name (EntraIDApplicationName): ___________________

                                                                                                                              Entra ID Application ID (EntraIDApplicationID): ___________________

                                                                                                                            Protect Function User-Assigned Managed Identity

                                                                                                                            User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                            1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                            2. Select Create

                                                                                                                            3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                            4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                            5. For Region provide recorded value of ApiRegion

                                                                                                                            6. For Name provide a name of the new identity

                                                                                                                            7. Assign following roles to this identity:

                                                                                                                              • Storage Blob Data Owner
                                                                                                                              • Monitoring Metrics Publisher
                                                                                                                              • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                            8. Record Protect function user-assigned identity

                                                                                                                              Protect Function User-Assigned Identity (ProtectFuncUserAssignedIdentity): ____________________

                                                                                                                            Install Protect Function via Azure Resource Manager

                                                                                                                            Resources created with the ARM template include API Management service, Function App, App Service Plan and Application Insights service.

                                                                                                                            To install protect function via Azure Resource Manager:

                                                                                                                            1. From Azure Console, select Create a resource, search for template then select Template deployment (deploy using custom templates) > Create.

                                                                                                                            2. Select Build your own template in the editor.

                                                                                                                            3. Click Load File and upload pty_protect_arm_v2.json, then click Save.

                                                                                                                            4. Select a Resource group.

                                                                                                                            5. Enter a Name for the resources. All resources will be prefixed with Protegrity-Protect except for log container which will be prefixed with ptylogs. For more information on naming rules see: Azure resource name rules.

                                                                                                                            6. For Location input specify Azure region name or leave default to deploy in the same region as resource group.

                                                                                                                            7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Protect Function Blob Url.

                                                                                                                            8. For Protect Function Blob Url use the value from Upload Files.

                                                                                                                            9. For Function App Managed Identity Optionally use the value from Protect Function User-Assigned Managed Identity. If value is not given, a system-assigned managed identity will be enabled.

                                                                                                                            10. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                            11. For Create Api Management Service select Do not create. API Management Service is required only for integration with Snowflake. This service is not required otherwise.

                                                                                                                            12. For Api Management Service Sku Applicable only when API Management Service is created. Skip this if API Management Service is not created. Either Consumption (if available) or Premium are recommended. Note that this will affect the running cost.

                                                                                                                            13. For Username Regex you can optionally specify regex to extract policy username from the request. See Configuring Regular Expression to Extract Policy Username for more details.

                                                                                                                            14. For Entra ID Application ID enter the value recorded in Register an Entra ID App.

                                                                                                                            15. For Forward Logs To ESA select whether audit logs are to be sent to ESA or not. If you are not planning on sending audit logs to ESA you can skip Event Hub Nameand Event Hub Namespace properties below. For details on creating and configuring Event Hubs see Audit Log Forwarder Installation

                                                                                                                            16. For Event Hub Name provide the name of Event Hub which will be used to send audit logs to ESA.

                                                                                                                            17. For Event Hub Namespace provide the name of Event Hub Namespace which is hosting Event Hub selected in previous step.

                                                                                                                            18. Under Review + create, click Create. Wait for all resources to deploy. If the deployment fails for any resources of type Microsoft.Web/sites/host/functionKeys then click Redeploy and try deploying again.

                                                                                                                            19. After deployment is complete, go to Outputs and record protectFunctionName, azureTenantId and apiGatewayUrl.

                                                                                                                              Protect Function Name (ProtectFuncName): __________________

                                                                                                                              Azure Tenant ID (AzureTenantID): __________________

                                                                                                                              API Gateway URL (ApiGatewayURL): __________________

                                                                                                                            Function System-Assigned Managed Identity

                                                                                                                            System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                            If you have not created a user-assigned managed identity at Protect Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                            1. Navigate to the function

                                                                                                                            2. Select Settings, Identity.

                                                                                                                            3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                            4. Click on Azure role assignments button.

                                                                                                                            5. Assign following roles to this identity:

                                                                                                                              • Storage Blob Data Owner
                                                                                                                              • Monitoring Metrics Publisher
                                                                                                                              • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                            6. From Azure console, navigate to Function App and select protect function deployed in previous section.

                                                                                                                            7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                            Update Key Vault Access Policies

                                                                                                                            The Key vault must be updated to allow the Function App to decrypt the policy files. Azure assigns a unique identifier to each Function App instance that can be used to grant permissions to that instance. Update the Key vault access policies with the Protect function. To update the key vault access policies:

                                                                                                                            Obtain Function App identifier

                                                                                                                            1. Navigate to the Function App service in the Azure portal.

                                                                                                                            2. Select the newly created Protect Function App instance.

                                                                                                                            3. Select the Identity option under Settings.

                                                                                                                            4. Ensure that setting System assigned is set to Status On.

                                                                                                                            5. Record the Object ID:

                                                                                                                              Protect Function Object ID: ___________________

                                                                                                                            Update the Key vault access policies with the Protect function’s Object ID

                                                                                                                            1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                            2. Select Access policies.
                                                                                                                            3. Click Create.
                                                                                                                            4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                            5. Proceed Next to Principal.
                                                                                                                            6. Enter the Protect Function Object ID recorded in this section into the search field.
                                                                                                                            7. Select the Function App instance.
                                                                                                                            8. Proceed Next to Application and Next again to Review + Create.
                                                                                                                            9. Review permissions and Create.

                                                                                                                            Upload the Sample Policy

                                                                                                                            The Protegrity installation bundle contains a sample policy which can be used to test the protect service installation without an ESA. Upload the sample policy artifact to the policy Blob storage container:

                                                                                                                            1. Go to Azure console and select Storage Account Name (StorageAccountName) recorded in step Create Storage Account.

                                                                                                                            2. Under Data storage select Blob Containers and select container created in Protect Function Policy Blob Container

                                                                                                                            3. Click Upload and select protegrity-sample-policy-<version>.zip file from your local computer.

                                                                                                                            4. Click Upload and wait for the file to complete uploading.

                                                                                                                            5. Record the sample policy blob url:

                                                                                                                              Sample Policy Blob Url (SamplePolicyBlobUrl): ___________________

                                                                                                                            Test the Protect Function Installation

                                                                                                                            Before continuing with next steps, you may verify the protect service is installed correctly. This step is optional and can be skipped.

                                                                                                                            1. From Azure console, navigate to Function App and select protect function app.

                                                                                                                            2. Select Overview and record URL value as <Protect Function URL>.

                                                                                                                            3. Navigate to Settings > Environment variables and click OPENID_ENABLED.

                                                                                                                            4. Change value to false and click Apply.

                                                                                                                            5. Select or create variable AZURE_POLICY_BLOB_URL.

                                                                                                                            6. Set value of AZURE_POLICY_BLOB_URL to value recorded for SamplePolicyBlobUrl and click Apply.

                                                                                                                            7. Select Apply and Confirm to finalize setting changes.

                                                                                                                            8. Go to Functions > App keys and record the value of default key under Host Keys (All functions) as <Protect Function app key>.

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

                                                                                                                              curl -X POST "<Protect Function URL>/api/v1/unprotect" -k \
                                                                                                                              -H 'x-functions-key: <Protect Function app key>' \
                                                                                                                              -H 'Content-Type: application/json' \
                                                                                                                              -d '{
                                                                                                                                "data": ["UtfVk UHgcD!"],
                                                                                                                                "user": "MARIA",
                                                                                                                                "data_element": "alpha"
                                                                                                                              }'
                                                                                                                              
                                                                                                                            10. Replace <Protect Function URL> and <Protect Function app key> with the values recorded in step 2 And 5.

                                                                                                                            11. Run curl command. Verify the following output.

                                                                                                                              {"data":["hello world!"], "success": true, "encoding": "utf8"}
                                                                                                                              
                                                                                                                            12. Go back to Function app. Select Settings > Environment variables and click OPENID_ENABLED,

                                                                                                                            13. Change value to true and click Apply. Select Apply and Confirm to finalize.

                                                                                                                            Troubleshooting

                                                                                                                            To review live requests, navigate to Application Insights service and select item with the same name as the protect function. Under Investigate, select Live Metrics. Wait for the dashboard to load, then go to Sample Telemetry pane on the right and look for the requests in question.

                                                                                                                            To review the full history of requests from Application Insights under Monitoring select Logs:

                                                                                                                            1. Select the Tables tab.
                                                                                                                            2. Hover over one of the table names under Application Insights header, for example exceptions.
                                                                                                                            3. Click on See preview data.
                                                                                                                            4. Click Use in editor.

                                                                                                                            You can also run the query directly in the query editor. For instance to select the 10 latest exceptions run the following query.

                                                                                                                            exceptions 
                                                                                                                            | where timestamp > ago(24h)
                                                                                                                            | order by timestamp
                                                                                                                            | limit 10
                                                                                                                            

                                                                                                                            Protect Function App Configuration

                                                                                                                            Protect Function app can be customized using environment variables. From Azure console, navigate to Function App service and select protect function app. Navigate to Settings > Environment variables. Add or Edit environment variables based on the following information.

                                                                                                                            ParameterDescriptionNotes
                                                                                                                            OPENID_ENABLEDWhen 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_AUDIENCESThe 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.applicable when OPENID_ENABLED= “true”.
                                                                                                                            OPENID_ISSUERSThe 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.applicable when OPENID_ENABLED= “true”.
                                                                                                                            OPENID_METADATA_URLA URL that points to an OpenID Connect identity provider configuration document, which is also known as OpenID well-known configuration endpoint.applicable when OPENID_ENABLED= “true”.
                                                                                                                            authorizationWhen equals “jwt”, Authorization Header JWT will be required in the Rest API Protect payload.
                                                                                                                            Supported Values: [“jwt”, “”]When equals to “jwt”, any request without Valid JWT in the Authorization header, will result in an error from API Gateway: 502 Bad Gateway.
                                                                                                                            allow_assume_userIf set to 0, The user from the payload will not be used, and the policy user is the JWT user.
                                                                                                                            Supported Values: [0, 1]applicable when authorization = “jwt”.
                                                                                                                            Default Value: 0
                                                                                                                            jwt_user_claimThe JWT payload claim with username. Common claims: name, preferred_username, cognito:usernameApplicable when authorization = “jwt”
                                                                                                                            Default Value: cognito:username
                                                                                                                            service_userIf 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.
                                                                                                                            AZURE_POLICY_BLOB_URLThis points to Protegrity security policy blob. It is updated by the Agent to point to latest security policy.
                                                                                                                            USERNAME_REGEXIf USERNAME_REGEX is set, the effective policy user will be extracted from the user in the request.
                                                                                                                            EVENTHUB_NAMEEvent Hub name where audit logs are to be sent to. Logs are not forwarded to ESA when this parameter is empty.
                                                                                                                            EventHub__fullyQualifiedNamespaceEvent Hub fully qualified namespace. Logs are not forwarded to ESA when this parameter is empty.
                                                                                                                            PTY_CORE_FLUSHINTERVALTime interval in seconds used to accumulate audit logs before sending to Event Hub. Default value: 10.Audit logs are always aggregated into one minute buckets. A value greater than 60 will influence only audit log batching while sending logs to Event Hub. A value less than 60 will influence both aggregation and audit log batching.
                                                                                                                            PTY_LOG_LEVELFunction min log level. Default: SevereOne of case-insensitive strings: off, severe, warning, info, config, all.
                                                                                                                            PTY_WRITE_LOG_ON_SINGLE_LINEWhether to write log level and message on one line or separate lines. Default: trueStarting from version 3.1.0, log level and message are printed on single line. Use this environment variable to switch to multi-line logging for backward compatibility with pre-3.1.0 release.
                                                                                                                            EVENT_LEVELLevel of logs produced by Azure services. Default: ErrorOne of case-insensitive strings: LogAlways, Critical, Error, Warning, Informational, Verbose. Set to at least ‘Informational’ during initial configuration, set to at most ‘Error’ in production environments.
                                                                                                                            ParameterNotes
                                                                                                                            AZURE_CLIENT_IDSets the Managed Identity Client ID for Function App runtime. System-Assigned Identity is used when variable is not set.
                                                                                                                            APPLICATIONINSIGHTS_AUTHENTICATION_STRINGDefine identity for Application Insights access. Managed Identity Client ID is provided to this setting with Function App Managed Identity ARM template parameter. See the corresponding Azure AD Authentication documentation: Azure AD authentication
                                                                                                                            APPLICATIONINSIGHTS_CONNECTION_STRINGConnection String for Application Insights instance. See the corresponding Azure Connection String documentation: Connection strings
                                                                                                                            FUNCTIONS_EXTENSION_VERSIONAzure Functions extension version
                                                                                                                            FUNCTIONS_WORKER_RUNTIMERuntime of the function
                                                                                                                            WEBSITE_RUN_FROM_PACKAGEURL to the zip file in blob storage with function runtime source
                                                                                                                            WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_IDManaged Identity used to load function runtime source
                                                                                                                            AzureWebJobsStorage__blobServiceUriURL of the storage account which hosts the blob identified in WEBSITE_RUN_FROM_PACKAGE
                                                                                                                            AZURE_TENANT_IDTenant identifier in Azure Active Directory
                                                                                                                            AzureWebJobs.AuditLogForwarder.DisabledDefines whether audit log forwarder function is disabled or not
                                                                                                                            AzureWebJobs.Protect.DisabledDefines whether Protect function is disabled or not
                                                                                                                            AzureWebJobs.v1-openapi.DisabledDefines whether v1-openapi function is disabled or not
                                                                                                                            AzureWebJobs.v1-protect.DisabledDefines whether v1-protect function is disabled or not
                                                                                                                            AzureWebJobs.v1-unprotect.DisabledDefines whether v1-unprotect function is disabled or not

                                                                                                                            2.1.3.4 - Policy Agent Installation

                                                                                                                            Install the policy agent.

                                                                                                                              Policy Agent Function installation is done via Azure Resource Manager template 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 Function App on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted. You can find the list of Agent Function Outbound IP addresses after you deploy the function in Agent Function Outbound IP address

                                                                                                                              Note down ESA IP to be accessed form Agent Function:

                                                                                                                              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 policy agent Cloud Function Environment variables configuration.

                                                                                                                              In case ESA is configured with publicly signed certificates, this section can be skipped since the agent 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 variable in the Policy Agent Function Configuration section Configure Function

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

                                                                                                                              Create Policy Encryption Key

                                                                                                                              Create a policy encryption key.

                                                                                                                              To create policy encryption key:

                                                                                                                              1. From Azure console, navigate to Key Vaults and select Key Vault created in Key Vault.

                                                                                                                              2. Under Objects, select Keys.

                                                                                                                              3. Click Generate/Import.

                                                                                                                              4. Specify the following:

                                                                                                                                a. Key name for the Name field.

                                                                                                                                b. RSA for Key type.

                                                                                                                                c. 2048 for RSA key size.

                                                                                                                                d. Set Enabled toggle to Yes.

                                                                                                                              5. Select Create.

                                                                                                                              6. Click on the key name after creation is complete, then click on the key identifier row under CURRENT VERSION.

                                                                                                                              7. Copy the full URL value of Key Identifier. Record it for later use:

                                                                                                                                Policy Encryption Key ID (PolicyEncryptionKey): _________________

                                                                                                                              Agent Function User-Assigned Managed Identity

                                                                                                                              User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                              1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                              2. Select Create

                                                                                                                              3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                              4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                              5. For Region provide recorded value of ApiRegion

                                                                                                                              6. For Name provide a name of the new identity

                                                                                                                              7. Assign following roles to this identity:

                                                                                                                                • Storage Blob Data Owner with scope Storage account
                                                                                                                                • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                • Website Contributor with scope Resource Group
                                                                                                                              8. Record Agent function user-assigned identity

                                                                                                                                Agent Function User-Assigned Identity (AgentFuncUserAssignedIdentity): ____________________

                                                                                                                              Install Agent via ARM template

                                                                                                                              Resources created with ARM template include Function App, Premium V3 App Service Plan (optional) and Application Insights service. Run Azure Resource Manager deployment.

                                                                                                                              To install Agent via ARM template:

                                                                                                                              1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                              2. Select Build your own template in editor.

                                                                                                                              3. Select Load File and upload pty_agent_arm_v2.json. Click Save.

                                                                                                                              4. Select Resource Group.

                                                                                                                              5. Specify Name for the resources (All resources will be prefixed with Protegrity-Agent).

                                                                                                                              6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                              7. For Agent Function Blob Url use the value from Upload Files

                                                                                                                              8. For Function App Managed Identity Optionally use the value from Agent Function User-Assigned Managed Identity. If value is not given, a system-assigned managed identity will be enabled.

                                                                                                                              9. If you set Use Existing App Service Plan to True, you must specify existing Linux App Service Plan name in the next parameter.

                                                                                                                              10. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Agent Function Blob Url.

                                                                                                                              11. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                              12. After deployment is complete, go to Outputs and record agentFunctionName:

                                                                                                                                Agent Function Name: __________________

                                                                                                                              Function System-Assigned Managed Identity

                                                                                                                              System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                              If you have not created a user-assigned managed identity at Agent Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                              1. Navigate to the function

                                                                                                                              2. Select Settings, Identity.

                                                                                                                              3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                              4. Click on Azure role assignments button.

                                                                                                                              5. Assign following roles to this identity:

                                                                                                                                • Storage Blob Data Owner with scope Storage account
                                                                                                                                • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                • Website Contributor with scope Resource Group

                                                                                                                              Creating ESA Credentials

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

                                                                                                                              ESA Credentials In Azure Key Vault

                                                                                                                              Policy Agent Function uses Key Vault as secure store for sensitive information like ESA username and password.

                                                                                                                              Create ESA credentials secrets:

                                                                                                                              1. Navigate to Key Vault.

                                                                                                                              2. Under Objects, select Secrets > Generate/import.

                                                                                                                              3. Select Manual, then type in valid json as shown in the example for Secret value.

                                                                                                                                {"username": "<policy_export_user>", "password": "<password>"}
                                                                                                                                
                                                                                                                              4. Select Create.

                                                                                                                              5. Navigate to the secret details in Key Vault by selecting the newly created secret.

                                                                                                                              6. Inspect the current secret version properties by selecting the current version.

                                                                                                                              7. Copy the Secret Identifier value. For example https://<myvault>.vault.azure.net/secrets/<mysecret>/abcdefgxyz8edef595adaehij0d99123.

                                                                                                                              8. Record the Secret Identifier for later use.

                                                                                                                              ESA Credentials From Custom Azure Function App

                                                                                                                              Policy Agent Function requests ESA username and password from a custom Azure Function App, further referred to as ESA Credentials function. This method may be used to get the username and password from external vaults.

                                                                                                                              There are four options for configuring Policy Agent authorization with ESA Credentials function: Option 1, Option 2, Option 3 and Option 4. Only one option is expected to be configured at a time.

                                                                                                                              Create ESA credentials function:

                                                                                                                              1. Create Azure HTTP triggered ESA Credentials function using any supported runtime.

                                                                                                                                a. There is no input needed.

                                                                                                                                b. The function must accept an HTTP POST request.

                                                                                                                                c. The function must return the following response schema

                                                                                                                                ```
                                                                                                                                response: 
                                                                                                                                type: json object
                                                                                                                                  properties: 
                                                                                                                                    username: string 
                                                                                                                                    password: string  
                                                                                                                                ```
                                                                                                                                
                                                                                                                                For example,
                                                                                                                                
                                                                                                                                ```
                                                                                                                                {"username": "admin", "password": "Password1234"} 
                                                                                                                                ```
                                                                                                                                
                                                                                                                              2. Configure Policy Agent to use ESA Credentials function app.

                                                                                                                                a. Navigate to HTTP triggered function to open ‘Code + Test’ page.

                                                                                                                                b. Under ‘Code + Test’ tab on ‘Code + Test’ page select ‘Resource JSON’.

                                                                                                                                c. In ‘Resource JSON’ blade record the value of ‘invoke_url_template’ property.

                                                                                                                                **'invoke_url_template'** property is located towards the bottom of resource json.
                                                                                                                                
                                                                                                                                URL must be in the form of 'https://[function-app-name].azurewebsites.[net|us]/api/[http-trigger-name]'.
                                                                                                                                
                                                                                                                                **ESA Credentials function URL (EsaCredentialsFnUrl):__________**
                                                                                                                                

                                                                                                                                d. Navigate to Policy Agent function app.

                                                                                                                                e. Expand Settings menu item.

                                                                                                                                f. Select Environment Variables menu item.

                                                                                                                                g. Click Add button.

                                                                                                                                h. For Name use PTY_ESA_CREDENTIALS_FUNCTION.

                                                                                                                                i. For Value use ESA Credentials function URL (EsaCredentialsFnUrl) recorded in previous steps.

                                                                                                                                j. Hit Apply in Add/Edit application setting blade.

                                                                                                                                k. Hit Apply in App Settings tab.

                                                                                                                              3. Configure Authorization Option 1: Function Key Option 2: Key Vault Option 3: System-assigned Identity Option 4: User-assigned Identity

                                                                                                                              Authorization Option 1: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from environment variables.
                                                                                                                              1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                Review Azure documentation on how to accomplish this.

                                                                                                                              2. Navigate to ESA Credentials function app.

                                                                                                                              3. Expand Functions menu item.

                                                                                                                              4. Select App Keys.

                                                                                                                              5. Record default key value.

                                                                                                                                ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                              6. Navigate to Policy Agent function app.

                                                                                                                              7. Expand Settings menu item.

                                                                                                                              8. Select Environment Variables menu item.

                                                                                                                              9. Click Add button.

                                                                                                                              10. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY.

                                                                                                                              11. For Value use ESA Credentials function key (EsaCredentialsFnKey) recorded in previous steps.

                                                                                                                              12. Hit Apply in Add/Edit application setting blade.

                                                                                                                              13. Hit Apply in App Settings tab.

                                                                                                                              Authorization Option 2: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from Azure Key Vault.
                                                                                                                              1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                Review Azure documentation on how to accomplish this.

                                                                                                                              2. Navigate to ESA Credentials function app.

                                                                                                                              3. Expand Functions menu item.

                                                                                                                              4. Select App Keys.

                                                                                                                              5. Record default key value.

                                                                                                                                ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                              6. Navigate to Key Vault.

                                                                                                                              7. Under Objects, select Secrets > Generate/import.

                                                                                                                              8. Select Manual, type in secret name and use ESA Credentials function key value recorded in previous steps (EsaCredentialsFnKey) for Secret value.

                                                                                                                              9. Select Create.

                                                                                                                              10. Record Key Vault secret name.

                                                                                                                                ESA Credentials function key secret name (EsaCredentialsFnKeySecretName):_______________

                                                                                                                              11. Navigate to Policy Agent function app.

                                                                                                                              12. Expand Settings menu item.

                                                                                                                              13. Select Environment Variables menu item.

                                                                                                                              14. Click Add button.

                                                                                                                              15. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET.

                                                                                                                              16. For Value use ESA Credentials function key secret name (EsaCredentialsFnKeySecretName) recorded in previous steps.

                                                                                                                              17. Hit Apply in Add/Edit application setting blade.

                                                                                                                              18. Hit Apply in App Settings tab.

                                                                                                                              Authorization Option 3: Configure ESA Credentials authentication provider to authorize Policy Agent system-assigned identity.
                                                                                                                              1. Navigate to Policy Agent function app

                                                                                                                              2. Expand Settings menu item

                                                                                                                              3. Select Identity

                                                                                                                              4. Select System assigned tab

                                                                                                                              5. Status should already be On

                                                                                                                                Other Status indicates Policy Agent was installed without system-assigned identity. Before proceeding any further you need to either install Policy Agent with system-assigned identity or follow Option 4 which describes configuration steps for Policy Agent installed with user-assigned managed identity.

                                                                                                                              6. Copy Object (principal) ID

                                                                                                                              7. Navigate to ESA Credentials function app

                                                                                                                              8. Expand Settings menu item

                                                                                                                              9. Select Authentication

                                                                                                                              10. Select Add identity provider

                                                                                                                                Review related Microsoft documentation

                                                                                                                              11. Select Microsoft in identity provider dropdown

                                                                                                                              12. For App registration type provide details of your choice

                                                                                                                              13. For Issuer URL accept the default value

                                                                                                                              14. For Client application requirement select Allow requests from any application

                                                                                                                                Access will be limited to only the Policy Agent identity in the next step

                                                                                                                              15. For Identity requirement select Allow requests from specific identities

                                                                                                                              16. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                              17. For Restrict access select Require authentication

                                                                                                                              18. For Unauthenticated requests select HTTP 401 Unauthorized: recommended for APIs

                                                                                                                              19. Check Token store

                                                                                                                              20. Select Add

                                                                                                                              21. Click OK to apply constraint

                                                                                                                              22. Click Save

                                                                                                                              23. Navigate to Application of Microsoft identity provider

                                                                                                                                A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                              24. Expand Manage menu item

                                                                                                                              25. Select Expose an API

                                                                                                                              26. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                              27. Record Application ID URI of identity provider

                                                                                                                                ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                              28. Navigate to Policy Agent function app.

                                                                                                                              29. Expand Settings menu item.

                                                                                                                              30. Select Environment Variables menu item.

                                                                                                                              31. Click Add button.

                                                                                                                              32. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                              33. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                Review Microsoft identity platform default scope

                                                                                                                              34. Hit Apply in Add/Edit application setting blade.

                                                                                                                              35. Hit Apply in App Settings tab.

                                                                                                                              Authorization Option 4: Configure ESA Credentials authentication provider to authorize Policy Agent user-assigned identity.
                                                                                                                              1. Navigate to Policy Agent function app

                                                                                                                              2. Expand Settings menu item

                                                                                                                              3. Select Identity

                                                                                                                              4. Select User assigned tab

                                                                                                                                User-assigned identity should already be provided. Missing user-assigned identity indicates Policy Agent was installed without user-assigned identity. Before proceeding any further you need to either install Policy Agent with user-assigned identity or follow Option 3 which describes configuration steps for Policy Agent installed with system-assigned managed identity.

                                                                                                                              5. Copy Client ID

                                                                                                                              6. Copy Object (principal) ID

                                                                                                                              7. Navigate to ESA Credentials function app

                                                                                                                              8. Expand Settings menu item

                                                                                                                              9. Select Authentication

                                                                                                                              10. Select Add identity provider

                                                                                                                                Review related Microsoft documentation

                                                                                                                              11. Select Microsoft in identity provider dropdown

                                                                                                                              12. For App registration type provide details of your choice

                                                                                                                              13. For Issuer URL accept the default value

                                                                                                                              14. For Client application requirement select Allow requests from specific client applications

                                                                                                                              15. For Allowed client applications add Client ID copied in previous step

                                                                                                                              16. Click OK to apply constraint

                                                                                                                              17. For Identity requirement select Allow requests from specific identities

                                                                                                                              18. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                              19. Click OK to apply constraint

                                                                                                                              20. Click Save

                                                                                                                              21. Navigate to Application of Microsoft identity provider

                                                                                                                                A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                              22. Expand Manage menu item

                                                                                                                              23. Select Expose an API

                                                                                                                              24. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                              25. Record Application ID URI of identity provider

                                                                                                                                ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                              26. Navigate to Policy Agent function app.

                                                                                                                              27. Expand Settings menu item.

                                                                                                                              28. Select Environment Variables menu item.

                                                                                                                              29. Click Add button.

                                                                                                                              30. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                              31. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                Review Microsoft identity platform default scope

                                                                                                                              32. Hit Apply in Add/Edit application setting blade.

                                                                                                                              33. Hit Apply in App Settings tab.

                                                                                                                              Agent Function Key Vault Access Policies

                                                                                                                              Agent Function requires access to Key Vault created in Key Vault to encrypt policy and to access configuration secrets.

                                                                                                                              1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                              2. Select Access policies.
                                                                                                                              3. Click Create.
                                                                                                                              4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Wrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                              5. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Agent Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Agent via ARM template
                                                                                                                              6. Proceed Next to Application and Next again to Review + Create.
                                                                                                                              7. Review permissions and Create.

                                                                                                                              Agent Function Outbound IP address

                                                                                                                              Agent Function App IP addresses may be useful for configuring ESA policy store and allowing traffic between Agent and ESA.

                                                                                                                              To obtain the list of Outbound IP addresses:

                                                                                                                              1. From Azure console navigate to Function App, select the Agent Function App.
                                                                                                                              2. Select Settings > Networking.
                                                                                                                              3. Under Outbound traffic configuration, select Show More next to Outbound addresses

                                                                                                                              Configure Function

                                                                                                                              Agent Function must be configured with parameters recorded in steps above.

                                                                                                                              To configure Function:

                                                                                                                              1. Open Function App service from the Azure console. Select the Function App created for policy agent in previous steps.

                                                                                                                              2. Navigate to Settings > Environment variables .

                                                                                                                              3. On the App Settings pane, click on Show values to reveal all configuration values

                                                                                                                              4. To modify multiple parameters, click the pencil icon Advanced edit at the top. Alternatively you may click on the environment variable name to edit single values.

                                                                                                                              5. Modify parameters according to the table below. If configuration has a default value you don’t have to change it

                                                                                                                              Parameter

                                                                                                                              Notes

                                                                                                                              AZURE_KEY_VAULT_NAME

                                                                                                                              Key Vault

                                                                                                                              AZURE_POLICY_BLOB_URL

                                                                                                                              URL of the Azure Blob file which is used to store Protegrity security policies for protector consumption. See ProtectFuncPolicyBlobUrl in Protect Function Policy Blob

                                                                                                                              AZURE_RETAIN_POLICY_BLOB

                                                                                                                              The amount of policy backups to retain. Default: 10. Allowed values: -1, >1. Value of -1 will disable cleanup of backup policies.

                                                                                                                              PROTEGRITY_PROTECT_FUNCTION

                                                                                                                              Protegrity function to be updated when new policy is deployed. Provide a comma separated list of protect function app names for updating multiple protectors:

                                                                                                                              Protegrity-Protect-func1,Protegrity-Protect-func2
                                                                                                                              

                                                                                                                              PTY_ESA_IP

                                                                                                                              ESA Server

                                                                                                                              AZURE_ESA_CREDENTIALS_SECRET_ID

                                                                                                                              ESA Credentials In Azure Key Vault

                                                                                                                              AZURE_ENCRYPTION_KEY_ID

                                                                                                                              Create Policy Encryption Key

                                                                                                                              PEP_CONFIG_CASE_SENSITIVE

                                                                                                                              Default: No Allowed values: yes/no

                                                                                                                              Specifies whether policy usernames should be case sensitive

                                                                                                                              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

                                                                                                                              PEP_CONFIG_EMPTY_STRING

                                                                                                                              Default: empty Allowed values: null empty

                                                                                                                              Determines outcome of empty value operation. For example, (un)protect(’’) -> null (un)protect(’’) ->

                                                                                                                              DISABLE_DEPLOY

                                                                                                                              Default: 0

                                                                                                                              POLICY_PULL_TIMEOUT

                                                                                                                              Default: 20s

                                                                                                                              ESA_CONNECTION_TIMEOUT

                                                                                                                              Default: 5s

                                                                                                                              LOG_LEVEL

                                                                                                                              Default: INFO. Allowed values: DEBUG, INFO, WARNING, ERROR

                                                                                                                              AZURE_SUBSCRIPTION_ID

                                                                                                                              Default: Same as ARM Resource group

                                                                                                                              AZURE_RESOURCE_GROUP_NAME

                                                                                                                              Default: Same as ARM Resource group

                                                                                                                              POLICY_DOWNLOAD_CRON_EXPRESSION

                                                                                                                              Describes how often Agent Function will run Default: 0 0 * * * * (Every hour)

                                                                                                                              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.

                                                                                                                              PTY_ESA_CREDENTIALS_FUNCTION

                                                                                                                              Instead of supplying AZURE_ESA_CREDENTIALS_SECRET_ID environment variable, ESA credentials can be provided by a custom Azure Function App. Provide a value recorded for EsaCredentialsFnUrl

                                                                                                                              PTY_ESA_CREDENTIALS_FUNCTION_KEY

                                                                                                                              When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key. Provide a value recorded for EsaCredentialsFnKey

                                                                                                                              PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET

                                                                                                                              When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key stored in Azure Key Vault. Provide a value recorded for EsaCredentialsFnKeySecretName

                                                                                                                              PTY_ESA_CREDENTIALS_FUNCTION_SCOPE

                                                                                                                              When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using its own identity. Provide a value here recorded for EsaCredentialsFnAppIdUri appended with /.default to create authentication scope. Review Microsoft identity platform default scope

                                                                                                                              PTY_SYNC_DATASTORE

                                                                                                                              Name of the target datastore

                                                                                                                              PTY_DATASTORE_KEY

                                                                                                                              The export key is the public part of an asymmetric key pair created in a Create Policy Encryption 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.

                                                                                                                              1. Click Apply at the bottom of the screen and then Confirm to save the changes.

                                                                                                                              Parameter

                                                                                                                              Notes

                                                                                                                              AZURE_CLIENT_ID

                                                                                                                              Sets the Managed Identity Client ID for Function App runtime. System-Assigned Identity is used when variable is not set.

                                                                                                                              APPLICATIONINSIGHTS_AUTHENTICATION_STRING

                                                                                                                              Define identity for Application Insights access. Managed Identity Client ID is provided to this setting with Function App Managed Identity ARM template parameter. See the corresponding Azure AD Authentication documentation: Azure AD authentication

                                                                                                                              APPLICATIONINSIGHTS_CONNECTION_STRING

                                                                                                                              Connection String for Application Insights instance. See the corresponding Azure Connection String documentation: Connection strings

                                                                                                                              FUNCTIONS_EXTENSION_VERSION

                                                                                                                              Azure Functions extension version

                                                                                                                              FUNCTIONS_WORKER_RUNTIME

                                                                                                                              Runtime of the function

                                                                                                                              WEBSITE_RUN_FROM_PACKAGE

                                                                                                                              URL to the zip file in blob storage with function runtime source

                                                                                                                              WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID

                                                                                                                              Managed Identity used to load function runtime source

                                                                                                                              AzureWebJobsStorage__blobServiceUri

                                                                                                                              URL of the storage account which hosts the blob identified in WEBSITE_RUN_FROM_PACKAGE

                                                                                                                              Test Agent Function Installation

                                                                                                                              After configuration is complete you can test the function.

                                                                                                                              To test Agent function installation:

                                                                                                                              1. Navigate to Overview.

                                                                                                                              2. Select the function agent from the Functions tab.

                                                                                                                              3. Click Code + Test > Test/Run and then Run to execute the function.

                                                                                                                              4. You should see a 202 Accepted response.

                                                                                                                              5. Expand Logs output at the bottom of the page. Click Maximize to enlarge log output.

                                                                                                                              6. Below is an example log output from successful agent run.

                                                                                                                                
                                                                                                                                INFO:AZURE_SUBSCRIPTION_ID: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
                                                                                                                                INFO:AZURE_KEY_VAULT_NAME: [vault-name]
                                                                                                                                INFO:AZURE_ENCRYPTION_KEY_ID: [https://vault-name.vault.azure.net/keys/key-name/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
                                                                                                                                INFO:AZURE_RESOURCE_GROUP_NAME: [resource-group-name]
                                                                                                                                INFO:AZURE_POLICY_BLOB_URL: [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip]
                                                                                                                                INFO:AZURE_RETAIN_POLICY_BLOB: [3]
                                                                                                                                INFO:PROTEGRITY_PROTECT_FUNCTION: [Protegrity-Protect-xxxx]
                                                                                                                                INFO:DISABLE_DEPLOY: [0]
                                                                                                                                INFO:PTY_ESA_IP: [xxx.xxx.xxx.xxx]
                                                                                                                                INFO:PTY_SYNC_DATASTORE: []
                                                                                                                                INFO:POLICY_PULL_TIMEOUT: [40]
                                                                                                                                INFO:LOG_LEVEL: [info]
                                                                                                                                INFO:PTY_CORE_EMPTYSTRING: [empty]
                                                                                                                                INFO:PTY_CORE_CASESENSITIVE: [no]
                                                                                                                                INFO:PTY_ADDIPADDRESSHEADER: [yes]
                                                                                                                                INFO:Starting policy agent [4.0.3] ...
                                                                                                                                INFO:ESA_CONNECTION_TIMEOUT: [60]
                                                                                                                                INFO:Using ESA CA certificate from PTY_ESA_CA_SERVER_CERT environment variable.
                                                                                                                                INFO:ResilientPackageClient initialized.
                                                                                                                                INFO:Retrieving ESA rps version
                                                                                                                                INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[]
                                                                                                                                INFO:RPS Version: 1.9.2, Build: 1.9.2+1.g4bfba.1.9
                                                                                                                                INFO:Checking ESA rps export availability
                                                                                                                                INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[QA_DATA_STORE]
                                                                                                                                INFO:Export available, Last-Modified: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                INFO:Getting current policy metadata [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip] ...
                                                                                                                                INFO:Last modified: [Thu, 01 Jan 2026 00:00:00 GMT], Last deployed: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                WARNING:Current policy deployment has no checksum_mapping metadata:
                                                                                                                                INFO:No changes in the policy since last download. Skipping policy deployment.
                                                                                                                                INFO:Checking container for the last deployed policy [https://resource-group-name.blob.core.windows.net/policy]...
                                                                                                                                INFO:[Protegrity-Protect-xxxx] current policy blob url: [https://resource-group-name.blob.core.windows.net/policy/2026-02-01_18-00-00/protegrity-policy-name.zip]
                                                                                                                                INFO:Policy blob in sync for function [Protegrity-Protect-xxxx]
                                                                                                                                INFO:[0] blobs are outside of the retention period [3]
                                                                                                                                
                                                                                                                              7. If the log output in this window pauses or is difficult to read, you may navigate back to the Agent Function App overview and select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to view logs.

                                                                                                                              Troubleshooting

                                                                                                                              To review the most recent invocation traces, navigate to the function app instance. Select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to retrieve the full history of executions with detailed traces.

                                                                                                                              2.1.3.5 - Audit Log Forwarder Installation

                                                                                                                              Install the audit log forwarder.

                                                                                                                                The following sections provide installation steps for the Log Forwarder component in Azure. The Log Forwarder deployment allows for the audit logs generated by Protect Service to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protect Service to work properly. See Audit Log Forwarder Architecture for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity for further guidance on configuration alternatives in the cloud.

                                                                                                                                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 (Audit Store) or 24284 (td-agent).

                                                                                                                                2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                                                                                3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                                                                                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 Log Forwarder variable in section Install Log Forwarder via ARM template

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

                                                                                                                                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:

                                                                                                                                • client.key
                                                                                                                                • client.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"
                                                                                                                                

                                                                                                                                There are two options to configure Log Forwarder for certificate authentication:

                                                                                                                                • While installing using ARM template
                                                                                                                                  1. Provide single-line client certificate for Esa Client Cert
                                                                                                                                  2. Provide Azure Key Vault secret name for Esa Client Cert Key Secret Name which stores single-line certificate key file.
                                                                                                                                • When re-configuring after installation using environment variables
                                                                                                                                  1. Provide single-line client certificate for ESA_CLIENT_CERT
                                                                                                                                  2. Provide Azure Key Vault secret name for ESA_CLIENT_CERT_KEY_SECRET_NAME which stores single-line certificate key file.

                                                                                                                                Create Key Vault Secrets

                                                                                                                                Log Forwarder uses Key Vault as a secure store for certificate key file.

                                                                                                                                Create secret in Key Vault for certificate key file:

                                                                                                                                1. Navigate to Key Vault.

                                                                                                                                2. Under Objects, select Secrets > Generate/import.

                                                                                                                                3. Select Manual, type in secret name and specify single-line certificate key file value for Secret value.

                                                                                                                                4. Select Create.

                                                                                                                                5. Record secret name:

                                                                                                                                  ESA Client Cert Key Secret Name (EsaClientCertKeySecretName): ___________________

                                                                                                                                Function User-Assigned Managed Identity

                                                                                                                                User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                2. Select Create

                                                                                                                                3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                5. For Region provide recorded value of ApiRegion

                                                                                                                                6. For Name provide a name of the new identity

                                                                                                                                7. Assign following roles to this identity:

                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                8. Record Forward function user-assigned identity

                                                                                                                                  Forward Function User-Assigned Identity (ForwardFuncUserAssignedIdentity): ____________________

                                                                                                                                Install Log Forwarder via ARM template

                                                                                                                                Resources created with ARM template include Function App, App Service Plan and Application Insights service. Optionally, a new Event Hub namespace and Event Hub instance can be created.

                                                                                                                                To install Log Forwarder via ARM template:

                                                                                                                                1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                2. Select Build your own template in editor.

                                                                                                                                3. Select Load File and upload pty_forward_arm_v2.json. Click Save.

                                                                                                                                4. Select Resource Group.

                                                                                                                                5. Specify Name for the resources (All resources will be prefixed with Protegrity-Forward).

                                                                                                                                6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Forward Function Blob Url.

                                                                                                                                8. For Forward Function Blob Url use the value from Upload Files.

                                                                                                                                9. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                                10. For Function Sku Count Minimum number of workers to keep active.

                                                                                                                                11. For WorkSpace Sku Azure Monitor log analytics pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                12. For Log Retention In Days The workSpace data retention in days. Allowed values are per pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                13. For Forward Logs to ESA select whether to collect audit logs from a new or an existing Event Hub. A new Event Hub namespace and new Event Hub instance will be created for ‘From new Event Hub’ option.

                                                                                                                                14. For Audit Log Output select whether to send logs directly to Audit Store or td-agent on ESA

                                                                                                                                15. For Event Hub Namespace enter Event Hub namespace name. Depending on previous option, a new namespace with this name will be created or an existing namespace with this name will be used.

                                                                                                                                16. For New Event Hub Namespace Sku Name select Event Hub namespace SKU name. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                17. For New Event Hub Namespace Sku Tier select Event Hub namespace SKU Tier used for new Event Hub namespace. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                18. For New Event Hub Namespace Sku Capacity enter a value of Event Hub throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                19. For Event Hub Name enter Event Hub instance name. A new Event Hub instance with this name will be created or an existing Event Hub instance with this name will be used.

                                                                                                                                20. For Event Hub Name DLQ enter Event Hub name for the dead-letter queue, where messages will be delivered to in case connection to ESA is lost. A new Event Hub instance with this name will be created or an existing Event Hub with this name will be used.

                                                                                                                                21. For New Event Hub Partition Count enter number of partitions to create in a new Event Hub. Allowed values are from 1 to 32 partitions. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                22. For New Event Hub Audit Log Retention In Days enter number of days audit logs will be available in Event Hub. Applies to both primary Event Hub and dead-letter queue Event Hub. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                23. For Log Destination Esa Ip enter ESA IP address.

                                                                                                                                24. For Esa Client Cert enter single-line ESA client certificate. See section Certificate Authentication for details.

                                                                                                                                25. For Esa Client Cert Key Secret Name enter secret name which stores ESA client certificate single-line private key. See section Certificate Authentication for details.

                                                                                                                                26. For Key Vault Uri enter URI of the Key Vault that stores ESA username/password secrets.

                                                                                                                                27. For Esa Tls Disable Cert Verify Set to ‘0’ to enable ESA certificate validation. Set to ‘1’ to disable ESA certificate verification. Disable only for initial setup and development purposes, do not disable in production environments.

                                                                                                                                28. If ESA is configured with self-signed certificate, set Pty Esa Ca Server Cert. Use the ESA CA Server Certificate escaped content recorded in Certificates on ESA.

                                                                                                                                  Note that for development and troubleshooting purposes, ESA certificate validation can be disabled by either redeploying this function with this ARM template where Esa Tls Disable Cert Verify option is set to ‘1’ or by directly setting PTY_ESA_DISABLE_TLS_CERT_VERIFY environment variable to ‘1’.

                                                                                                                                29. For Esa Connect Timeout set time in seconds to wait for the ESA connection response. Minimum value: 1. Default: 5.

                                                                                                                                30. For Esa Virtual Host provide ESA virtual hostname. This configuration is optional. It can be used when proxy server is present and supports TLS SNI extension.

                                                                                                                                31. For Min Log Level select minimum log level. Accepted values: off, severe, warning, info, config, all

                                                                                                                                32. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                After deployment is complete:

                                                                                                                                1. Go to Outputs and record:

                                                                                                                                  Forward Function Name (ForwardFuncName):__________________

                                                                                                                                2. Record:

                                                                                                                                  Event Hub Name (EventHubName):__________________

                                                                                                                                  Event Hub Namespace (EventHubNamespace):__________________

                                                                                                                                Function System-Assigned Managed Identity

                                                                                                                                System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                If you have not created a user-assigned managed identity at Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                1. Navigate to the function

                                                                                                                                2. Select Settings, Identity.

                                                                                                                                3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                4. Click on Azure role assignments button.

                                                                                                                                5. Assign following roles to this identity:

                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                6. From Azure console, navigate to Function App and select audit log forwarder function deployed in previous section.

                                                                                                                                7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                Update Function Key Vault Access Policies

                                                                                                                                The Key vault must be updated to allow the Function App to decrypt the policy files. The Forwarder is using policy to confirm the authenticity of audit logs it receives from Event Hub and to digitally sign the aggregated logs that it sends to ESA. Update the Key vault access policies with function identity. To update the key vault access policies:

                                                                                                                                1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                2. Select Access policies.
                                                                                                                                3. Click Create.
                                                                                                                                4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                5. Proceed Next to Principal.
                                                                                                                                6. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Log Forwarder via ARM template
                                                                                                                                7. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                8. Review permissions and Create.

                                                                                                                                Test Log Forwarder Installation

                                                                                                                                Follow the steps to validate Log Forwarder installation. Successful Log Forwarder installation will aggregate logs, connect to ESA and send audit log events.

                                                                                                                                Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                                                                                Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                                                                                1. In the following command, replace ‘forwarder-function-name’ with your function name

                                                                                                                                2. In the following command, replace ‘forwarder-function-key’ with your function key

                                                                                                                                3. Run the command in PowerShell:

                                                                                                                                  
                                                                                                                                  $forwarderFunctionName='forwarder-function-name'
                                                                                                                                  $forwarderFunctionKey='forwarder-function-key'
                                                                                                                                  
                                                                                                                                  Invoke-WebRequest -UseBasicParsing -Uri "https://$forwarderFunctionName.azurewebsites.net/admin/functions/auditlogforwarder" `
                                                                                                                                  -Method POST `
                                                                                                                                  -Headers @{
                                                                                                                                    "x-functions-key" = $forwarderFunctionKey
                                                                                                                                  } `
                                                                                                                                  -ContentType "application/json" `
                                                                                                                                  -Body "{`"input`":`"{\`"additional_info\`":{\`"description\`":\`"Data unprotect operation was successful.\`",\`"request_id\`":\`"f0ffbbf8-ab5b-42b7-90f4-51db7443af77\`"},\`"cnt\`": 1,\`"correlationid\`": \`"clfwrqgme0021nj329mijk52w\`",\`"logtype\`": \`"Protection\`",\`"level\`": \`"SUCCESS\`",\`"origin\`": {  \`"hostname\`": \`"169.254.197.189\`",  \`"ip\`": \`"169.254.197.189\`", \`"time_utc\`": 1722941687},\`"protection\`": {\`"dataelement\`": \`"alpha\`", \`"operation\`": \`"Unprotect\`",\`"audit_code\`": 8,\`"policy_user\`": \`"test_user\`",\`"datastore\`": \`"SAMPLE_POLICY\`"},\`"process\`": {  \`"name\`": \`"N/A\`",  \`"id\`": \`"15\`",\`"thread_id\`": \`"2243954624\`",\`"user\`": \`"sbx_user1051\`", \`"platform\`": \`"Linux_x32\`"},\`"client\`": {\`"username\`":\`"sbx_user1051\`",\`"ip\`":\`"169.254.197.189\`"},\`"protector\`": {\`"family\`": \`"IAP Lambda\`",\`"version\`": \`"3.1.0\`",\`"vendor\`": \`"Cloud Protect\`",\`"pcc_version\`": \`"3.5.0.1\`", \`"core_version\`": \`"2.0.1\`"},\`"signature\`": { \`"key_id\`":\`"5f143892-bbe4-4794-b1f4-ed28ca2a077e\`", \`"checksum\`": \`"90BC9BF39354869BD4BC5381820D201797DF4AF53B5A7F5F3AE01EC607C41A6E\`"}}`"}"
                                                                                                                                  

                                                                                                                                4. Run following query to see your function logs, allow for a few minutes for Azure to deliver the logs

                                                                                                                                  
                                                                                                                                  traces
                                                                                                                                  | project timestamp, message
                                                                                                                                  | where timestamp > ago(5m)
                                                                                                                                  
                                                                                                                                5. Test is successful if the logs contain the following entry:

                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                  

                                                                                                                                  If the log entry is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                                                                Update Protect Service With Event Hub details

                                                                                                                                In this section, Event Hub details will be provided to the Protect Service installation.

                                                                                                                                1. Navigate to the Protect function environment variables.

                                                                                                                                2. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                3. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                4. Apply and Confirm to apply the changes.

                                                                                                                                Update Policy Agent With Log Forwarder Function Target

                                                                                                                                Log Forwarder requires a Protegrity policy which is in sync with the Protector Service. This section will describe the steps to update the Policy Agent to include updating the Log Forwarder.

                                                                                                                                1. Navigate to the Policy Agent function created in Install Agent via ARM template

                                                                                                                                2. Select Settings > Environment variables > PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                3. Edit the value for environment variable PROTEGRITY_PROTECT_FUNCTION to include the Log Forwarder function’s name in the comma separated list of function names.

                                                                                                                                4. Select Apply > Apply > Confirm to save the changes

                                                                                                                                5. Test Policy Agent installation as described in Test Agent Function Installation

                                                                                                                                Test Full Log Forwarder Installation

                                                                                                                                1. Install and configure Protegrity Agent, Protect Service and Log Forwarder components.
                                                                                                                                2. Set EVENT_LEVEL environment variable on Protect Service function to Informational.
                                                                                                                                3. Set PTY_LOG_LEVEL environment variable on both Protect Service function and Log Forwarder function to config.

                                                                                                                                Test Installation

                                                                                                                                1. Make a protect operation using a data element or user which will result in audit log generation

                                                                                                                                2. Navigate to the Logs for the Protect Service function

                                                                                                                                3. Execute ’traces’ query

                                                                                                                                4. Expect to see a log similar to the below:

                                                                                                                                  
                                                                                                                                  Completed publishing events for Event Hub: audit-logs (Partition Id/Key: '0'), Operation Id: 'e17bacd6-91e6-4fb5-8281-2929788bef09'. Service Retry Count: 0; Duration: '0.02' seconds
                                                                                                                                  
                                                                                                                                5. Navigate to the Logs for the Log Forwarder function

                                                                                                                                6. Execute ’traces’ query

                                                                                                                                7. Expect to see a log similar to the below:

                                                                                                                                  
                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                  

                                                                                                                                Troubleshooting

                                                                                                                                Configure additional logging for functions:

                                                                                                                                1. Set EVENT_LEVEL environment variable on Protect function to Informational.
                                                                                                                                2. Set PTY_LOG_LEVEL environment variable on both Protect function and Log Forwarder function to config.

                                                                                                                                Error

                                                                                                                                Detail

                                                                                                                                
                                                                                                                                Unhandled exception. System.Exception: Failed to initialize 
                                                                                                                                function type,expecting environment variable 
                                                                                                                                'AzureWebJobs.AuditLogForwarder.Disabled' 
                                                                                                                                to be set to either 'true' or 'false'
                                                                                                                                
                                                                                                                                1. An environment variable ‘AzureWebJobs.AuditLogForwarder.Disabled’ is expected. This environment variable is added automatically when functions are deployed with ARM templates.
                                                                                                                                2. Verify this environment variable exists and is set to ’true’ for Protect Service functions and is set to ‘false’ for Log Forwarder functions.
                                                                                                                                
                                                                                                                                [2024/08/08 10:00:00] [error] [tls] error: unexpected EOF
                                                                                                                                

                                                                                                                                Log Forwarder failed to verify ESA certificate

                                                                                                                                1. If ESA is configured with self-signed certificate, verify that Log Forwarder ‘PTY_ESA_CA_SERVER_CERT’ is correctly set to ESA CA certificate string. Refer to Certificates on ESA for details.
                                                                                                                                2. If ESA is configured with publicly signed certificate, ensure Log Forwarder ‘PTY_LOG_LEVEL’ is set to ‘all’ level, restart and re-test the Log Forwarder. Review the logs to see if your root CA is used. If not used, you may supply your public CA in Log forwarder configuration ‘PTY_ESA_CA_SERVER_CERT’.
                                                                                                                                3. During initial non-production setup, SSL verification can be disabled by setting ‘PTY_ESA_DISABLE_TLS_CERT_VERIFY’ environment variable to ‘1’ or ’true’
                                                                                                                                
                                                                                                                                Failed to aggregate audit logs, 1 audit logs dropped, error: 
                                                                                                                                The user, group or application 'appid=;oid=;iss=' does not have 
                                                                                                                                secrets get permission on key vault ';location='...
                                                                                                                                Status: 403 (Forbidden)
                                                                                                                                ErrorCode: Forbidden
                                                                                                                                

                                                                                                                                Log Forwarder has no permissions to use Key Vault

                                                                                                                                1. Verify Log Forwarder has access to the Key Vault.
                                                                                                                                2. Consult section Update Function Key Vault Access Policies
                                                                                                                                
                                                                                                                                TCP connection timed out: 001.001.001.001:9200
                                                                                                                                

                                                                                                                                Log Forwarder failed to connect to ESA

                                                                                                                                1. Ensure ESA is available on given IP address and 9200 port
                                                                                                                                2. Consult section ESA Audit Store Configuration
                                                                                                                                
                                                                                                                                fail: Protect.Aggregate[0] Failed to aggregate audit logs, 
                                                                                                                                1 audit logs dropped, error: Invalid URI: The format of the URI 
                                                                                                                                could not be determined. 
                                                                                                                                info: iap[0] Shared memory segment POLICY does not exist: The 
                                                                                                                                system cannot find the file specified.
                                                                                                                                

                                                                                                                                Invalid Key Vault Uri format

                                                                                                                                1. Ensure that environment variable KEY_VAULT_URI has correctly formatted url.
                                                                                                                                2. Example 1: https://<keyvaultname>.vault.azure.net/
                                                                                                                                3. Example 2: https://<keyvaultname>.vault.usgovcloudapi.net/
                                                                                                                                
                                                                                                                                [Error] Azure-Messaging-EventHubs: An exception occurred while 
                                                                                                                                publishing a batch of events for buffered producer instance with 
                                                                                                                                identifier 'x' to Event Hub: audit-logs, Partition Id: '0', 
                                                                                                                                Operation Id: 'x'. Error Message: 'Unauthorized access.
                                                                                                                                

                                                                                                                                Protect Service function failed to send messages to Event Hub

                                                                                                                                1. Ensure Forwarder Function managed identity has ‘Azure Event Hubs Data Sender’ role assigned for the Event Hub resource.
                                                                                                                                2. See Function User-Assigned Managed Identity and Function System-Assigned Managed Identity

                                                                                                                                2.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
                                                                                                                                Azure Account (Azure Global or US Government Subscription)Recommend creating a new resource group for Protegrity.

                                                                                                                                2.1.3.7 -

                                                                                                                                Required Skills and Abilities

                                                                                                                                Role / Skillset

                                                                                                                                Description

                                                                                                                                Azure Account Administrator

                                                                                                                                Ability to run Azure Resource Manager (or perform steps manually), create/configure Entra ID Application Registrations

                                                                                                                                Protegrity Administrator

                                                                                                                                The ESA credentials required to extract the policy for the Policy Agent

                                                                                                                                Network Administrator

                                                                                                                                Needed to open firewall to access ESA and evaluate Azure network setup

                                                                                                                                2.1.3.8 -

                                                                                                                                2.1.4 - REST API

                                                                                                                                Reference for Cloud API authorization and specification

                                                                                                                                REST API

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

                                                                                                                                Base URL:

                                                                                                                                https://{ProtectFuncName}.azurewebsites.net/api

                                                                                                                                Substitute the Protect function name recorded during the Protect function installation.

                                                                                                                                2.1.4.1 - Export an OpenAPI Spec

                                                                                                                                Exporting OpenAPI Spec from Azure Function App

                                                                                                                                Export an OpenAPI Spec

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

                                                                                                                                https://{ProtectFuncName}.azurewebsites.net/api/v1/openapi
                                                                                                                                

                                                                                                                                Authentication and functions key are required to get the URL.

                                                                                                                                For testing the REST API, we recommend using a client tool, such as Postman.

                                                                                                                                2.1.4.2 - Payload Encoding

                                                                                                                                Describes the request/response payload encoding

                                                                                                                                Payload Encoding

                                                                                                                                The following encoding formats are supported in the REST API.

                                                                                                                                For every encoding, the resultant protected data is returned in the same encoding. For example, if request is hex-encoded, the response is also hex-encoded.

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

                                                                                                                                Encoding

                                                                                                                                Supported by data elements

                                                                                                                                Notes

                                                                                                                                utf8

                                                                                                                                All except binary data elements.

                                                                                                                                Default encoding if encoding is not specified.

                                                                                                                                hex

                                                                                                                                All

                                                                                                                                Default encoding for binary data elements.

                                                                                                                                base64

                                                                                                                                All

                                                                                                                                base64_mime

                                                                                                                                All

                                                                                                                                • Uses RFC 2045 Alphabet.
                                                                                                                                • Accepts input on multiple lines.
                                                                                                                                • Lines can be separated by any combination of CR and LF characters.
                                                                                                                                • Lines must not be longer than 76 characters long.
                                                                                                                                • Response lines are separated by CRLF characters.
                                                                                                                                • Optional padding.
                                                                                                                                • Does not accept any non-base64 characters.

                                                                                                                                base64_pem

                                                                                                                                All

                                                                                                                                • Uses RFC 1421 Alphabet.
                                                                                                                                • Accepts input on multiple lines.
                                                                                                                                • Lines can be separated by any combination of CR and LF characters.
                                                                                                                                • Lines must not be longer than 64 characters long.
                                                                                                                                • Response lines are separated by CRLF characters.
                                                                                                                                • Optional padding.
                                                                                                                                • Does not accept any non-base64 characters.

                                                                                                                                base64_url

                                                                                                                                All

                                                                                                                                The following sections provide the payload schema and its examples.

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

                                                                                                                                2.1.4.4 - 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=="}]}}}
                                                                                                                                

                                                                                                                                2.1.4.5 - SSL Certificates

                                                                                                                                Reference for SSL Certificate resources in Azure Function Apps

                                                                                                                                SSL Certificates

                                                                                                                                By default, the Azure function app function support HTTPS.

                                                                                                                                To setup SSL Certificates in the Protect Function App please go to the following Azure documentation link:

                                                                                                                                App Service, Configure SSL Certificate

                                                                                                                                2.1.5 - Performance

                                                                                                                                Performance benchmarks and considerations.

                                                                                                                                2.1.5.1 - Function App Performance

                                                                                                                                Guidance on Function App Performance Performance settings and considerations.

                                                                                                                                Function App Performance

                                                                                                                                Overview

                                                                                                                                Azure Function apps offer different hosting plans that directly impact the performance, scalability, and cost of Cloud Protect deployments. Understanding these plans and their characteristics is essential for optimizing your data protection operations.

                                                                                                                                Azure Function App Service Plans

                                                                                                                                Azure Functions provides several hosting options, each with different characteristics:

                                                                                                                                Consumption Plan

                                                                                                                                The Consumption plan provides automatic scaling and charges only for compute resources used during function execution. While cost-effective for sporadic workloads, this plan has limitations:

                                                                                                                                • Cold start latency: Functions may experience delays when starting after periods of inactivity
                                                                                                                                • Limited execution time: Maximum execution duration of 10 minutes per function invocation
                                                                                                                                • Shared infrastructure: Resources are shared across tenants, which can lead to variable performance
                                                                                                                                • Memory constraints: Limited to 1.5 GB of memory per instance

                                                                                                                                The Premium plan is the recommended option for Cloud Protect on Azure. It provides enhanced performance and enterprise-grade features:

                                                                                                                                • Pre-warmed instances: Always-ready instances eliminate cold start delays, ensuring consistent performance
                                                                                                                                • Enhanced compute resources: Flexible compute sizing, see App Service Premium version 3 plan
                                                                                                                                • VNET integration: Secure connectivity to on-premises resources and Azure private networks
                                                                                                                                • Unlimited execution duration: No time limits for long-running protection operations
                                                                                                                                • Predictable performance: Dedicated infrastructure ensures consistent throughput
                                                                                                                                • Better scaling control: Minimum and maximum instance count configuration

                                                                                                                                The Elastic Premium plan extends the Premium plan with additional elasticity and performance optimization:

                                                                                                                                • Rapid scale-out: Faster scaling response to demand spikes
                                                                                                                                • Greater instance limits: Support for larger-scale deployments
                                                                                                                                • Optimized cold start: Even faster initialization compared to standard Premium
                                                                                                                                • Event-driven scaling: More granular scaling based on event sources
                                                                                                                                • All Premium features: Includes VNET integration, pre-warmed instances, and unlimited execution time

                                                                                                                                Cloud Protect Recommendations

                                                                                                                                Cloud Protect on Azure recommends using either Premium or Elastic Premium plans for production deployments. These plans provide:

                                                                                                                                1. Consistent Performance: Pre-warmed instances ensure data protection operations execute immediately without cold start delays
                                                                                                                                2. Sufficient Resources: Memory and CPU resources adequate for cryptographic operations and high-volume data processing
                                                                                                                                3. Reliability: Dedicated infrastructure for predictable performance and SLA compliance
                                                                                                                                4. Security: VNET integration enables secure communication with ESA (Enterprise Security Administrator) and other protected resources
                                                                                                                                5. Scalability: Automatic scaling handles variable workloads while maintaining performance standards

                                                                                                                                Performance Considerations

                                                                                                                                When deploying Cloud Protect on Azure Functions, consider the following factors:

                                                                                                                                Instance Sizing

                                                                                                                                Select appropriate instance sizes based on your workload:

                                                                                                                                • EP1 (Elastic Premium 1): 1 vCPU, 3.5 GB RAM - suitable for moderate workloads
                                                                                                                                • EP2 (Elastic Premium 2): 2 vCPU, 7 GB RAM - recommended for standard production deployments
                                                                                                                                • EP3 (Elastic Premium 3): 4 vCPU, 14 GB RAM - for high-volume or resource-intensive operations

                                                                                                                                Scaling Configuration

                                                                                                                                Configure scaling parameters to match your protection requirements:

                                                                                                                                • Minimum instances: Set to at least 1-2 pre-warmed instances to eliminate cold starts
                                                                                                                                • Maximum instances: Configure based on peak load expectations and budget constraints
                                                                                                                                • Scale-out rules: Define appropriate triggers based on CPU, memory, or queue depth metrics

                                                                                                                                Network Considerations

                                                                                                                                • Use VNET integration to reduce latency when communicating with ESA servers
                                                                                                                                • Enable private endpoints for secure, high-performance connectivity to Azure services (Storage, Key Vault)
                                                                                                                                • Consider proximity placement to co-locate Function apps with dependent resources

                                                                                                                                Monitoring and Optimization

                                                                                                                                • Monitor execution duration metrics to identify bottlenecks
                                                                                                                                • Track instance count and scaling patterns to optimize configuration
                                                                                                                                • Review memory and CPU utilization to right-size your plan
                                                                                                                                • Set up Application Insights for detailed performance telemetry and diagnostics

                                                                                                                                Cost vs. Performance Trade-offs

                                                                                                                                While Premium and Elastic Premium plans have higher baseline costs compared to Consumption, they provide:

                                                                                                                                • Predictable performance and cost structure
                                                                                                                                • Reduced total cost for steady-state workloads (no per-execution charges)
                                                                                                                                • Better resource utilization through persistent instances
                                                                                                                                • Lower operational overhead from consistent behavior

                                                                                                                                For Cloud Protect deployments handling sensitive data with compliance requirements, the Premium/Elastic Premium investment ensures reliable, performant data protection operations.

                                                                                                                                2.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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Azure Event Hub instance where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated.

                                                                                                                                  These sections show 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 so that audit records are not lost.

                                                                                                                                  Protect Service Function Environment Variables

                                                                                                                                  • PTY_CORE_FLUSHINTERVAL: Defines for how long audit logs are aggregated before they are sent to Azure Event Hub. Default value is ten seconds. Audit logs are always aggregated into one minute buckets, therefore a value greater than sixty seconds will affect mostly the batching interval.

                                                                                                                                  • MAX_WAIT_TIME: Defines for how long aggregated audit logs are batched before they are sent to Azure Event Hub. Default value is ten seconds.

                                                                                                                                    Increasing MAX_WAIT_TIME may result in:

                                                                                                                                    1. Increased latency or lag of audit logs arriving to Event Hub and therefore ESA

                                                                                                                                    2. Increased throughput rates due to fewer network requests overall

                                                                                                                                    3. Increased aggregation rates for values up to one minute Lowering MAX_WAIT_TIME may result in:

                                                                                                                                    4. Reduced latency or lag for audit logs to arrive to Event Hub and therefore ESA

                                                                                                                                    5. Reduced throughput rates due to higher number of network requests overall

                                                                                                                                    6. Reduced aggregation rates for values up to one minute It is not recommended to set MAX_WAIT_TIME lower in production workloads as it may overload the Event Hubs service. Lowering MAX_WAIT_TIME may be beneficial for speeding up log delivery to ESA in dev/test environments.

                                                                                                                                  Log Forwarder ARM Template Parameters

                                                                                                                                  • New Event Hub Namespace Sku Name and New Event Hub Namespace Sku Tier directly affect the quotas applied to new Event Hub instances. Review Azure Event Hub Quotas related to selected tier in Azure documentation: Azure Event Hub Quotas
                                                                                                                                  • New Event Hub Namespace Sku Capacity: Event Hubs throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Capacity directly controls the purchased throughput of Event Hub instance. Review details in Azure documentation: Event Hub Instance Throughput
                                                                                                                                  • New Event Hub Partition Count: The number of partitions represents the level of parallel log streams in the Event Hub. It is proportional to throughput capacity of the Event Hub instance. If the number of partitions is too low and the volume of audit logs is too high, a throughput ceiling may be reached on Event Hub and some audit records sent from protect function may be lost. Review details in Azure documentation: Event Hub Scalability
                                                                                                                                  • New Event Hub Audit Log Retention In Days: Number of days audit logs are to be available in Event Hub. Applies to both primary Event Hub instance and dead-letter queue Event Hub instance. While audit logs are processed by Log Forwarder in near-realtime, it may be beneficial to keep audit logs available in Event Hub for extended period in case Log Forwarder or ESA require maintenance.
                                                                                                                                  • Event Hub Name DLQ: Dead-letter Queue Event Hub name. This Event Hub will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ Event Hub can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                                                                                  Monitoring Log Forwarder Performance

                                                                                                                                  • Azure Event Hub Metrics: Any positive value in ‘Throttled Requests’ metric indicates that audit logs rate from protect function is too high. The recommended actions may include:

                                                                                                                                    • Increase aggregation and batching intervals of Protect function by increasing values of PTY_CORE_FLUSHINTERVAL and MAX_WAIT_TIME
                                                                                                                                    • Increase number of partitions for Event Hub
                                                                                                                                    • Purchase additional capacity units for Event Hub
                                                                                                                                    • Use a higher Event Hub namespace tier
                                                                                                                                  • Azure Event Hub Metrics for DLQ Event Hub: Any positive value in ‘Incoming Messages’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Audit Log Forwarder Installation

                                                                                                                                  • Protect Function Logs: If protect function is unable to send logs to Event Hub, it will log the following message:

                                                                                                                                    Failed to forward {n} events to Event Hub
                                                                                                                                    
                                                                                                                                  • Count number of protect operations: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                    traces
                                                                                                                                    | where timestamp >= ago(20h)
                                                                                                                                    | where message has 'additional_info'
                                                                                                                                    | parse message with * "cnt\":" Count: long *  ",\"correlation" *
                                                                                                                                    | summarize count_sum = sum(Count)
                                                                                                                                    
                                                                                                                                  • View number of function instances on a graph: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                    requests
                                                                                                                                    | summarize InstanceCount = dcount(cloud_RoleInstance) by bin(timestamp, 1s)
                                                                                                                                    | where timestamp >= ago(2h)
                                                                                                                                    | order by timestamp desc
                                                                                                                                    | render timechart
                                                                                                                                    

                                                                                                                                  2.1.6 - Audit Logging

                                                                                                                                  Audit log description/formatting

                                                                                                                                    Audit Logging

                                                                                                                                    Audit records and application logs stream to Azure Storage Account. 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 Azure Application Insights. For more information about forwarding your audit records to ESA, contact Protegrity. Azure Application Insights contains only a sample of the audit records. The complete audit records are written to Azure Storage Account. For more information about Azure Application Insights,, refer to the Azure Application Insights 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

                                                                                                                                    Example Audit Records

                                                                                                                                    The following are sample audit messages:

                                                                                                                                    Protect Success:

                                                                                                                                    {
                                                                                                                                          "additional_info": {
                                                                                                                                            "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                            "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",
                                                                                                                                            "ip": "127.0.0.1",
                                                                                                                                            "time_utc": 1635363966
                                                                                                                                          },
                                                                                                                                          "protection": {
                                                                                                                                            "dataelement": "deAddress",
                                                                                                                                            "operation": "Protect",
                                                                                                                                            "audit_code": 6,
                                                                                                                                            "datastore": "SAMPLE_POLICY",
                                                                                                                                            "policy_user": "test_user"
                                                                                                                                          },
                                                                                                                                          process":{
                                                                                                                                            "name":"protect",
                                                                                                                                            "id":"13",
                                                                                                                                            "module":"coreprovider",
                                                                                                                                            "thread_id":"573580544",
                                                                                                                                            "user":"sbx_user1051",
                                                                                                                                            "platform":"\"Linux_x64\"",
                                                                                                                                            "version":"UNKNOWN"
                                                                                                                                          },
                                                                                                                                          "client": {
                                                                                                                                            "ip":"169.254.62.117"
                                                                                                                                          },
                                                                                                                                          "protector": {
                                                                                                                                            "family": "cp",
                                                                                                                                            "version": "4.0.0.102",
                                                                                                                                            "vendor": "aws.snowflake",
                                                                                                                                            "datastore":"SAMPLE_POLICY",
                                                                                                                                            "pcc_version": "4.0.0.9",
                                                                                                                                            "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                            "lambda_version":"4.0.1"
                                                                                                                                          },
                                                                                                                                          "signature": {
                                                                                                                                            "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                            "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                          }
                                                                                                                                        }
                                                                                                                                    

                                                                                                                                    User permission denied:

                                                                                                                                    {
                                                                                                                                          "additional_info": {
                                                                                                                                            "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                            "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",
                                                                                                                                            "ip": "127.0.0.1",
                                                                                                                                            "time_utc": 1635363966
                                                                                                                                          },
                                                                                                                                          "protection": {
                                                                                                                                            "dataelement": "deAddress",
                                                                                                                                            "operation": "Protect",
                                                                                                                                            "audit_code": 3,
                                                                                                                                            "datastore": "SAMPLE_POLICY",
                                                                                                                                            "policy_user": "test_user"
                                                                                                                                          },
                                                                                                                                          process":{
                                                                                                                                            "name":"protect",
                                                                                                                                            "id":"13",
                                                                                                                                            "module":"coreprovider",
                                                                                                                                            "thread_id":"573580544",
                                                                                                                                            "user":"sbx_user1051",
                                                                                                                                            "platform":"\"Linux_x64\"",
                                                                                                                                            "version":"UNKNOWN"
                                                                                                                                          },
                                                                                                                                          "client": {
                                                                                                                                            "ip":"169.254.62.117"
                                                                                                                                          },
                                                                                                                                          "protector": {
                                                                                                                                            "family": "cp",
                                                                                                                                            "version": "4.0.0.102",
                                                                                                                                            "vendor": "aws.snowflake",
                                                                                                                                            "datastore":"SAMPLE_POLICY",
                                                                                                                                            "pcc_version": "4.0.0.9",
                                                                                                                                            "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                            "lambda_version":"4.0.1"
                                                                                                                                          },
                                                                                                                                          "signature": {
                                                                                                                                            "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                            "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                          }
                                                                                                                                        }
                                                                                                                                    

                                                                                                                                    Data element not found:

                                                                                                                                    {
                                                                                                                                          "additional_info": {
                                                                                                                                            "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                            "description": "The data element could not be found in the policy.",
                                                                                                                                            "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",
                                                                                                                                            "ip": "127.0.0.1",
                                                                                                                                            "time_utc": 1635363966
                                                                                                                                          },
                                                                                                                                          "protection": {
                                                                                                                                            "dataelement": "deAddress",
                                                                                                                                            "operation": "Protect",
                                                                                                                                            "audit_code": 2,
                                                                                                                                            "datastore": "SAMPLE_POLICY",
                                                                                                                                            "policy_user": "test_user"
                                                                                                                                          },
                                                                                                                                          process":{
                                                                                                                                            "name":"protect",
                                                                                                                                            "id":"13",
                                                                                                                                            "module":"coreprovider",
                                                                                                                                            "thread_id":"573580544",
                                                                                                                                            "user":"sbx_user1051",
                                                                                                                                            "platform":"\"Linux_x64\"",
                                                                                                                                            "version":"UNKNOWN"
                                                                                                                                          },
                                                                                                                                          "client": {
                                                                                                                                            "ip":"169.254.62.117"
                                                                                                                                          },
                                                                                                                                          "protector": {
                                                                                                                                            "family": "cp",
                                                                                                                                            "version": "4.0.0.102",
                                                                                                                                            "vendor": "aws.snowflake",
                                                                                                                                            "datastore":"SAMPLE_POLICY",
                                                                                                                                            "pcc_version": "4.0.0.9",
                                                                                                                                            "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                            "lambda_version":"4.0.1"
                                                                                                                                          },
                                                                                                                                          "signature": {
                                                                                                                                            "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                            "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                          }
                                                                                                                                        }
                                                                                                                                    

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

                                                                                                                                    2.1.8 - Upgrading To The Latest Version

                                                                                                                                    Instructions for upgrading the protector.

                                                                                                                                      Upload Deployment Artifacts

                                                                                                                                      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.

                                                                                                                                      After downloading the deployment package from the Protegrity Portal, go to Azure console. Navigate to the storage account that was previously created to upload deployment artifacts (see: Agent Policy Blob Container).

                                                                                                                                      Upload the following artifacts to the Azure storage container:

                                                                                                                                      • protegrity-protect-<version>.zip
                                                                                                                                      • protegrity-agent-<version>.zip

                                                                                                                                      After upload is complete, note the blob url for each file. Blob URL may be found in the blob properties.

                                                                                                                                      Record Blob URL values below

                                                                                                                                      New Protect Function Blob URL: ___________________

                                                                                                                                      New Log Forwarder Function Blob URL: ___________________

                                                                                                                                      New Agent Function Blob URL: ___________________

                                                                                                                                      Perform the following steps to upgrade the Policy Agent, Protect, and Log Forwarder Functions separately.

                                                                                                                                      Disable Protegrity Agent Function Timer Trigger

                                                                                                                                      App Function Timer Trigger is used to periodically run Protegrity Agent Function to synchronize policy from ESA. The trigger must be disabled temporarily for the time of the upgrade process.

                                                                                                                                      Follow the steps below to disable the Agent Function Timer Trigger.

                                                                                                                                      1. From Azure Console, go to Function App service and select Protegrity Agent Function.

                                                                                                                                      2. Navigate to Overview.

                                                                                                                                      3. The functions list should contain agent function with Trigger type Timer and status Enabled.

                                                                                                                                      4. Click on the three dots in the same row as the agent function. Then select Disable.

                                                                                                                                      Upgrading Policy Agent Function

                                                                                                                                      Upgrade Policy Agent Runtime Package

                                                                                                                                      1. From Azure console, navigate to Function App service and select agent function app. Navigate to Settings > Environment variables.

                                                                                                                                      2. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                      3. Save existing URL. You may need it to rollback upgrade.

                                                                                                                                        WEBSITE_RUN_FROM_PACKAGE: _______________

                                                                                                                                      4. Replace URL with New Agent Function Blob URL.

                                                                                                                                      5. Click Apply then select Apply and Confirm to finalize.

                                                                                                                                      6. Using menu on the left, navigate to Overview. Stop the function using Stop button at the top. Then start it again.

                                                                                                                                      7. In the next section the Agent function will be tested to make sure it works as expected.

                                                                                                                                      8. (Optional) If you need to rollback to older version of Agent Function, replace WEBSITE_RUN_FROM_PACKAGE with URL recorded in previous steps.

                                                                                                                                      Disable Agent Policy Deployment and Test Policy Agent Function

                                                                                                                                      Policy agent generates a backup of pulled policy when triggered. The policy will then be deployed to Protect and Log Forwarder functions. Deployment of policies to functions should be disabled during the upgrade process.

                                                                                                                                      Follow the steps below to disable policy deployment:

                                                                                                                                      1. From Azure Console, navigate to Policy Agent Function App

                                                                                                                                      2. Navigate to Settings > Environment variables.

                                                                                                                                      3. set DISABLE_DEPLOY to 1 if it is not already set.

                                                                                                                                      4. Stop/Start the Agent function. It may take a few minutes for the function to start.

                                                                                                                                      Test/Run Policy Agent Function to Generate Latest Policy

                                                                                                                                      Follow the steps below to run the upgraded policy agent to refresh latest backup policy. Record the latest backup policy URL for later upgrade steps.

                                                                                                                                      1. From Azure Console, navigate to the Policy Agent Function App

                                                                                                                                      2. Navigate to the agent Test/Run feature as described in Test Agent Function Installation.

                                                                                                                                      3. Run the policy agent. Verify the agent executed successfully by carefully inspecting the logs.

                                                                                                                                      4. Use the following Azure Blob url from your Policy Agent Function Settings > Environment variables

                                                                                                                                        AZURE_POLICY_BLOB_URL
                                                                                                                                        

                                                                                                                                        upgraded_agent_policy_blob_url: _______________________

                                                                                                                                      Upgrading Protect Function

                                                                                                                                      Diagram below illustrates upgrade steps.

                                                                                                                                      Azure Protect Function Upgrade Steps

                                                                                                                                      Create Staging Deployment Slot (Protector)

                                                                                                                                      Creating new deployment slot allows updating the function without interruptions to the existing traffic.

                                                                                                                                      1. From Azure console, navigate to Function App service and select the Protect Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                      2. Click Add slot. Specify slot name.

                                                                                                                                      3. Click Add. Wait for the slot to be created.

                                                                                                                                      4. After the slot is added, select Close to close the dialog box.

                                                                                                                                      5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done and tested, you will swap staging slot with production slot.

                                                                                                                                      6. Click on the new deployment slot. This will open the newly created replica of Cloud Protect Function.

                                                                                                                                      7. Copy the function URL from the overview window.

                                                                                                                                        Staging Protect Function URL: ________________

                                                                                                                                      8. Navigate to Identity section under Settings.

                                                                                                                                      9. If your installation utilizes System Assigned Identity:

                                                                                                                                        1. Select System Assigned tab and switch Status On. Click Save.

                                                                                                                                        2. This will generate the Object ID for the newly deployed function in the deployment slot.

                                                                                                                                        3. Add Role Assignments to the identity as described in section Function System-Assigned Managed Identity

                                                                                                                                        4. Use the Object ID to update Key Vault policy to allow function in the deployment slot to use policy encryption key. See Protect Function Key Vault Access Policies for instructions how to update Key Vault policy.

                                                                                                                                      10. If your installation utilizes User Assigned Identity:

                                                                                                                                        1. Select User Assigned tab

                                                                                                                                        2. Select Add. Choose the identity in use on the production function, then complete by selecting Add again.

                                                                                                                                      11. Navigate to App Keys section from the menu on the left. Record default key value under Host Keys section.

                                                                                                                                        Staging Protect Function Default Host Key: ________________

                                                                                                                                      12. Navigate to the staging Function App Settings > Environment variables

                                                                                                                                      13. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                      14. Replace value with New Protect Function Blob URL.

                                                                                                                                      15. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template for the newly deployed log forwarder.

                                                                                                                                      16. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                      17. Click Apply, then Apply to finalize.

                                                                                                                                      Load Production Policy and Test New Protect Function In Staging

                                                                                                                                      1. Navigate to the new staging Protect function Settings > Environment variables

                                                                                                                                      2. Set AZURE_POLICY_BLOB_URL environment variable to the upgraded_agent_policy_blob_url value recorded in previous steps.

                                                                                                                                      3. Start/Stop the protect function.

                                                                                                                                      4. Test New Protect Function in staging. You can use curl command below, replacing Staging Protect Function URL and Staging Protect Function Default Host Key with values recorded in previous section.

                                                                                                                                      curl -X POST "<Staging Protect Function URL>/api/Protect" -k \
                                                                                                                                      -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 'x-functions-key: <Staging Protect Function Default Host Key>' \
                                                                                                                                      -H 'Content-Type: application/json' \
                                                                                                                                      -d '{
                                                                                                                                        "data": [
                                                                                                                                          ["0", "UtfVk UHgcD!"]
                                                                                                                                        ]
                                                                                                                                      }'
                                                                                                                                      
                                                                                                                                      curl -X POST "<Protect Function URL>/api/v1/protect" -k \
                                                                                                                                      -H 'x-functions-key: <Protect Function app key>' \
                                                                                                                                      -H 'Content-Type: application/json' \
                                                                                                                                      -d '{
                                                                                                                                        "data": ["test"],
                                                                                                                                        "user": "test",
                                                                                                                                        "data_element": "test"
                                                                                                                                      }'
                                                                                                                                      

                                                                                                                                      Finalize Protector upgrade

                                                                                                                                      Upgraded Protect Function can now be swapped in to production deployment slot to serve production traffic.

                                                                                                                                      1. Go to your main Protect Function.

                                                                                                                                      2. Select deployment slots.

                                                                                                                                      3. Select Swap.

                                                                                                                                      4. Select staging Protect Function slot as source and production Function as target.

                                                                                                                                      5. Click swap and wait until the functions are swapped.

                                                                                                                                      6. If you need to rollback swap the application slots again.

                                                                                                                                      Upgrading Log Forwarder Function

                                                                                                                                      Disable Log Forwarder Event Hub Trigger

                                                                                                                                      Disabling the Event Hub trigger will prevent audit log delivery during the upgrade process. This reduces the chance for any duplicate or lost audit logs. Later steps will indicate when this trigger may be re-enabled.

                                                                                                                                      Follow the steps below to disable the Event Hub trigger:

                                                                                                                                      1. From Azure Console, go to Function App service and select Protegrity Log Forwarder Function.

                                                                                                                                      2. Navigate to Overview.

                                                                                                                                      3. The functions list should contain AuditLogForwarder function with Trigger type Event Hub and Status Enabled.

                                                                                                                                      4. Click on the three dots in the same row as the AuditLogForwarder function. Then select Disable.

                                                                                                                                      Create Staging Deployment Slot (Log Forwarder)

                                                                                                                                      Creating new deployment slot allows updating the function such that it may easily be rolled back. Log Forwarder Function will be disabled during the upgrade process. Logs generated during this time will be processed once Log Forwarder is re-enabled

                                                                                                                                      1. From Azure console, navigate to Function App service and select the Log Forwarder Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                      2. Click Add slot. Specify slot name.

                                                                                                                                      3. Click Add. Wait for the slot to be created.

                                                                                                                                      4. After the slot is added, select Close to close the dialog box.

                                                                                                                                      5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done, you will swap staging slot with production slot.

                                                                                                                                      6. Click on the new deployment slot. This will open the newly created replica of Log Forwarder Function.

                                                                                                                                      7. Navigate to the staging Function App environment variable settings Settings > Environment variables

                                                                                                                                      8. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                      9. Replace value with New Log Forwarder Function Blob URL. Click Apply.

                                                                                                                                      10. Click on AZURE_POLICY_BLOB_URL configuration entry.

                                                                                                                                      11. Replace value with upgraded_agent_policy_blob_url. Click Apply.

                                                                                                                                      12. Click Apply and Confirm to push the configuration changes.

                                                                                                                                      Finalize Log Forwarder Upgrade

                                                                                                                                      Upgraded Log Forwarder Function will be swapped into production deployment slot to serve production traffic and re-enabled,

                                                                                                                                      Swap Upgraded Function Slot to Production

                                                                                                                                      1. Go to your main Log Forwarder Function.

                                                                                                                                      2. Select deployment slots.

                                                                                                                                      3. Select Swap.

                                                                                                                                      4. Select staging Log Forwarder Function slot as source and current Function as target.

                                                                                                                                      5. Click Start Swap and wait until the functions are swapped.

                                                                                                                                      6. If you need to rollback, swap the application slots again.

                                                                                                                                      Re-Enable Log Forwarder Function Trigger

                                                                                                                                      1. Go to your main Log Forwarder Function.

                                                                                                                                      2. Navigate to environment variable settings Settings > Environment variables

                                                                                                                                      3. Click on AzureWebJobs.AuditLogForwarder.Disabled configuration entry.

                                                                                                                                      4. Replace value with false. Click Apply then Apply and Confirm to finalize.

                                                                                                                                      Re-enable Policy Agent Deployment Setting

                                                                                                                                      Skip this step if changes were not made to the DISABLE_DEPLOY setting in previous upgrade steps

                                                                                                                                      1. Navigate to Agent function Settings > Environment variables

                                                                                                                                      2. Set DISABLE_DEPLOY to 0.

                                                                                                                                      3. apply changes and restart the Agent Function App

                                                                                                                                      Enable Protegrity Agent Function Timer Trigger

                                                                                                                                      If the Agent Function Timer Trigger was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to enable Policy Agent Timer Trigger.

                                                                                                                                      1. Navigate back to Protegrity Agent Function.

                                                                                                                                      2. Select Overview.

                                                                                                                                      3. Click on the three dots in the same row as the agent function in the list of functions. Then select Enable.

                                                                                                                                      2.1.9 - Known Limitations

                                                                                                                                      Known product limitations.
                                                                                                                                      • FPE is supported only for ASCII values.

                                                                                                                                      2.1.10 - Appendices

                                                                                                                                      Additional references for the protector.

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

                                                                                                                                        2.1.10.2 - Configuring Regular Expression to Extract Policy Username

                                                                                                                                        Example configurations for user extraction with regular expressions

                                                                                                                                        Configuring Regular Expression to Extract Policy Username

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

                                                                                                                                        • USERNAME_REGEX 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

                                                                                                                                        juliet.snow@domain.com

                                                                                                                                        juliet.snow@domain.com

                                                                                                                                        juliet.snow/ad_postfix

                                                                                                                                        juliet.snow/ad_postfix

                                                                                                                                        ^(.*)[@/].*$
                                                                                                                                        

                                                                                                                                        juliet.snow@domain.com

                                                                                                                                        juliet.snow

                                                                                                                                        juliet.snow/ad_postfix

                                                                                                                                        juliet.snow

                                                                                                                                        2.1.10.3 - Getting JWT for Service Account in Azure Active Directory

                                                                                                                                        How to get JWT using OAuth 2.0 client credentials grant flow in Azure Active Directory and authorize the Client ID in Protegrity Policy

                                                                                                                                        Getting JWT for Service Account in Azure Active Directory

                                                                                                                                        Protect Function App can use Microsoft identity platform endpoint for identity-as-a-service, available in Azure Active Directory, to implement OpenID Connect and OAuth 2.0 authorization. This section describes how to get JWT using OAuth 2.0 client credentials grant flow in Azure Active Directory and authorize the Client ID in Protegrity Policy.

                                                                                                                                        Suggested reading: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow

                                                                                                                                        High-level design:

                                                                                                                                        1. Active Directory Admin creates App registration for the service account.
                                                                                                                                        2. Active Directory Admin gives consent for the Service Account App ID.
                                                                                                                                        3. Daemon uses the Service Account App ID and the Service Account App ID Secret or Certificate, Protect Function App ID as the scope, and gets back the Access Token (JWT).
                                                                                                                                        4. Daemon sends the request to the Protect Function App, including the access token in the Authorization Bearer header.

                                                                                                                                        Configure the Protect Function App:

                                                                                                                                        1. From the Azure console, navigate to Function App service and select protect function app.

                                                                                                                                        2. Navigate to Settings > Environment variables and click OPENID_ENABLED. Make sure it is set to true.

                                                                                                                                        3. Click on OPENID_AUDIENCES, make sure it is set to the App ID recorded in EntraIDApplicationID.

                                                                                                                                        4. Click or Add the authorization environment variable. Make sure it is set to jwt.

                                                                                                                                        5. Click or Add on jwt_user_claim environment variable, make sure it is set to [“azp”, “appid”]. For more information on claims on AAD access token, refer:

                                                                                                                                          https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens

                                                                                                                                        To register a Service Account:

                                                                                                                                        1. In the Azure portal navigate to Azure Active Directory.

                                                                                                                                        2. Under Manage, select App registrations > New registration.

                                                                                                                                        3. Enter a Name and select Accounts in any organizational directory.

                                                                                                                                        4. Redirect URI is set to http://localhost.

                                                                                                                                        5. Select Register.

                                                                                                                                          After registration is complete record Application ID and Directory (tenant) ID displayed in the overview window:

                                                                                                                                          Service Account App ID: ___________________

                                                                                                                                          Directory (tenant) ID: ___________________

                                                                                                                                        6. In the Azure portal, in App registrations, select your application.

                                                                                                                                        7. Select Certificates & secrets > New client secret.

                                                                                                                                        8. Add a description for your client secret.

                                                                                                                                        9. Select a duration.

                                                                                                                                        10. Click Add.

                                                                                                                                        11. Record the secret’s value for use in your client application code. This secret value is never displayed again after you leave this page.

                                                                                                                                          Service Account App Secret: ___________________

                                                                                                                                        For more information on app registration, see Azure documentation Quickstart Registering App

                                                                                                                                        Admin Consent the Service Account:

                                                                                                                                        https://login.microsoftonline.com/{tenant}/adminconsent?
                                                                                                                                        client_id={Service Account App ID}
                                                                                                                                        &state=12345
                                                                                                                                        &redirect_uri=http://localhost
                                                                                                                                        

                                                                                                                                        Replace the tenant and the Service Account App ID with the values recorded in the previous step. At this point, Azure AD enforces that only a tenant administrator can sign into complete the request. The administrator will be asked to approve all the direct application permissions that were requested for the app in the app registration portal.

                                                                                                                                        Get the access token

                                                                                                                                        curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'client_id={Service Account App ID}&scope={EntraIDApplicationID }%2F.default&client_secret={Service Account App Secret}&grant_type=client_credentials' 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token'
                                                                                                                                        

                                                                                                                                        Replace Service Account App ID, EntraIDApplicationID, Service Account App Secret, and tenant with values recorded in previous steps.

                                                                                                                                        Example for successful response:

                                                                                                                                        {
                                                                                                                                          "token_type": "Bearer",
                                                                                                                                          "expires_in": 3599,
                                                                                                                                          "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBP..."
                                                                                                                                        }
                                                                                                                                        

                                                                                                                                        \

                                                                                                                                        Record the access_token from the response. access_token: ___________________

                                                                                                                                        Use the token

                                                                                                                                        curl -X POST "https://<Protect hostname>/api/v1/protect" -k \
                                                                                                                                        -H 'x-functions-key: <Protect Function app key>' \
                                                                                                                                        -H 'Authorization: Bearer <access_token>' \
                                                                                                                                        -H 'Content-Type: application/json' \
                                                                                                                                        -d '{
                                                                                                                                          "data": ["hello world!"],
                                                                                                                                          "data_element": "alpha"
                                                                                                                                        }'
                                                                                                                                        

                                                                                                                                        Replace the {Protect hostname}, {Protect Function app key} and {access_token} with the.

                                                                                                                                        Troubleshooting:

                                                                                                                                        • Service Account App ID redirect URL matches the redirect URL in the request for admin consent.
                                                                                                                                        • Active Directory administrator does admin consent.
                                                                                                                                        • JWT aud claim is the same as OPENID_AUDIENCES.
                                                                                                                                        • JWT iss claim is the same as OPENID_ISSUERS.
                                                                                                                                        • Protect Function configuration authorization=JWT
                                                                                                                                        • At least one of thejwt_user_claim exists in the JWT
                                                                                                                                        • The user claim in the token has permissions to make protect request.
                                                                                                                                        • The data element exists in the Protect Function App current policy.
                                                                                                                                        • JWT is not expired

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

                                                                                                                                        2.1.10.5 - ARM Template Installation - Required Permissions

                                                                                                                                        Outlines the required permissions to deploy Cloud Protect with provided ARM templates

                                                                                                                                        ARM Template Installation - Required Permissions

                                                                                                                                        Permissions below are required to install Protegrity service using ARM template.

                                                                                                                                        All permissions in the table must be granted with the Resource group scope.

                                                                                                                                        Permissions

                                                                                                                                        Description

                                                                                                                                        Built-In Azure Role

                                                                                                                                        Microsoft.Insights/components/read
                                                                                                                                        
                                                                                                                                        Microsoft.OperationalInsights/workspaces/read
                                                                                                                                        

                                                                                                                                        Read access to monitoring data and settings

                                                                                                                                        Monitoring Reader

                                                                                                                                        Microsoft.Insights/components/write
                                                                                                                                        
                                                                                                                                        Microsoft.OperationalInsights/workspaces/write
                                                                                                                                        

                                                                                                                                        Write and manage access to monitoring data and settings

                                                                                                                                        Monitoring Contributor

                                                                                                                                        Microsoft.Web/serverFarms/write
                                                                                                                                        
                                                                                                                                        Microsoft.Web/sites/write
                                                                                                                                        
                                                                                                                                        Microsoft.Web/sites/host/listkeys/action
                                                                                                                                        
                                                                                                                                        Microsoft.Web/serverFarms/join/action
                                                                                                                                        
                                                                                                                                        Microsoft.Web/register/action
                                                                                                                                        

                                                                                                                                        Write and manage access to web apps

                                                                                                                                        Website Contributor

                                                                                                                                        Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
                                                                                                                                        
                                                                                                                                        Microsoft.ManagedIdentity/userAssignedIdentities/read
                                                                                                                                        

                                                                                                                                        Manage and assign managed identities

                                                                                                                                        Managed Identity Operator

                                                                                                                                        Microsoft.Resources/deployments/validate/action
                                                                                                                                        
                                                                                                                                        Microsoft.Resources/deployments/write
                                                                                                                                        
                                                                                                                                        Microsoft.Resources/deployments/operationStatuses/read
                                                                                                                                        
                                                                                                                                        Microsoft.Resources/deployments/read
                                                                                                                                        

                                                                                                                                        Manage and validate deployments

                                                                                                                                        Deployment Contributor

                                                                                                                                                 

                                                                                                                                        Log Forwarder service ARM deployment requires additional permissions below:

                                                                                                                                        Permissions

                                                                                                                                        Description

                                                                                                                                        Built-In Azure Role

                                                                                                                                        Microsoft.EventHub/namespaces/write
                                                                                                                                        
                                                                                                                                        Microsoft.EventHub/namespaces/eventhubs/write
                                                                                                                                        
                                                                                                                                        Microsoft.EventHub/namespaces/networkrulesets/write
                                                                                                                                        

                                                                                                                                        Allow for the creation, update, and deletion of Event Hub namespaces, event hubs within those namespaces, and their network rule sets, enabling full management of Event Hub resources. Note: These permissions are only required when deploying new event Hub.

                                                                                                                                        Event Hubs Contributor

                                                                                                                                        Microsoft.EventHub/namespaces/read
                                                                                                                                        

                                                                                                                                        Read monitoring data and metrics, including Event Hub namespace data.

                                                                                                                                        Monitoring Reader

                                                                                                                                          

                                                                                                                                              

                                                                                                                                        The additional permissions listed below are required when API management is part of the deployment.

                                                                                                                                        Permissions

                                                                                                                                        Description

                                                                                                                                        Built-In Azure Role

                                                                                                                                        Microsoft.ApiManagement/service/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/apis/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/diagnostics/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/apis/operations/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/apis/operations/policies/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/backends/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/loggers/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/policies/write
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/apis/diagnostics/write
                                                                                                                                        

                                                                                                                                        Create or update API Management service instances, APIs, diagnostics, API operations, operation policies, backends, loggers, tenant policies, and API diagnostics.

                                                                                                                                        API Management Service Contributor

                                                                                                                                        Microsoft.ApiManagement/service/read
                                                                                                                                        
                                                                                                                                        Microsoft.ApiManagement/service/operationResults/read
                                                                                                                                        

                                                                                                                                        Read metadata for API Management service instances and get the status of long-running operations.

                                                                                                                                        API Management Service Reader

                                                                                                                                        2.1.10.6 - Associating ESA Data Store With Cloud Protect Agent

                                                                                                                                        Configure ESA data store for Policy Agent

                                                                                                                                        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
                                                                                                                                        falseyes20.75.43.207
                                                                                                                                        falseno20.75.43.207
                                                                                                                                        169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                                                                                                                                        trueno34.230.42.110
                                                                                                                                        falseyes34.230.42.110
                                                                                                                                        falseno34.230.42.110

                                                                                                                                        2.2 - Snowflake

                                                                                                                                        Protector for Snowflake on Azure.

                                                                                                                                        This section describes the high-level architecture of the product for integration with Snowflake, the installation procedures, and provides guidance on performance. This section focuses on Protegrity-specific aspects and should be consumed with the corresponding Snowflake 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.2.1 - Overview

                                                                                                                                        Solution overview and features.

                                                                                                                                          Solution Overview

                                                                                                                                          Snowflake Protector on Azure 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 Lambda 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 Azure 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.

                                                                                                                                          Features

                                                                                                                                          Snowflake Protector on Azure 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.2 - Architecture

                                                                                                                                          Deployment architecture and connectivity

                                                                                                                                            Deployment Architecture

                                                                                                                                            Protegrity Protector for Snowflake should be deployed in Customer’s Cloud account within the same Azure region as the Snowflake cluster. The product incorporates Protegrity’s vaultless tokenization engine within an Azure Function App. The encrypted data security policy from an ESA is deployed periodically as a static resources through an Azure blob storage. The policy is decrypted in memory at runtime within the Function App. This architecture allows Protegrity Serverless to be highly available and scale very quickly without direct dependency on any other Protegrity services.

                                                                                                                                            Protegrity’s Protector for Snowflake exposes a remote data protection service invoked from external User Defined Functions (UDF), a native feature of particular Cloud databases. UDFs can be invoked via direct SQL queries, database views, or features such as Snowflake table masking. The external UDF makes parallel API calls to Protegrity Serverless for 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. It 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 for reporting and alerting purposes via optional component called Log Forwarder explained in details in the next section of this guide.

                                                                                                                                            The security policy is synchronized via another serverless component called the Protegrity Policy Agent . The agent operates on a configurable schedule, fetches policy from ESA, performs additional envelope encryption using Azure Key Vault, and deploys the policy into the Azure blob storage container which is accessed by Protector Function App. This solution can be configured to automatically provision the static policy or the final step can be performed on-demand by an administrator.

                                                                                                                                            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 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 the Policy Management Section.

                                                                                                                                            Audit Log Forwarding Architecture

                                                                                                                                            Audit logs are by default sent to Azure Blob Storage and Application Insights. The Cloud Protect product can also be configured to send audit logs to ESA. Such configuration requires deploying audit Log Forwarder component which is available as part of Cloud Protect deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

                                                                                                                                            The audit log forwarding solution includes Azure Event Hubs data-streaming service and an Azure Function App deployment called Log Forwarder. Protect function delivers audit logs to Azure Event Hub instance, Event Hub instance batches audit logs and delivers them to Log Forwarder function. Log Forwarder function then delivers audit logs to ESA. Audit log aggregation occurs on both Protect and Log Forwarder functions. Aggregation rules are described in the Understanding the log aggregation section. If Log Forwarder cannot deliver audit logs to ESA due to temporary ESA connection loss, it will send undelivered audit logs to a dead-letter queue Event Hub. Audit logs in dead-letter queue Event Hub can be re-delivered to ESA using another instance of Log Forwarder, which can be configured to run either manually or on schedule.

                                                                                                                                            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 function which verifies individual logs signature. The signature verification is done upon arrival from Azure Event Hub 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 client certificate to authenticate calls to ESA.

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

                                                                                                                                            Snowflake Connectivity

                                                                                                                                            Snowflake’s API Integration Object

                                                                                                                                            The Snowflake API Integration Object provides a connection between your Snowflake Azure account and your Azure account where the Protegrity product is hosted. Creating this connection requires setting up the API Management and appropriate access policies. These steps are provided in the installation.

                                                                                                                                            2.2.3 - Installation

                                                                                                                                            Product Installation Guide.

                                                                                                                                            2.2.3.1 - Prerequisites

                                                                                                                                            Requirements before installing the protector.

                                                                                                                                              Azure Services

                                                                                                                                              The following table describes the Azure services that may be part of your Protegrity installation.

                                                                                                                                              All permissions in the table must be granted with the Resource group scope.

                                                                                                                                              Service

                                                                                                                                              Description

                                                                                                                                              Microsoft Entra ID Application

                                                                                                                                              Allows authentication with Azure Function app

                                                                                                                                              Azure Managed Identity

                                                                                                                                              Allows functions assume user-defined managed identity

                                                                                                                                              Function App

                                                                                                                                              Provides serverless compute for Protegrity protection operations and ESA integration to fetch policy updates or deliver audit logs.

                                                                                                                                              API Management Service

                                                                                                                                              Provides the end-point and access control

                                                                                                                                              Azure Key Vault

                                                                                                                                              Provides cryptographic keys for envelope encryption/decryption of the policy. Stores secrets required during deployment, e.g., ESA credentials

                                                                                                                                              Blob storage

                                                                                                                                              Intermediate storage location for the encrypted ESA policy package

                                                                                                                                              Application Insights

                                                                                                                                              Application and audit logs, performance monitoring, and alerts

                                                                                                                                              Azure Event Hubs

                                                                                                                                              Required if audit logs are to be sent to ESA. Set up and configuration of a new Event Hub is covered in section Audit Log Forwarder Installation.

                                                                                                                                              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
                                                                                                                                              Azure Account (Azure Global or US Government Subscription)Recommend creating a new resource group for Protegrity.

                                                                                                                                              Required Skills and Abilities

                                                                                                                                              Role / Skillset

                                                                                                                                              Description

                                                                                                                                              Azure Account Administrator

                                                                                                                                              Ability to run Azure Resource Manager (or perform steps manually), create/configure Entra ID Application Registrations

                                                                                                                                              Protegrity Administrator

                                                                                                                                              The ESA credentials required to extract the policy for the Policy Agent

                                                                                                                                              Network Administrator

                                                                                                                                              Needed to open firewall to access ESA and evaluate Azure network setup

                                                                                                                                              2.2.3.2 - Pre-Configuration

                                                                                                                                              Configuration steps prior product installation.

                                                                                                                                                Resource Group

                                                                                                                                                Identify or create a new Azure Resource Group where the Protegrity solution will be installed. It is recommended that a new Resource group is created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some of the subsequent installation steps.

                                                                                                                                                Azure Subscription ID (AzureSubscriptionID): ____________________

                                                                                                                                                Azure Resource Group ID (AzureResourceGroupID): ___________________

                                                                                                                                                Region

                                                                                                                                                Query the Azure region where Snowflake is running. This is the region where the product must be installed.

                                                                                                                                                To determine the region:

                                                                                                                                                1. Login to Snowflake

                                                                                                                                                2. In the SQL console, run the following query.

                                                                                                                                                  select current_region();
                                                                                                                                                  
                                                                                                                                                3. Record the Azure region (e.g. AZURE_EASTUS2).

                                                                                                                                                  Snowflake Azure Region (AzureRegion): ___________________

                                                                                                                                                Key Vault

                                                                                                                                                Key Vault is required to store secrets and encrypt policy deployment package. Identify existing Key Vault or create new.

                                                                                                                                                To create Key Vault:

                                                                                                                                                1. From the Azure Console select Create a resource.

                                                                                                                                                2. Navigate to Key Vault > Create.

                                                                                                                                                3. Select a Resource group.

                                                                                                                                                4. Enter a Key vault name.

                                                                                                                                                5. Select a Region. For the best performance, use the same region for all resources.

                                                                                                                                                6. Set the Pricing tier to Standard.

                                                                                                                                                7. Under Access configuration, select Vault access policy as the Permission model.

                                                                                                                                                8. Under Networking, ensure that Enable public access is selected.

                                                                                                                                                9. Under Review + create, click Create.

                                                                                                                                                10. Record Key Vault Name:

                                                                                                                                                  Key Vault Name (PolicyKeyValue): ___________________

                                                                                                                                                Function App Storage

                                                                                                                                                Create Storage Account

                                                                                                                                                Create a storage account to host Protegrity deployment packages provided in installation artifact bundle. Note that turning on the firewall or restricting access to selected virtual networks or IP address ranges will require additional configuration and is beyond the scope of this document.

                                                                                                                                                To create Function App storage:

                                                                                                                                                1. From the Azure Console select Create a resource.

                                                                                                                                                2. Navigate to Storage account > Create.

                                                                                                                                                3. Select the Resource group where the Protegrity solution will be deployed.

                                                                                                                                                4. Enter a Storage account name.

                                                                                                                                                5. Select the Region where the Protegrity solution will be deployed.

                                                                                                                                                6. Set the Preferred storage type to Azure Blob Storage or Azure Data Lake Storage

                                                                                                                                                7. Set the Primary workload to Cloud native

                                                                                                                                                8. Setting for Performance should be set to Standard.

                                                                                                                                                9. Setting for Redundancy should be set to Geo-redundant storage (GRS).

                                                                                                                                                10. Continue to Advanced setup and verify Enable hierarchical namespace is unchecked

                                                                                                                                                11. Adjust the Networking and Data protection configurations according to your security requirements or use the default values.

                                                                                                                                                12. Under Review + create, click Create.

                                                                                                                                                13. Record the storage account name

                                                                                                                                                  Storage Account Name (StorageAccountName): ____________________

                                                                                                                                                14. Record the storage blob service URL. Navigate to created Storage Account, select Settings, Endpoints, record the value of Blob Service

                                                                                                                                                  Storage Account Blob Service Url (StorageAccountBlobServiceUrl): ____________________

                                                                                                                                                Upload Files

                                                                                                                                                Create a deployment container using the Azure Blob Service.

                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                4. Upload the following installation artifacts to the container:

                                                                                                                                                • protegrity-protect-azure-<version>.zip
                                                                                                                                                • protegrity-agent-azure-<version>.zip
                                                                                                                                                1. Record Protect function blob URL:

                                                                                                                                                  Protect Function Blob URL (ProtectFuncURL): ____________________

                                                                                                                                                2. Record Forward function blob URL. Both Protect and Forward functions use the same protegrity-protect-azure-<version>.zip distribution:

                                                                                                                                                  Forward Function Blob URL (ForwardFuncURL): ____________________

                                                                                                                                                3. Record Agent function blob URL:

                                                                                                                                                  Agent Function Blob URL (AgentFuncURL): ____________________

                                                                                                                                                Create Protect Function Policy Blob

                                                                                                                                                Create a blob container for encrypted Protegrity security policy using Azure Blob Service. Agent will store encrypted policy in this container. Both Protect and Log Forwarder functions will load policy from this container.

                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                4. Right-click the container name, and select Container properties to obtain URL.

                                                                                                                                                  Append the name of the policy file to the container URL, e.g, https://<your-storage-account>.blob.core.windows.net/<your-policy-container>/<your-policy-file-name>.zip. Record the blob url.

                                                                                                                                                  Protect Function Policy Blob URL (ProtectFuncPolicyBlobUrl): ____________________

                                                                                                                                                Create Agent Policy Blob Container

                                                                                                                                                The Agent function uploads an encrypted policy zip package to a blob container which is used as a staging storage. Create the policy staging container

                                                                                                                                                To prepare the policy blob container:

                                                                                                                                                1. Under Storage account created in previous step, select Data storage > Containers and click + Container .

                                                                                                                                                2. Type in a container name and click Create .

                                                                                                                                                  Agent Policy Blob Container Name (AgentPolicyBlobContainer): ___________________

                                                                                                                                                2.2.3.3 - Protect Service Installation

                                                                                                                                                Product Installation Guide.

                                                                                                                                                  Preparation

                                                                                                                                                  1. Ensure that all the steps in Pre-Configuration are performed.

                                                                                                                                                  2. Login to the Azure account console where Protegrity will be installed.

                                                                                                                                                  3. Ensure the Azure Resource Manager templates provided by Protegrity are available on your local computer.

                                                                                                                                                  Register an Entra ID App

                                                                                                                                                  A Microsoft Entra ID App provides the mechanism for Client to authenticate with the Function App instance. Creating an Entra ID app requires appropriate permissions to the Azure Subscription and is typically performed by the Azure Account Administrator.

                                                                                                                                                  To register an Entra ID App:

                                                                                                                                                  1. In the Azure portal navigate to Microsoft Entra ID.

                                                                                                                                                  2. Click + Add and select App registration.

                                                                                                                                                  3. Enter a Name and select Accounts in any organizational directory.

                                                                                                                                                  4. Leave the Redirect URI empty and select Register.

                                                                                                                                                  5. After registration is complete record the application name and application id displayed in the overview window.

                                                                                                                                                    Entra ID Application Name (EntraIDApplicationName): ___________________

                                                                                                                                                    Entra ID Application ID (EntraIDApplicationID): ___________________

                                                                                                                                                  Protect Function User-Assigned Managed Identity

                                                                                                                                                  User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                  1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                  2. Select Create

                                                                                                                                                  3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                  4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                  5. For Region provide recorded value of ApiRegion

                                                                                                                                                  6. For Name provide a name of the new identity

                                                                                                                                                  7. Assign following roles to this identity:

                                                                                                                                                    • Storage Blob Data Owner
                                                                                                                                                    • Monitoring Metrics Publisher
                                                                                                                                                    • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                                                  8. Record Protect function user-assigned identity

                                                                                                                                                    Protect Function User-Assigned Identity (ProtectFuncUserAssignedIdentity): ____________________

                                                                                                                                                  Install Protect Function via Azure Resource Manager

                                                                                                                                                  Resources created with the ARM template include API Management service, Function App, App Service Plan and Application Insights service.

                                                                                                                                                  To install protect function via Azure Resource Manager:

                                                                                                                                                  1. From Azure Console, select Create a resource, search for template then select Template deployment (deploy using custom templates) > Create.

                                                                                                                                                  2. Select Build your own template in the editor.

                                                                                                                                                  3. Click Load File and upload pty_protect_arm_v2.json, then click Save.

                                                                                                                                                  4. Select a Resource group.

                                                                                                                                                  5. Enter a Name for the resources. All resources will be prefixed with Protegrity-Protect except for log container which will be prefixed with ptylogs. For more information on naming rules see: Azure resource name rules.

                                                                                                                                                  6. For Location input specify Azure region name or leave default to deploy in the same region as resource group.

                                                                                                                                                  7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Protect Function Blob Url.

                                                                                                                                                  8. For Protect Function Blob Url use the value from Upload Files.

                                                                                                                                                  9. For Function App Managed Identity Optionally use the value from Protect Function User-Assigned Managed Identity. If value is not given, a system-assigned managed identity will be enabled.

                                                                                                                                                  10. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                                                  11. For Create Api Management Service select Do not create. API Management Service is required only for integration with Snowflake. This service is not required otherwise.

                                                                                                                                                  12. For Api Management Service Sku Applicable only when API Management Service is created. Skip this if API Management Service is not created. Either Consumption (if available) or Premium are recommended. Note that this will affect the running cost.

                                                                                                                                                  13. For Username Regex you can optionally specify regex to extract policy username from the request. See Configuring Regular Expression to Extract Policy Username for more details.

                                                                                                                                                  14. For Entra ID Application ID enter the value recorded in Register an Entra ID App.

                                                                                                                                                  15. For Forward Logs To ESA select whether audit logs are to be sent to ESA or not. If you are not planning on sending audit logs to ESA you can skip Event Hub Nameand Event Hub Namespace properties below. For details on creating and configuring Event Hubs see Audit Log Forwarder Installation

                                                                                                                                                  16. For Event Hub Name provide the name of Event Hub which will be used to send audit logs to ESA.

                                                                                                                                                  17. For Event Hub Namespace provide the name of Event Hub Namespace which is hosting Event Hub selected in previous step.

                                                                                                                                                  18. Under Review + create, click Create. Wait for all resources to deploy. If the deployment fails for any resources of type Microsoft.Web/sites/host/functionKeys then click Redeploy and try deploying again.

                                                                                                                                                  19. After deployment is complete, go to Outputs and record protectFunctionName, azureTenantId and apiGatewayUrl.

                                                                                                                                                    Protect Function Name (ProtectFuncName): __________________

                                                                                                                                                    Azure Tenant ID (AzureTenantID): __________________

                                                                                                                                                    API Gateway URL (ApiGatewayURL): __________________

                                                                                                                                                  Function System-Assigned Managed Identity

                                                                                                                                                  System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                  If you have not created a user-assigned managed identity at Protect Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                  1. Navigate to the function

                                                                                                                                                  2. Select Settings, Identity.

                                                                                                                                                  3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                  4. Click on Azure role assignments button.

                                                                                                                                                  5. Assign following roles to this identity:

                                                                                                                                                    • Storage Blob Data Owner
                                                                                                                                                    • Monitoring Metrics Publisher
                                                                                                                                                    • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                                                  6. From Azure console, navigate to Function App and select protect function deployed in previous section.

                                                                                                                                                  7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                                  Update Key Vault Access Policies

                                                                                                                                                  The Key vault must be updated to allow the Function App to decrypt the policy files. Azure assigns a unique identifier to each Function App instance that can be used to grant permissions to that instance. Update the Key vault access policies with the Protect function. To update the key vault access policies:

                                                                                                                                                  Obtain Function App identifier

                                                                                                                                                  1. Navigate to the Function App service in the Azure portal.

                                                                                                                                                  2. Select the newly created Protect Function App instance.

                                                                                                                                                  3. Select the Identity option under Settings.

                                                                                                                                                  4. Ensure that setting System assigned is set to Status On.

                                                                                                                                                  5. Record the Object ID:

                                                                                                                                                    Protect Function Object ID: ___________________

                                                                                                                                                  Update the Key vault access policies with the Protect function’s Object ID

                                                                                                                                                  1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                  2. Select Access policies.
                                                                                                                                                  3. Click Create.
                                                                                                                                                  4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                  5. Proceed Next to Principal.
                                                                                                                                                  6. Enter the Protect Function Object ID recorded in this section into the search field.
                                                                                                                                                  7. Select the Function App instance.
                                                                                                                                                  8. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                  9. Review permissions and Create.

                                                                                                                                                  Upload the Sample Policy

                                                                                                                                                  The Protegrity installation bundle contains a sample policy which can be used to test the protect service installation without an ESA. Upload the sample policy artifact to the policy Blob storage container:

                                                                                                                                                  1. Go to Azure console and select Storage Account Name (StorageAccountName) recorded in step Create Storage Account.

                                                                                                                                                  2. Under Data storage select Blob Containers and select container created in Protect Function Policy Blob Container

                                                                                                                                                  3. Click Upload and select protegrity-sample-policy-<version>.zip file from your local computer.

                                                                                                                                                  4. Click Upload and wait for the file to complete uploading.

                                                                                                                                                  5. Record the sample policy blob url:

                                                                                                                                                    Sample Policy Blob Url (SamplePolicyBlobUrl): ___________________

                                                                                                                                                  Test the Protect Function Installation

                                                                                                                                                  Before continuing with next steps, you may verify the protect service is installed correctly. This step is optional and can be skipped.

                                                                                                                                                  1. From Azure console, navigate to Function App and select protect function app.

                                                                                                                                                  2. Select Overview and record URL value as <Protect Function URL>.

                                                                                                                                                  3. Navigate to Settings > Environment variables and click OPENID_ENABLED.

                                                                                                                                                  4. Change value to false and click Apply.

                                                                                                                                                  5. Select or create variable AZURE_POLICY_BLOB_URL.

                                                                                                                                                  6. Set value of AZURE_POLICY_BLOB_URL to value recorded for SamplePolicyBlobUrl and click Apply.

                                                                                                                                                  7. Select Apply and Confirm to finalize setting changes.

                                                                                                                                                  8. Go to Functions > App keys and record the value of default key under Host Keys (All function) as <Protect Function app key>.

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

                                                                                                                                                    curl -X POST "<Protect Function URL>/api/Protect" -k \
                                                                                                                                                    -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 'x-functions-key: <Protect Function app key>' \
                                                                                                                                                    -H 'Content-Type: application/json' \
                                                                                                                                                    -d '{
                                                                                                                                                      "data": [
                                                                                                                                                        ["0", "UtfVk UHgcD!"]
                                                                                                                                                      ]
                                                                                                                                                    }
                                                                                                                                                    '
                                                                                                                                                    

                                                                                                                                                    Note: When you copy-paste the curl command, make sure each header is in a separate line.

                                                                                                                                                  10. Replace <Protect Function URL> and <Protect Function app key> with the values recorded in step 2 And 5.

                                                                                                                                                  11. Run curl command. Verify the following output.

                                                                                                                                                    {"data":["hello world!"], "success": true, "encoding": "utf8"}
                                                                                                                                                    
                                                                                                                                                  12. Go back to Function app. Select Settings > Environment variables and click OPENID_ENABLED,

                                                                                                                                                  13. Change value to true and click Apply. Select Apply and Confirm to finalize.

                                                                                                                                                  Add Access Restrictions to Protect Function

                                                                                                                                                  This step is only applicable when API Management is using any tier except for consumption. The Function App instance can be configured to restrict access to IP addresses used by the API Management instance.

                                                                                                                                                  Obtain Function App identifier

                                                                                                                                                  1. Navigate to the API Management services service in the Azure portal.

                                                                                                                                                  2. Select the newly created API Management instance.

                                                                                                                                                  3. Copy the Virtual IP (VIP) addresses.

                                                                                                                                                    Virtual IP (VIP) addresses: ___________________

                                                                                                                                                  4. Navigate to the Function App service in the Azure portal.

                                                                                                                                                  5. Select the newly created Function App instance.

                                                                                                                                                  6. Under Settings > Networking.

                                                                                                                                                  7. Select Enabled with no access restrictions link under the section Inbound traffic configuration.

                                                                                                                                                  8. Click Add under Site access and rules section.

                                                                                                                                                  9. Change Name to API.

                                                                                                                                                  10. Ensure the Action is set to Allow.

                                                                                                                                                  11. Set Priority to 1.

                                                                                                                                                  12. Ensure the Type is IPv4.

                                                                                                                                                  13. Paste in the copied value and reformat as an IPv4 CIDR. For example “public: 169.254.169.254” becomes “169.254.169.254/32"

                                                                                                                                                  14. Click Add Rule.

                                                                                                                                                  15. If there are multiple IP addresses, repeat steps 8 through 14.

                                                                                                                                                  Troubleshooting

                                                                                                                                                  To review live requests, navigate to Application Insights service and select item with the same name as the protect function. Under Investigate, select Live Metrics. Wait for the dashboard to load, then go to Sample Telemetry pane on the right and look for the requests in question.

                                                                                                                                                  To review the full history of requests from Application Insights under Monitoring select Logs:

                                                                                                                                                  1. Select the Tables tab.
                                                                                                                                                  2. Hover over one of the table names under Application Insights header, for example exceptions.
                                                                                                                                                  3. Click on See preview data.
                                                                                                                                                  4. Click Use in editor.

                                                                                                                                                  You can also run the query directly in the query editor. For instance to select the 10 latest exceptions run the following query.

                                                                                                                                                  exceptions 
                                                                                                                                                  | where timestamp > ago(24h)
                                                                                                                                                  | order by timestamp
                                                                                                                                                  | limit 10
                                                                                                                                                  

                                                                                                                                                  Protect Function App Configuration

                                                                                                                                                  Protect Function app can be customized using environment variables. From Azure console, navigate to Function App service and select protect function app. Navigate to Settings > Environment variables. Add or Edit environment variables based on the following information.

                                                                                                                                                  ParameterDescriptionNotes
                                                                                                                                                  OPENID_ENABLEDWhen 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_AUDIENCESThe 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.applicable when OPENID_ENABLED= “true”.
                                                                                                                                                  OPENID_ISSUERSThe 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.applicable when OPENID_ENABLED= “true”.
                                                                                                                                                  OPENID_METADATA_URLA URL that points to an OpenID Connect identity provider configuration document, which is also known as OpenID well-known configuration endpoint.applicable when OPENID_ENABLED= “true”.
                                                                                                                                                  authorizationWhen equals “jwt”, Authorization Header JWT will be required in the Rest API Protect payload.
                                                                                                                                                  Supported Values: [“jwt”, “”]When equals to “jwt”, any request without Valid JWT in the Authorization header, will result in an error from API Gateway: 502 Bad Gateway.
                                                                                                                                                  allow_assume_userIf set to 0, The user from the payload will not be used, and the policy user is the JWT user.
                                                                                                                                                  Supported Values: [0, 1]applicable when authorization = “jwt”.
                                                                                                                                                  Default Value: 0
                                                                                                                                                  jwt_user_claimThe JWT payload claim with username. Common claims: name, preferred_username, cognito:usernameApplicable when authorization = “jwt”
                                                                                                                                                  Default Value: cognito:username
                                                                                                                                                  service_userIf 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.
                                                                                                                                                  AZURE_POLICY_BLOB_URLThis points to Protegrity security policy blob. It is updated by the Agent to point to latest security policy.
                                                                                                                                                  USERNAME_REGEXIf USERNAME_REGEX is set, the effective policy user will be extracted from the user in the request.
                                                                                                                                                  EVENTHUB_NAMEEvent Hub name where audit logs are to be sent to. Logs are not forwarded to ESA when this parameter is empty.
                                                                                                                                                  EventHub__fullyQualifiedNamespaceEvent Hub fully qualified namespace. Logs are not forwarded to ESA when this parameter is empty.
                                                                                                                                                  PTY_CORE_FLUSHINTERVALTime interval in seconds used to accumulate audit logs before sending to Event Hub. Default value: 10.Audit logs are always aggregated into one minute buckets. A value greater than 60 will influence only audit log batching while sending logs to Event Hub. A value less than 60 will influence both aggregation and audit log batching.
                                                                                                                                                  PTY_LOG_LEVELFunction min log level. Default: SevereOne of case-insensitive strings: off, severe, warning, info, config, all.
                                                                                                                                                  PTY_WRITE_LOG_ON_SINGLE_LINEWhether to write log level and message on one line or separate lines. Default: trueStarting from version 3.1.0, log level and message are printed on single line. Use this environment variable to switch to multi-line logging for backward compatibility with pre-3.1.0 release.
                                                                                                                                                  EVENT_LEVELLevel of logs produced by Azure services. Default: ErrorOne of case-insensitive strings: LogAlways, Critical, Error, Warning, Informational, Verbose. Set to at least ‘Informational’ during initial configuration, set to at most ‘Error’ in production environments.
                                                                                                                                                  ParameterNotes
                                                                                                                                                  AZURE_CLIENT_IDSets the Managed Identity Client ID for Function App runtime. System-Assigned Identity is used when variable is not set.
                                                                                                                                                  APPLICATIONINSIGHTS_AUTHENTICATION_STRINGDefine identity for Application Insights access. Managed Identity Client ID is provided to this setting with Function App Managed Identity ARM template parameter. See the corresponding Azure AD Authentication documentation: Azure AD authentication
                                                                                                                                                  APPLICATIONINSIGHTS_CONNECTION_STRINGConnection String for Application Insights instance. See the corresponding Azure Connection String documentation: Connection strings
                                                                                                                                                  FUNCTIONS_EXTENSION_VERSIONAzure Functions extension version
                                                                                                                                                  FUNCTIONS_WORKER_RUNTIMERuntime of the function
                                                                                                                                                  WEBSITE_RUN_FROM_PACKAGEURL to the zip file in blob storage with function runtime source
                                                                                                                                                  WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_IDManaged Identity used to load function runtime source
                                                                                                                                                  AzureWebJobsStorage__blobServiceUriURL of the storage account which hosts the blob identified in WEBSITE_RUN_FROM_PACKAGE
                                                                                                                                                  AZURE_TENANT_IDTenant identifier in Azure Active Directory
                                                                                                                                                  AzureWebJobs.AuditLogForwarder.DisabledDefines whether audit log forwarder function is disabled or not
                                                                                                                                                  AzureWebJobs.Protect.DisabledDefines whether Protect function is disabled or not
                                                                                                                                                  AzureWebJobs.v1-openapi.DisabledDefines whether v1-openapi function is disabled or not
                                                                                                                                                  AzureWebJobs.v1-protect.DisabledDefines whether v1-protect function is disabled or not
                                                                                                                                                  AzureWebJobs.v1-unprotect.DisabledDefines whether v1-unprotect function is disabled or not

                                                                                                                                                  2.2.3.4 - Snowflake Configuration

                                                                                                                                                  Configure Snowflake.

                                                                                                                                                    The following sections will configure Snowflake to access the API Gateway.

                                                                                                                                                    Login to Snowflake as ACCOUNTADMIN

                                                                                                                                                    Ensure that the current user can assume the Account Administrator role. This role must be created.

                                                                                                                                                    Create the Snowflake API Integration Object

                                                                                                                                                    Create Snowflake integration object to allow invoking Protegrity Function App from Snowflake.

                                                                                                                                                    1. From the Snowflake console worksheet, select the role ACCOUNTADMIN.

                                                                                                                                                    2. Paste the DDL test below.

                                                                                                                                                    3. Replace <Azure Tenant ID> and <API Gateway URL> with Azure Tenant ID and API Gateway URL from Install Protect Function via Azure Resource Manager.

                                                                                                                                                    4. Replace <Entra ID Application ID> with Entra ID Application ID from Register an Entra ID App.

                                                                                                                                                    5. Run DDL

                                                                                                                                                      create or replace api integration protegrity_api
                                                                                                                                                        api_provider = azure_api_management
                                                                                                                                                        azure_tenant_id = '<Azure Tenant ID>'
                                                                                                                                                        azure_ad_application_id = '<Entra ID Application ID>'
                                                                                                                                                        enabled = true
                                                                                                                                                        api_allowed_prefixes = ('<API Gateway URL>');
                                                                                                                                                      

                                                                                                                                                    Snowflake will create an application that must be linked to Azure Active Directory giving it permission to access the API Management and Function App instances. Information about this integration should be retrieved from the Snowflake instance.

                                                                                                                                                    To link Snowflake to AD:

                                                                                                                                                    1. Run the following query in the console.

                                                                                                                                                      DESCRIBE API INTEGRATION protegrity_api;
                                                                                                                                                      
                                                                                                                                                    2. Record the following output values from the resulting query:

                                                                                                                                                      • Azure Multi-Tenant App Name: ___________________
                                                                                                                                                      • Azure Consent URL: ___________________
                                                                                                                                                    3. An Azure Account Administrator is required for the remaining steps to grant the Snowflake application access to the Azure Active Directory.

                                                                                                                                                    4. Open the Azure Consent URL in a web browser.

                                                                                                                                                    5. If redirected to the Snowflake website, then skip to step 9.

                                                                                                                                                    6. If prompted to login then enter the credentials of an Azure user or administrator.

                                                                                                                                                    7. Click Accept to grant Snowflake access to the Azure account.

                                                                                                                                                    8. Additional instructions may be shown if the current user is not authorized to add the Snowflake application.

                                                                                                                                                    9. Navigate to the Enterprise applications service within the Azure portal.

                                                                                                                                                    10. Select the application that matches the Azure Multi-Tenant App Name.

                                                                                                                                                    11. Record the Application ID below.

                                                                                                                                                      Azure Multi-Tenant App ID: ___________________

                                                                                                                                                    Update API policies

                                                                                                                                                    To update API policies:

                                                                                                                                                    1. Navigate to API Management services in the Azure portal.

                                                                                                                                                    2. Select the instance created previously.

                                                                                                                                                    3. Select the APIs option under APIs.

                                                                                                                                                    4. Select All APIs.

                                                                                                                                                    5. Click the </> icon next to Policies under Inbound processing.

                                                                                                                                                    6. Add the <required-claims> using the example below replacing <Azure Tenant ID>, <Entra ID Application ID>, and <Azure Multi-Tenant App ID> with values recorded in earlier steps.

                                                                                                                                                      <policies>
                                                                                                                                                          <inbound>
                                                                                                                                                              <validate-jwt header-name="Authorization" failed-validation-httpcode="401">
                                                                                                                                                                  <openid-config url="https://login.microsoftonline.com/<Azure Tenant ID>/.well-known/openid-configuration" />
                                                                                                                                                                  <required-claims>
                                                                                                                                                                      <claim name="aud" match="all">
                                                                                                                                                                          <value><Entra ID Application ID></value>
                                                                                                                                                                      </claim>
                                                                                                                                                                      <claim name="appid" match="all">
                                                                                                                                                                          <value><Azure Multi-Tenant App ID></value>
                                                                                                                                                                      </claim>
                                                                                                                                                                  </required-claims>
                                                                                                                                                              </validate-jwt>
                                                                                                                                                          </inbound>
                                                                                                                                                          <backend>
                                                                                                                                                              <forward-request timeout="30" fail-on-error-status-code="true" />
                                                                                                                                                          </backend>
                                                                                                                                                          <outbound></outbound>
                                                                                                                                                          <on-error>
                                                                                                                                                          </on-error>
                                                                                                                                                      </policies>
                                                                                                                                                      
                                                                                                                                                    7. Click Save.

                                                                                                                                                    Update API Management Backend Function Key

                                                                                                                                                    API management allows specifying function key in the request to function app backend.

                                                                                                                                                    To update API function key:

                                                                                                                                                    1. From Azure console, navigate to Function App and select protect function app.

                                                                                                                                                    2. Go to Functions > App keys and record the value of default key under Host Keys (All functions) as <Protect Function app key>.

                                                                                                                                                    3. From the API management view, select the Backends option under APIs.

                                                                                                                                                    4. Select backend1.

                                                                                                                                                    5. Select the Authorization credentials option under Settings.

                                                                                                                                                    6. Under Headers locate the x-functions-key header.

                                                                                                                                                    7. For x-functions-key Value use the <Protect Function app key> recorded in step above.

                                                                                                                                                    8. Click Save.

                                                                                                                                                    Update Function App Configuration

                                                                                                                                                    The Function App configuration can be updated to verify that the request is coming from Snowflake.

                                                                                                                                                    To update Function App configuration:

                                                                                                                                                    1. Navigate to the Function App service in the Azure Portal and select the Protegrity-Protect-<name> item (there may be more than one).

                                                                                                                                                    2. Navigate to Settings > Environment variables.

                                                                                                                                                    3. Click Add.

                                                                                                                                                    4. Enter OPENID_APPID in the Name field.

                                                                                                                                                    5. Enter the value for Azure Multi-Tenant App ID in the Value field.

                                                                                                                                                    6. Click Apply then Apply and Confirm to finalize.

                                                                                                                                                    7. Repeat the above steps if there are multiple Function Apps.

                                                                                                                                                    Test Connectivity

                                                                                                                                                    Verify connectivity from Snowflake to Protect Function app.

                                                                                                                                                    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 URL>/api/Protect';
                                                                                                                                                      
                                                                                                                                                    3. Replace the placeholder value indicated substituting your API Gateway URL captured in Install Protect Function via Azure Resource Manager

                                                                                                                                                    4. Run the following protect in the console:

                                                                                                                                                      select pty_unprotect_sample_policy('UtfVk UHgcD!');
                                                                                                                                                      

                                                                                                                                                    Troubleshooting

                                                                                                                                                    To review live requests, navigate to Application Insights service and select item with the same name as the protect function. Under Investigate, select Live Metrics. Wait for the dashboard to load, then go to Sample Telemetry pane on the right and look for the requests in question.

                                                                                                                                                    To review the full history of requests from Application Insights under Monitoring select Logs:

                                                                                                                                                    1. Select the Tables tab.
                                                                                                                                                    2. Hover over one of the table names under Application Insights header, for example exceptions.
                                                                                                                                                    3. Click on See preview data.
                                                                                                                                                    4. Click Use in editor.

                                                                                                                                                    You can also run the query directly in the query editor. For instance to select the 10 latest exceptions run the following query.

                                                                                                                                                    exceptions 
                                                                                                                                                    | where timestamp > ago(24h)
                                                                                                                                                    | order by timestamp
                                                                                                                                                    | limit 10
                                                                                                                                                    

                                                                                                                                                    For more helpful platform-specific symptoms, refer to the Snowflake documentation: Platform Specific Symptoms

                                                                                                                                                    2.2.3.5 - Policy Agent Installation

                                                                                                                                                    Install the policy agent.

                                                                                                                                                      Policy Agent Function installation is done via Azure Resource Manager template 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 Function App on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted. You can find the list of Agent Function Outbound IP addresses after you deploy the function in Agent Function Outbound IP address

                                                                                                                                                      Note down ESA IP to be accessed form Agent Function:

                                                                                                                                                      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 policy agent Cloud Function Environment variables configuration.

                                                                                                                                                      In case ESA is configured with publicly signed certificates, this section can be skipped since the agent 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 variable in the Policy Agent Function Configuration section Configure Function

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

                                                                                                                                                      Create Policy Encryption Key

                                                                                                                                                      Create a policy encryption key.

                                                                                                                                                      To create policy encryption key:

                                                                                                                                                      1. From Azure console, navigate to Key Vaults and select Key Vault created in Key Vault.

                                                                                                                                                      2. Under Objects, select Keys.

                                                                                                                                                      3. Click Generate/Import.

                                                                                                                                                      4. Specify the following:

                                                                                                                                                        a. Key name for the Name field.

                                                                                                                                                        b. RSA for Key type.

                                                                                                                                                        c. 2048 for RSA key size.

                                                                                                                                                        d. Set Enabled toggle to Yes.

                                                                                                                                                      5. Select Create.

                                                                                                                                                      6. Click on the key name after creation is complete, then click on the key identifier row under CURRENT VERSION.

                                                                                                                                                      7. Copy the full URL value of Key Identifier. Record it for later use:

                                                                                                                                                        Policy Encryption Key ID (PolicyEncryptionKey): _________________

                                                                                                                                                      Agent Function User-Assigned Managed Identity

                                                                                                                                                      User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                      1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                      2. Select Create

                                                                                                                                                      3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                      4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                      5. For Region provide recorded value of ApiRegion

                                                                                                                                                      6. For Name provide a name of the new identity

                                                                                                                                                      7. Assign following roles to this identity:

                                                                                                                                                        • Storage Blob Data Owner with scope Storage account
                                                                                                                                                        • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                                        • Website Contributor with scope Resource Group
                                                                                                                                                      8. Record Agent function user-assigned identity

                                                                                                                                                        Agent Function User-Assigned Identity (AgentFuncUserAssignedIdentity): ____________________

                                                                                                                                                      Install Agent via ARM template

                                                                                                                                                      Resources created with ARM template include Function App, Premium V3 App Service Plan (optional) and Application Insights service. Run Azure Resource Manager deployment.

                                                                                                                                                      To install Agent via ARM template:

                                                                                                                                                      1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                                      2. Select Build your own template in editor.

                                                                                                                                                      3. Select Load File and upload pty_agent_arm_v2.json. Click Save.

                                                                                                                                                      4. Select Resource Group.

                                                                                                                                                      5. Specify Name for the resources (All resources will be prefixed with Protegrity-Agent).

                                                                                                                                                      6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                                      7. For Agent Function Blob Url use the value from Upload Files

                                                                                                                                                      8. For Function App Managed Identity Optionally use the value from Agent Function User-Assigned Managed Identity. If value is not given, a system-assigned managed identity will be enabled.

                                                                                                                                                      9. If you set Use Existing App Service Plan to True, you must specify existing Linux App Service Plan name in the next parameter.

                                                                                                                                                      10. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Agent Function Blob Url.

                                                                                                                                                      11. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                                      12. After deployment is complete, go to Outputs and record agentFunctionName:

                                                                                                                                                        Agent Function Name: __________________

                                                                                                                                                      Function System-Assigned Managed Identity

                                                                                                                                                      System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                      If you have not created a user-assigned managed identity at Agent Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                      1. Navigate to the function

                                                                                                                                                      2. Select Settings, Identity.

                                                                                                                                                      3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                      4. Click on Azure role assignments button.

                                                                                                                                                      5. Assign following roles to this identity:

                                                                                                                                                        • Storage Blob Data Owner with scope Storage account
                                                                                                                                                        • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                                        • Website Contributor with scope Resource Group

                                                                                                                                                      Creating ESA Credentials

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

                                                                                                                                                      ESA Credentials In Azure Key Vault

                                                                                                                                                      Policy Agent Function uses Key Vault as secure store for sensitive information like ESA username and password.

                                                                                                                                                      Create ESA credentials secrets:

                                                                                                                                                      1. Navigate to Key Vault.

                                                                                                                                                      2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                      3. Select Manual, then type in valid json as shown in the example for Secret value.

                                                                                                                                                        {"username": "<policy_export_user>", "password": "<password>"}
                                                                                                                                                        
                                                                                                                                                      4. Select Create.

                                                                                                                                                      5. Navigate to the secret details in Key Vault by selecting the newly created secret.

                                                                                                                                                      6. Inspect the current secret version properties by selecting the current version.

                                                                                                                                                      7. Copy the Secret Identifier value. For example https://<myvault>.vault.azure.net/secrets/<mysecret>/abcdefgxyz8edef595adaehij0d99123.

                                                                                                                                                      8. Record the Secret Identifier for later use.

                                                                                                                                                      ESA Credentials From Custom Azure Function App

                                                                                                                                                      Policy Agent Function requests ESA username and password from a custom Azure Function App, further referred to as ESA Credentials function. This method may be used to get the username and password from external vaults.

                                                                                                                                                      There are four options for configuring Policy Agent authorization with ESA Credentials function: Option 1, Option 2, Option 3 and Option 4. Only one option is expected to be configured at a time.

                                                                                                                                                      Create ESA credentials function:

                                                                                                                                                      1. Create Azure HTTP triggered ESA Credentials function using any supported runtime.

                                                                                                                                                        a. There is no input needed.

                                                                                                                                                        b. The function must accept an HTTP POST request.

                                                                                                                                                        c. The function must return the following response schema

                                                                                                                                                        ```
                                                                                                                                                        response: 
                                                                                                                                                        type: json object
                                                                                                                                                          properties: 
                                                                                                                                                            username: string 
                                                                                                                                                            password: string  
                                                                                                                                                        ```
                                                                                                                                                        
                                                                                                                                                        For example,
                                                                                                                                                        
                                                                                                                                                        ```
                                                                                                                                                        {"username": "admin", "password": "Password1234"} 
                                                                                                                                                        ```
                                                                                                                                                        
                                                                                                                                                      2. Configure Policy Agent to use ESA Credentials function app.

                                                                                                                                                        a. Navigate to HTTP triggered function to open ‘Code + Test’ page.

                                                                                                                                                        b. Under ‘Code + Test’ tab on ‘Code + Test’ page select ‘Resource JSON’.

                                                                                                                                                        c. In ‘Resource JSON’ blade record the value of ‘invoke_url_template’ property.

                                                                                                                                                        **'invoke_url_template'** property is located towards the bottom of resource json.
                                                                                                                                                        
                                                                                                                                                        URL must be in the form of 'https://[function-app-name].azurewebsites.[net|us]/api/[http-trigger-name]'.
                                                                                                                                                        
                                                                                                                                                        **ESA Credentials function URL (EsaCredentialsFnUrl):__________**
                                                                                                                                                        

                                                                                                                                                        d. Navigate to Policy Agent function app.

                                                                                                                                                        e. Expand Settings menu item.

                                                                                                                                                        f. Select Environment Variables menu item.

                                                                                                                                                        g. Click Add button.

                                                                                                                                                        h. For Name use PTY_ESA_CREDENTIALS_FUNCTION.

                                                                                                                                                        i. For Value use ESA Credentials function URL (EsaCredentialsFnUrl) recorded in previous steps.

                                                                                                                                                        j. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                        k. Hit Apply in App Settings tab.

                                                                                                                                                      3. Configure Authorization Option 1: Function Key Option 2: Key Vault Option 3: System-assigned Identity Option 4: User-assigned Identity

                                                                                                                                                      Authorization Option 1: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from environment variables.
                                                                                                                                                      1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                        Review Azure documentation on how to accomplish this.

                                                                                                                                                      2. Navigate to ESA Credentials function app.

                                                                                                                                                      3. Expand Functions menu item.

                                                                                                                                                      4. Select App Keys.

                                                                                                                                                      5. Record default key value.

                                                                                                                                                        ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                      6. Navigate to Policy Agent function app.

                                                                                                                                                      7. Expand Settings menu item.

                                                                                                                                                      8. Select Environment Variables menu item.

                                                                                                                                                      9. Click Add button.

                                                                                                                                                      10. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY.

                                                                                                                                                      11. For Value use ESA Credentials function key (EsaCredentialsFnKey) recorded in previous steps.

                                                                                                                                                      12. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                      13. Hit Apply in App Settings tab.

                                                                                                                                                      Authorization Option 2: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from Azure Key Vault.
                                                                                                                                                      1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                        Review Azure documentation on how to accomplish this.

                                                                                                                                                      2. Navigate to ESA Credentials function app.

                                                                                                                                                      3. Expand Functions menu item.

                                                                                                                                                      4. Select App Keys.

                                                                                                                                                      5. Record default key value.

                                                                                                                                                        ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                      6. Navigate to Key Vault.

                                                                                                                                                      7. Under Objects, select Secrets > Generate/import.

                                                                                                                                                      8. Select Manual, type in secret name and use ESA Credentials function key value recorded in previous steps (EsaCredentialsFnKey) for Secret value.

                                                                                                                                                      9. Select Create.

                                                                                                                                                      10. Record Key Vault secret name.

                                                                                                                                                        ESA Credentials function key secret name (EsaCredentialsFnKeySecretName):_______________

                                                                                                                                                      11. Navigate to Policy Agent function app.

                                                                                                                                                      12. Expand Settings menu item.

                                                                                                                                                      13. Select Environment Variables menu item.

                                                                                                                                                      14. Click Add button.

                                                                                                                                                      15. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET.

                                                                                                                                                      16. For Value use ESA Credentials function key secret name (EsaCredentialsFnKeySecretName) recorded in previous steps.

                                                                                                                                                      17. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                      18. Hit Apply in App Settings tab.

                                                                                                                                                      Authorization Option 3: Configure ESA Credentials authentication provider to authorize Policy Agent system-assigned identity.
                                                                                                                                                      1. Navigate to Policy Agent function app

                                                                                                                                                      2. Expand Settings menu item

                                                                                                                                                      3. Select Identity

                                                                                                                                                      4. Select System assigned tab

                                                                                                                                                      5. Status should already be On

                                                                                                                                                        Other Status indicates Policy Agent was installed without system-assigned identity. Before proceeding any further you need to either install Policy Agent with system-assigned identity or follow Option 4 which describes configuration steps for Policy Agent installed with user-assigned managed identity.

                                                                                                                                                      6. Copy Object (principal) ID

                                                                                                                                                      7. Navigate to ESA Credentials function app

                                                                                                                                                      8. Expand Settings menu item

                                                                                                                                                      9. Select Authentication

                                                                                                                                                      10. Select Add identity provider

                                                                                                                                                        Review related Microsoft documentation

                                                                                                                                                      11. Select Microsoft in identity provider dropdown

                                                                                                                                                      12. For App registration type provide details of your choice

                                                                                                                                                      13. For Issuer URL accept the default value

                                                                                                                                                      14. For Client application requirement select Allow requests from any application

                                                                                                                                                        Access will be limited to only the Policy Agent identity in the next step

                                                                                                                                                      15. For Identity requirement select Allow requests from specific identities

                                                                                                                                                      16. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                      17. For Restrict access select Require authentication

                                                                                                                                                      18. For Unauthenticated requests select HTTP 401 Unauthorized: recommended for APIs

                                                                                                                                                      19. Check Token store

                                                                                                                                                      20. Select Add

                                                                                                                                                      21. Click OK to apply constraint

                                                                                                                                                      22. Click Save

                                                                                                                                                      23. Navigate to Application of Microsoft identity provider

                                                                                                                                                        A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                      24. Expand Manage menu item

                                                                                                                                                      25. Select Expose an API

                                                                                                                                                      26. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                      27. Record Application ID URI of identity provider

                                                                                                                                                        ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                      28. Navigate to Policy Agent function app.

                                                                                                                                                      29. Expand Settings menu item.

                                                                                                                                                      30. Select Environment Variables menu item.

                                                                                                                                                      31. Click Add button.

                                                                                                                                                      32. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                      33. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                        Review Microsoft identity platform default scope

                                                                                                                                                      34. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                      35. Hit Apply in App Settings tab.

                                                                                                                                                      Authorization Option 4: Configure ESA Credentials authentication provider to authorize Policy Agent user-assigned identity.
                                                                                                                                                      1. Navigate to Policy Agent function app

                                                                                                                                                      2. Expand Settings menu item

                                                                                                                                                      3. Select Identity

                                                                                                                                                      4. Select User assigned tab

                                                                                                                                                        User-assigned identity should already be provided. Missing user-assigned identity indicates Policy Agent was installed without user-assigned identity. Before proceeding any further you need to either install Policy Agent with user-assigned identity or follow Option 3 which describes configuration steps for Policy Agent installed with system-assigned managed identity.

                                                                                                                                                      5. Copy Client ID

                                                                                                                                                      6. Copy Object (principal) ID

                                                                                                                                                      7. Navigate to ESA Credentials function app

                                                                                                                                                      8. Expand Settings menu item

                                                                                                                                                      9. Select Authentication

                                                                                                                                                      10. Select Add identity provider

                                                                                                                                                        Review related Microsoft documentation

                                                                                                                                                      11. Select Microsoft in identity provider dropdown

                                                                                                                                                      12. For App registration type provide details of your choice

                                                                                                                                                      13. For Issuer URL accept the default value

                                                                                                                                                      14. For Client application requirement select Allow requests from specific client applications

                                                                                                                                                      15. For Allowed client applications add Client ID copied in previous step

                                                                                                                                                      16. Click OK to apply constraint

                                                                                                                                                      17. For Identity requirement select Allow requests from specific identities

                                                                                                                                                      18. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                      19. Click OK to apply constraint

                                                                                                                                                      20. Click Save

                                                                                                                                                      21. Navigate to Application of Microsoft identity provider

                                                                                                                                                        A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                      22. Expand Manage menu item

                                                                                                                                                      23. Select Expose an API

                                                                                                                                                      24. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                      25. Record Application ID URI of identity provider

                                                                                                                                                        ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                      26. Navigate to Policy Agent function app.

                                                                                                                                                      27. Expand Settings menu item.

                                                                                                                                                      28. Select Environment Variables menu item.

                                                                                                                                                      29. Click Add button.

                                                                                                                                                      30. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                      31. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                        Review Microsoft identity platform default scope

                                                                                                                                                      32. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                      33. Hit Apply in App Settings tab.

                                                                                                                                                      Agent Function Key Vault Access Policies

                                                                                                                                                      Agent Function requires access to Key Vault created in Key Vault to encrypt policy and to access configuration secrets.

                                                                                                                                                      1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                      2. Select Access policies.
                                                                                                                                                      3. Click Create.
                                                                                                                                                      4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Wrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                      5. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Agent Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Agent via ARM template
                                                                                                                                                      6. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                      7. Review permissions and Create.

                                                                                                                                                      Agent Function Outbound IP address

                                                                                                                                                      Agent Function App IP addresses may be useful for configuring ESA policy store and allowing traffic between Agent and ESA.

                                                                                                                                                      To obtain the list of Outbound IP addresses:

                                                                                                                                                      1. From Azure console navigate to Function App, select the Agent Function App.
                                                                                                                                                      2. Select Settings > Networking.
                                                                                                                                                      3. Under Outbound traffic configuration, select Show More next to Outbound addresses

                                                                                                                                                      Configure Function

                                                                                                                                                      Agent Function must be configured with parameters recorded in steps above.

                                                                                                                                                      To configure Function:

                                                                                                                                                      1. Open Function App service from the Azure console. Select the Function App created for policy agent in previous steps.

                                                                                                                                                      2. Navigate to Settings > Environment variables .

                                                                                                                                                      3. On the App Settings pane, click on Show values to reveal all configuration values

                                                                                                                                                      4. To modify multiple parameters, click the pencil icon Advanced edit at the top. Alternatively you may click on the environment variable name to edit single values.

                                                                                                                                                      5. Modify parameters according to the table below. If configuration has a default value you don’t have to change it

                                                                                                                                                      Parameter

                                                                                                                                                      Notes

                                                                                                                                                      AZURE_KEY_VAULT_NAME

                                                                                                                                                      Key Vault

                                                                                                                                                      AZURE_POLICY_BLOB_URL

                                                                                                                                                      URL of the Azure Blob file which is used to store Protegrity security policies for protector consumption. See ProtectFuncPolicyBlobUrl in Protect Function Policy Blob

                                                                                                                                                      AZURE_RETAIN_POLICY_BLOB

                                                                                                                                                      The amount of policy backups to retain. Default: 10. Allowed values: -1, >1. Value of -1 will disable cleanup of backup policies.

                                                                                                                                                      PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                                      Protegrity function to be updated when new policy is deployed. Provide a comma separated list of protect function app names for updating multiple protectors:

                                                                                                                                                      Protegrity-Protect-func1,Protegrity-Protect-func2
                                                                                                                                                      

                                                                                                                                                      PTY_ESA_IP

                                                                                                                                                      ESA Server

                                                                                                                                                      AZURE_ESA_CREDENTIALS_SECRET_ID

                                                                                                                                                      ESA Credentials In Azure Key Vault

                                                                                                                                                      AZURE_ENCRYPTION_KEY_ID

                                                                                                                                                      Create Policy Encryption Key

                                                                                                                                                      PEP_CONFIG_CASE_SENSITIVE

                                                                                                                                                      Default: No Allowed values: yes/no

                                                                                                                                                      Specifies whether policy usernames should be case sensitive

                                                                                                                                                      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

                                                                                                                                                      PEP_CONFIG_EMPTY_STRING

                                                                                                                                                      Default: empty Allowed values: null empty

                                                                                                                                                      Determines outcome of empty value operation. For example, (un)protect(’’) -> null (un)protect(’’) ->

                                                                                                                                                      DISABLE_DEPLOY

                                                                                                                                                      Default: 0

                                                                                                                                                      POLICY_PULL_TIMEOUT

                                                                                                                                                      Default: 20s

                                                                                                                                                      ESA_CONNECTION_TIMEOUT

                                                                                                                                                      Default: 5s

                                                                                                                                                      LOG_LEVEL

                                                                                                                                                      Default: INFO. Allowed values: DEBUG, INFO, WARNING, ERROR

                                                                                                                                                      AZURE_SUBSCRIPTION_ID

                                                                                                                                                      Default: Same as ARM Resource group

                                                                                                                                                      AZURE_RESOURCE_GROUP_NAME

                                                                                                                                                      Default: Same as ARM Resource group

                                                                                                                                                      POLICY_DOWNLOAD_CRON_EXPRESSION

                                                                                                                                                      Describes how often Agent Function will run Default: 0 0 * * * * (Every hour)

                                                                                                                                                      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.

                                                                                                                                                      PTY_ESA_CREDENTIALS_FUNCTION

                                                                                                                                                      Instead of supplying AZURE_ESA_CREDENTIALS_SECRET_ID environment variable, ESA credentials can be provided by a custom Azure Function App. Provide a value recorded for EsaCredentialsFnUrl

                                                                                                                                                      PTY_ESA_CREDENTIALS_FUNCTION_KEY

                                                                                                                                                      When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key. Provide a value recorded for EsaCredentialsFnKey

                                                                                                                                                      PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET

                                                                                                                                                      When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key stored in Azure Key Vault. Provide a value recorded for EsaCredentialsFnKeySecretName

                                                                                                                                                      PTY_ESA_CREDENTIALS_FUNCTION_SCOPE

                                                                                                                                                      When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using its own identity. Provide a value here recorded for EsaCredentialsFnAppIdUri appended with /.default to create authentication scope. Review Microsoft identity platform default scope

                                                                                                                                                      PTY_SYNC_DATASTORE

                                                                                                                                                      Name of the target datastore

                                                                                                                                                      PTY_DATASTORE_KEY

                                                                                                                                                      The export key is the public part of an asymmetric key pair created in a Create Policy Encryption 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.

                                                                                                                                                      1. Click Apply at the bottom of the screen and then Confirm to save the changes.

                                                                                                                                                      Parameter

                                                                                                                                                      Notes

                                                                                                                                                      AZURE_CLIENT_ID

                                                                                                                                                      Sets the Managed Identity Client ID for Function App runtime. System-Assigned Identity is used when variable is not set.

                                                                                                                                                      APPLICATIONINSIGHTS_AUTHENTICATION_STRING

                                                                                                                                                      Define identity for Application Insights access. Managed Identity Client ID is provided to this setting with Function App Managed Identity ARM template parameter. See the corresponding Azure AD Authentication documentation: Azure AD authentication

                                                                                                                                                      APPLICATIONINSIGHTS_CONNECTION_STRING

                                                                                                                                                      Connection String for Application Insights instance. See the corresponding Azure Connection String documentation: Connection strings

                                                                                                                                                      FUNCTIONS_EXTENSION_VERSION

                                                                                                                                                      Azure Functions extension version

                                                                                                                                                      FUNCTIONS_WORKER_RUNTIME

                                                                                                                                                      Runtime of the function

                                                                                                                                                      WEBSITE_RUN_FROM_PACKAGE

                                                                                                                                                      URL to the zip file in blob storage with function runtime source

                                                                                                                                                      WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID

                                                                                                                                                      Managed Identity used to load function runtime source

                                                                                                                                                      AzureWebJobsStorage__blobServiceUri

                                                                                                                                                      URL of the storage account which hosts the blob identified in WEBSITE_RUN_FROM_PACKAGE

                                                                                                                                                      Test Agent Function Installation

                                                                                                                                                      After configuration is complete you can test the function.

                                                                                                                                                      To test Agent function installation:

                                                                                                                                                      1. Navigate to Overview.

                                                                                                                                                      2. Select the function agent from the Functions tab.

                                                                                                                                                      3. Click Code + Test > Test/Run and then Run to execute the function.

                                                                                                                                                      4. You should see a 202 Accepted response.

                                                                                                                                                      5. Expand Logs output at the bottom of the page. Click Maximize to enlarge log output.

                                                                                                                                                      6. Below is an example log output from successful agent run.

                                                                                                                                                        
                                                                                                                                                        INFO:AZURE_SUBSCRIPTION_ID: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
                                                                                                                                                        INFO:AZURE_KEY_VAULT_NAME: [vault-name]
                                                                                                                                                        INFO:AZURE_ENCRYPTION_KEY_ID: [https://vault-name.vault.azure.net/keys/key-name/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
                                                                                                                                                        INFO:AZURE_RESOURCE_GROUP_NAME: [resource-group-name]
                                                                                                                                                        INFO:AZURE_POLICY_BLOB_URL: [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip]
                                                                                                                                                        INFO:AZURE_RETAIN_POLICY_BLOB: [3]
                                                                                                                                                        INFO:PROTEGRITY_PROTECT_FUNCTION: [Protegrity-Protect-xxxx]
                                                                                                                                                        INFO:DISABLE_DEPLOY: [0]
                                                                                                                                                        INFO:PTY_ESA_IP: [xxx.xxx.xxx.xxx]
                                                                                                                                                        INFO:PTY_SYNC_DATASTORE: []
                                                                                                                                                        INFO:POLICY_PULL_TIMEOUT: [40]
                                                                                                                                                        INFO:LOG_LEVEL: [info]
                                                                                                                                                        INFO:PTY_CORE_EMPTYSTRING: [empty]
                                                                                                                                                        INFO:PTY_CORE_CASESENSITIVE: [no]
                                                                                                                                                        INFO:PTY_ADDIPADDRESSHEADER: [yes]
                                                                                                                                                        INFO:Starting policy agent [4.0.3] ...
                                                                                                                                                        INFO:ESA_CONNECTION_TIMEOUT: [60]
                                                                                                                                                        INFO:Using ESA CA certificate from PTY_ESA_CA_SERVER_CERT environment variable.
                                                                                                                                                        INFO:ResilientPackageClient initialized.
                                                                                                                                                        INFO:Retrieving ESA rps version
                                                                                                                                                        INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[]
                                                                                                                                                        INFO:RPS Version: 1.9.2, Build: 1.9.2+1.g4bfba.1.9
                                                                                                                                                        INFO:Checking ESA rps export availability
                                                                                                                                                        INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[QA_DATA_STORE]
                                                                                                                                                        INFO:Export available, Last-Modified: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                                        INFO:Getting current policy metadata [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip] ...
                                                                                                                                                        INFO:Last modified: [Thu, 01 Jan 2026 00:00:00 GMT], Last deployed: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                                        WARNING:Current policy deployment has no checksum_mapping metadata:
                                                                                                                                                        INFO:No changes in the policy since last download. Skipping policy deployment.
                                                                                                                                                        INFO:Checking container for the last deployed policy [https://resource-group-name.blob.core.windows.net/policy]...
                                                                                                                                                        INFO:[Protegrity-Protect-xxxx] current policy blob url: [https://resource-group-name.blob.core.windows.net/policy/2026-02-01_18-00-00/protegrity-policy-name.zip]
                                                                                                                                                        INFO:Policy blob in sync for function [Protegrity-Protect-xxxx]
                                                                                                                                                        INFO:[0] blobs are outside of the retention period [3]
                                                                                                                                                        
                                                                                                                                                      7. If the log output in this window pauses or is difficult to read, you may navigate back to the Agent Function App overview and select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to view logs.

                                                                                                                                                      Troubleshooting

                                                                                                                                                      To review the most recent invocation traces, navigate to the function app instance. Select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to retrieve the full history of executions with detailed traces.

                                                                                                                                                      2.2.3.6 - Audit Log Forwarder Installation

                                                                                                                                                      Install the audit log forwarder.

                                                                                                                                                        The following sections provide installation steps for the Log Forwarder component in Azure. The Log Forwarder deployment allows for the audit logs generated by Protect Service to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protect Service to work properly. See Audit Log Forwarder Architecture for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity for further guidance on configuration alternatives in the cloud.

                                                                                                                                                        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 (Audit Store) or 24284 (td-agent).

                                                                                                                                                        2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                                                                                                        3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                                                                                                        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 Log Forwarder variable in section Install Log Forwarder via ARM template

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

                                                                                                                                                        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:

                                                                                                                                                        • client.key
                                                                                                                                                        • client.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"
                                                                                                                                                        

                                                                                                                                                        There are two options to configure Log Forwarder for certificate authentication:

                                                                                                                                                        • While installing using ARM template
                                                                                                                                                          1. Provide single-line client certificate for Esa Client Cert
                                                                                                                                                          2. Provide Azure Key Vault secret name for Esa Client Cert Key Secret Name which stores single-line certificate key file.
                                                                                                                                                        • When re-configuring after installation using environment variables
                                                                                                                                                          1. Provide single-line client certificate for ESA_CLIENT_CERT
                                                                                                                                                          2. Provide Azure Key Vault secret name for ESA_CLIENT_CERT_KEY_SECRET_NAME which stores single-line certificate key file.

                                                                                                                                                        Create Key Vault Secrets

                                                                                                                                                        Log Forwarder uses Key Vault as a secure store for certificate key file.

                                                                                                                                                        Create secret in Key Vault for certificate key file:

                                                                                                                                                        1. Navigate to Key Vault.

                                                                                                                                                        2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                        3. Select Manual, type in secret name and specify single-line certificate key file value for Secret value.

                                                                                                                                                        4. Select Create.

                                                                                                                                                        5. Record secret name:

                                                                                                                                                          ESA Client Cert Key Secret Name (EsaClientCertKeySecretName): ___________________

                                                                                                                                                        Function User-Assigned Managed Identity

                                                                                                                                                        User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                        1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                        2. Select Create

                                                                                                                                                        3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                        4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                        5. For Region provide recorded value of ApiRegion

                                                                                                                                                        6. For Name provide a name of the new identity

                                                                                                                                                        7. Assign following roles to this identity:

                                                                                                                                                          • Storage Blob Data Owner
                                                                                                                                                          • Monitoring Metrics Publisher
                                                                                                                                                          • Azure Event Hubs Data Receiver
                                                                                                                                                        8. Record Forward function user-assigned identity

                                                                                                                                                          Forward Function User-Assigned Identity (ForwardFuncUserAssignedIdentity): ____________________

                                                                                                                                                        Install Log Forwarder via ARM template

                                                                                                                                                        Resources created with ARM template include Function App, App Service Plan and Application Insights service. Optionally, a new Event Hub namespace and Event Hub instance can be created.

                                                                                                                                                        To install Log Forwarder via ARM template:

                                                                                                                                                        1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                                        2. Select Build your own template in editor.

                                                                                                                                                        3. Select Load File and upload pty_forward_arm_v2.json. Click Save.

                                                                                                                                                        4. Select Resource Group.

                                                                                                                                                        5. Specify Name for the resources (All resources will be prefixed with Protegrity-Forward).

                                                                                                                                                        6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                                        7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Forward Function Blob Url.

                                                                                                                                                        8. For Forward Function Blob Url use the value from Upload Files.

                                                                                                                                                        9. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                                                        10. For Function Sku Count Minimum number of workers to keep active.

                                                                                                                                                        11. For WorkSpace Sku Azure Monitor log analytics pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                        12. For Log Retention In Days The workSpace data retention in days. Allowed values are per pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                        13. For Forward Logs to ESA select whether to collect audit logs from a new or an existing Event Hub. A new Event Hub namespace and new Event Hub instance will be created for ‘From new Event Hub’ option.

                                                                                                                                                        14. For Audit Log Output select whether to send logs directly to Audit Store or td-agent on ESA

                                                                                                                                                        15. For Event Hub Namespace enter Event Hub namespace name. Depending on previous option, a new namespace with this name will be created or an existing namespace with this name will be used.

                                                                                                                                                        16. For New Event Hub Namespace Sku Name select Event Hub namespace SKU name. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                        17. For New Event Hub Namespace Sku Tier select Event Hub namespace SKU Tier used for new Event Hub namespace. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                        18. For New Event Hub Namespace Sku Capacity enter a value of Event Hub throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                        19. For Event Hub Name enter Event Hub instance name. A new Event Hub instance with this name will be created or an existing Event Hub instance with this name will be used.

                                                                                                                                                        20. For Event Hub Name DLQ enter Event Hub name for the dead-letter queue, where messages will be delivered to in case connection to ESA is lost. A new Event Hub instance with this name will be created or an existing Event Hub with this name will be used.

                                                                                                                                                        21. For New Event Hub Partition Count enter number of partitions to create in a new Event Hub. Allowed values are from 1 to 32 partitions. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                        22. For New Event Hub Audit Log Retention In Days enter number of days audit logs will be available in Event Hub. Applies to both primary Event Hub and dead-letter queue Event Hub. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                        23. For Log Destination Esa Ip enter ESA IP address.

                                                                                                                                                        24. For Esa Client Cert enter single-line ESA client certificate. See section Certificate Authentication for details.

                                                                                                                                                        25. For Esa Client Cert Key Secret Name enter secret name which stores ESA client certificate single-line private key. See section Certificate Authentication for details.

                                                                                                                                                        26. For Key Vault Uri enter URI of the Key Vault that stores ESA username/password secrets.

                                                                                                                                                        27. For Esa Tls Disable Cert Verify Set to ‘0’ to enable ESA certificate validation. Set to ‘1’ to disable ESA certificate verification. Disable only for initial setup and development purposes, do not disable in production environments.

                                                                                                                                                        28. If ESA is configured with self-signed certificate, set Pty Esa Ca Server Cert. Use the ESA CA Server Certificate escaped content recorded in Certificates on ESA.

                                                                                                                                                          Note that for development and troubleshooting purposes, ESA certificate validation can be disabled by either redeploying this function with this ARM template where Esa Tls Disable Cert Verify option is set to ‘1’ or by directly setting PTY_ESA_DISABLE_TLS_CERT_VERIFY environment variable to ‘1’.

                                                                                                                                                        29. For Esa Connect Timeout set time in seconds to wait for the ESA connection response. Minimum value: 1. Default: 5.

                                                                                                                                                        30. For Esa Virtual Host provide ESA virtual hostname. This configuration is optional. It can be used when proxy server is present and supports TLS SNI extension.

                                                                                                                                                        31. For Min Log Level select minimum log level. Accepted values: off, severe, warning, info, config, all

                                                                                                                                                        32. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                                        After deployment is complete:

                                                                                                                                                        1. Go to Outputs and record:

                                                                                                                                                          Forward Function Name (ForwardFuncName):__________________

                                                                                                                                                        2. Record:

                                                                                                                                                          Event Hub Name (EventHubName):__________________

                                                                                                                                                          Event Hub Namespace (EventHubNamespace):__________________

                                                                                                                                                        Function System-Assigned Managed Identity

                                                                                                                                                        System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                        If you have not created a user-assigned managed identity at Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                        1. Navigate to the function

                                                                                                                                                        2. Select Settings, Identity.

                                                                                                                                                        3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                        4. Click on Azure role assignments button.

                                                                                                                                                        5. Assign following roles to this identity:

                                                                                                                                                          • Storage Blob Data Owner
                                                                                                                                                          • Monitoring Metrics Publisher
                                                                                                                                                          • Azure Event Hubs Data Receiver
                                                                                                                                                        6. From Azure console, navigate to Function App and select audit log forwarder function deployed in previous section.

                                                                                                                                                        7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                                        Update Function Key Vault Access Policies

                                                                                                                                                        The Key vault must be updated to allow the Function App to decrypt the policy files. The Forwarder is using policy to confirm the authenticity of audit logs it receives from Event Hub and to digitally sign the aggregated logs that it sends to ESA. Update the Key vault access policies with function identity. To update the key vault access policies:

                                                                                                                                                        1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                        2. Select Access policies.
                                                                                                                                                        3. Click Create.
                                                                                                                                                        4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                        5. Proceed Next to Principal.
                                                                                                                                                        6. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Log Forwarder via ARM template
                                                                                                                                                        7. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                        8. Review permissions and Create.

                                                                                                                                                        Test Log Forwarder Installation

                                                                                                                                                        Follow the steps to validate Log Forwarder installation. Successful Log Forwarder installation will aggregate logs, connect to ESA and send audit log events.

                                                                                                                                                        Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                                                                                                        Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                                                                                                        1. In the following command, replace ‘forwarder-function-name’ with your function name

                                                                                                                                                        2. In the following command, replace ‘forwarder-function-key’ with your function key

                                                                                                                                                        3. Run the command in PowerShell:

                                                                                                                                                          
                                                                                                                                                          $forwarderFunctionName='forwarder-function-name'
                                                                                                                                                          $forwarderFunctionKey='forwarder-function-key'
                                                                                                                                                          
                                                                                                                                                          Invoke-WebRequest -UseBasicParsing -Uri "https://$forwarderFunctionName.azurewebsites.net/admin/functions/auditlogforwarder" `
                                                                                                                                                          -Method POST `
                                                                                                                                                          -Headers @{
                                                                                                                                                            "x-functions-key" = $forwarderFunctionKey
                                                                                                                                                          } `
                                                                                                                                                          -ContentType "application/json" `
                                                                                                                                                          -Body "{`"input`":`"{\`"additional_info\`":{\`"description\`":\`"Data unprotect operation was successful.\`",\`"request_id\`":\`"f0ffbbf8-ab5b-42b7-90f4-51db7443af77\`"},\`"cnt\`": 1,\`"correlationid\`": \`"clfwrqgme0021nj329mijk52w\`",\`"logtype\`": \`"Protection\`",\`"level\`": \`"SUCCESS\`",\`"origin\`": {  \`"hostname\`": \`"169.254.197.189\`",  \`"ip\`": \`"169.254.197.189\`", \`"time_utc\`": 1722941687},\`"protection\`": {\`"dataelement\`": \`"alpha\`", \`"operation\`": \`"Unprotect\`",\`"audit_code\`": 8,\`"policy_user\`": \`"test_user\`",\`"datastore\`": \`"SAMPLE_POLICY\`"},\`"process\`": {  \`"name\`": \`"N/A\`",  \`"id\`": \`"15\`",\`"thread_id\`": \`"2243954624\`",\`"user\`": \`"sbx_user1051\`", \`"platform\`": \`"Linux_x32\`"},\`"client\`": {\`"username\`":\`"sbx_user1051\`",\`"ip\`":\`"169.254.197.189\`"},\`"protector\`": {\`"family\`": \`"IAP Lambda\`",\`"version\`": \`"3.1.0\`",\`"vendor\`": \`"Cloud Protect\`",\`"pcc_version\`": \`"3.5.0.1\`", \`"core_version\`": \`"2.0.1\`"},\`"signature\`": { \`"key_id\`":\`"5f143892-bbe4-4794-b1f4-ed28ca2a077e\`", \`"checksum\`": \`"90BC9BF39354869BD4BC5381820D201797DF4AF53B5A7F5F3AE01EC607C41A6E\`"}}`"}"
                                                                                                                                                          

                                                                                                                                                        4. Run following query to see your function logs, allow for a few minutes for Azure to deliver the logs

                                                                                                                                                          
                                                                                                                                                          traces
                                                                                                                                                          | project timestamp, message
                                                                                                                                                          | where timestamp > ago(5m)
                                                                                                                                                          
                                                                                                                                                        5. Test is successful if the logs contain the following entry:

                                                                                                                                                          opensearch.0: All logs successfully send to destination
                                                                                                                                                          

                                                                                                                                                          If the log entry is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                                                                                        Update Protect Service With Event Hub details

                                                                                                                                                        In this section, Event Hub details will be provided to the Protect Service installation.

                                                                                                                                                        1. Navigate to the Protect function environment variables.

                                                                                                                                                        2. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                        3. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                        4. Apply and Confirm to apply the changes.

                                                                                                                                                        Update Policy Agent With Log Forwarder Function Target

                                                                                                                                                        Log Forwarder requires a Protegrity policy which is in sync with the Protector Service. This section will describe the steps to update the Policy Agent to include updating the Log Forwarder.

                                                                                                                                                        1. Navigate to the Policy Agent function created in Install Agent via ARM template

                                                                                                                                                        2. Select Settings > Environment variables > PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                                        3. Edit the value for environment variable PROTEGRITY_PROTECT_FUNCTION to include the Log Forwarder function’s name in the comma separated list of function names.

                                                                                                                                                        4. Select Apply > Apply > Confirm to save the changes

                                                                                                                                                        5. Test Policy Agent installation as described in Test Agent Function Installation

                                                                                                                                                        Test Full Log Forwarder Installation

                                                                                                                                                        1. Install and configure Protegrity Agent, Protect Service and Log Forwarder components.
                                                                                                                                                        2. Set EVENT_LEVEL environment variable on Protect Service function to Informational.
                                                                                                                                                        3. Set PTY_LOG_LEVEL environment variable on both Protect Service function and Log Forwarder function to config.

                                                                                                                                                        Test Installation

                                                                                                                                                        1. Make a protect operation using a data element or user which will result in audit log generation

                                                                                                                                                        2. Navigate to the Logs for the Protect Service function

                                                                                                                                                        3. Execute ’traces’ query

                                                                                                                                                        4. Expect to see a log similar to the below:

                                                                                                                                                          
                                                                                                                                                          Completed publishing events for Event Hub: audit-logs (Partition Id/Key: '0'), Operation Id: 'e17bacd6-91e6-4fb5-8281-2929788bef09'. Service Retry Count: 0; Duration: '0.02' seconds
                                                                                                                                                          
                                                                                                                                                        5. Navigate to the Logs for the Log Forwarder function

                                                                                                                                                        6. Execute ’traces’ query

                                                                                                                                                        7. Expect to see a log similar to the below:

                                                                                                                                                          
                                                                                                                                                          opensearch.0: All logs successfully send to destination
                                                                                                                                                          

                                                                                                                                                        Troubleshooting

                                                                                                                                                        Configure additional logging for functions:

                                                                                                                                                        1. Set EVENT_LEVEL environment variable on Protect function to Informational.
                                                                                                                                                        2. Set PTY_LOG_LEVEL environment variable on both Protect function and Log Forwarder function to config.

                                                                                                                                                        Error

                                                                                                                                                        Detail

                                                                                                                                                        
                                                                                                                                                        Unhandled exception. System.Exception: Failed to initialize 
                                                                                                                                                        function type,expecting environment variable 
                                                                                                                                                        'AzureWebJobs.AuditLogForwarder.Disabled' 
                                                                                                                                                        to be set to either 'true' or 'false'
                                                                                                                                                        
                                                                                                                                                        1. An environment variable ‘AzureWebJobs.AuditLogForwarder.Disabled’ is expected. This environment variable is added automatically when functions are deployed with ARM templates.
                                                                                                                                                        2. Verify this environment variable exists and is set to ’true’ for Protect Service functions and is set to ‘false’ for Log Forwarder functions.
                                                                                                                                                        
                                                                                                                                                        [2024/08/08 10:00:00] [error] [tls] error: unexpected EOF
                                                                                                                                                        

                                                                                                                                                        Log Forwarder failed to verify ESA certificate

                                                                                                                                                        1. If ESA is configured with self-signed certificate, verify that Log Forwarder ‘PTY_ESA_CA_SERVER_CERT’ is correctly set to ESA CA certificate string. Refer to Certificates on ESA for details.
                                                                                                                                                        2. If ESA is configured with publicly signed certificate, ensure Log Forwarder ‘PTY_LOG_LEVEL’ is set to ‘all’ level, restart and re-test the Log Forwarder. Review the logs to see if your root CA is used. If not used, you may supply your public CA in Log forwarder configuration ‘PTY_ESA_CA_SERVER_CERT’.
                                                                                                                                                        3. During initial non-production setup, SSL verification can be disabled by setting ‘PTY_ESA_DISABLE_TLS_CERT_VERIFY’ environment variable to ‘1’ or ’true’
                                                                                                                                                        
                                                                                                                                                        Failed to aggregate audit logs, 1 audit logs dropped, error: 
                                                                                                                                                        The user, group or application 'appid=;oid=;iss=' does not have 
                                                                                                                                                        secrets get permission on key vault ';location='...
                                                                                                                                                        Status: 403 (Forbidden)
                                                                                                                                                        ErrorCode: Forbidden
                                                                                                                                                        

                                                                                                                                                        Log Forwarder has no permissions to use Key Vault

                                                                                                                                                        1. Verify Log Forwarder has access to the Key Vault.
                                                                                                                                                        2. Consult section Update Function Key Vault Access Policies
                                                                                                                                                        
                                                                                                                                                        TCP connection timed out: 001.001.001.001:9200
                                                                                                                                                        

                                                                                                                                                        Log Forwarder failed to connect to ESA

                                                                                                                                                        1. Ensure ESA is available on given IP address and 9200 port
                                                                                                                                                        2. Consult section ESA Audit Store Configuration
                                                                                                                                                        
                                                                                                                                                        fail: Protect.Aggregate[0] Failed to aggregate audit logs, 
                                                                                                                                                        1 audit logs dropped, error: Invalid URI: The format of the URI 
                                                                                                                                                        could not be determined. 
                                                                                                                                                        info: iap[0] Shared memory segment POLICY does not exist: The 
                                                                                                                                                        system cannot find the file specified.
                                                                                                                                                        

                                                                                                                                                        Invalid Key Vault Uri format

                                                                                                                                                        1. Ensure that environment variable KEY_VAULT_URI has correctly formatted url.
                                                                                                                                                        2. Example 1: https://<keyvaultname>.vault.azure.net/
                                                                                                                                                        3. Example 2: https://<keyvaultname>.vault.usgovcloudapi.net/
                                                                                                                                                        
                                                                                                                                                        [Error] Azure-Messaging-EventHubs: An exception occurred while 
                                                                                                                                                        publishing a batch of events for buffered producer instance with 
                                                                                                                                                        identifier 'x' to Event Hub: audit-logs, Partition Id: '0', 
                                                                                                                                                        Operation Id: 'x'. Error Message: 'Unauthorized access.
                                                                                                                                                        

                                                                                                                                                        Protect Service function failed to send messages to Event Hub

                                                                                                                                                        1. Ensure Forwarder Function managed identity has ‘Azure Event Hubs Data Sender’ role assigned for the Event Hub resource.
                                                                                                                                                        2. See Function User-Assigned Managed Identity and Function System-Assigned Managed Identity

                                                                                                                                                        2.2.3.7 -

                                                                                                                                                        Prerequisites

                                                                                                                                                        Requirement

                                                                                                                                                        Detail

                                                                                                                                                        Protegrity distribution and installation scripts

                                                                                                                                                        These artifacts are provided by Protegrity

                                                                                                                                                        Protegrity ESA 10.0+

                                                                                                                                                        The Cloud VNet must be able to obtain network access to the ESA

                                                                                                                                                        Azure Account (Azure Global or US Government Subscription)

                                                                                                                                                        Recommend creating a new resource group for Protegrity.

                                                                                                                                                        2.2.3.8 -

                                                                                                                                                        Required Skills and Abilities

                                                                                                                                                        Role / Skillset

                                                                                                                                                        Description

                                                                                                                                                        Azure Account Administrator

                                                                                                                                                        Ability to run Azure Resource Manager (or perform steps manually), create/configure Entra ID Application Registrations

                                                                                                                                                        Protegrity Administrator

                                                                                                                                                        The ESA credentials required to extract the policy for the Policy Agent

                                                                                                                                                        Snowflake Administrator

                                                                                                                                                        Account Admin access required to setup Snowflake integration

                                                                                                                                                        Network Administrator

                                                                                                                                                        Needed to open firewall to access ESA and evaluate Azure network setup

                                                                                                                                                        2.2.4 - Understanding Snowflake Objects

                                                                                                                                                        Key concepts in understanding the Protegrity Serverless with Snowflake.

                                                                                                                                                        2.2.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';
                                                                                                                                                                                    
                                                                                                                                                        

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

                                                                                                                                                        2.2.5 - Performance

                                                                                                                                                        Performance benchmarks and considerations.

                                                                                                                                                        2.2.5.1 - Function App Performance

                                                                                                                                                        Guidance on Function App Performance Performance settings and considerations.

                                                                                                                                                        Function App Performance

                                                                                                                                                        Overview

                                                                                                                                                        Azure Function apps offer different hosting plans that directly impact the performance, scalability, and cost of Cloud Protect deployments. Understanding these plans and their characteristics is essential for optimizing your data protection operations.

                                                                                                                                                        Azure Function App Service Plans

                                                                                                                                                        Azure Functions provides several hosting options, each with different characteristics:

                                                                                                                                                        Consumption Plan

                                                                                                                                                        The Consumption plan provides automatic scaling and charges only for compute resources used during function execution. While cost-effective for sporadic workloads, this plan has limitations:

                                                                                                                                                        • Cold start latency: Functions may experience delays when starting after periods of inactivity
                                                                                                                                                        • Limited execution time: Maximum execution duration of 10 minutes per function invocation
                                                                                                                                                        • Shared infrastructure: Resources are shared across tenants, which can lead to variable performance
                                                                                                                                                        • Memory constraints: Limited to 1.5 GB of memory per instance

                                                                                                                                                        The Premium plan is the recommended option for Cloud Protect on Azure. It provides enhanced performance and enterprise-grade features:

                                                                                                                                                        • Pre-warmed instances: Always-ready instances eliminate cold start delays, ensuring consistent performance
                                                                                                                                                        • Enhanced compute resources: Flexible compute sizing, see App Service Premium version 3 plan
                                                                                                                                                        • VNET integration: Secure connectivity to on-premises resources and Azure private networks
                                                                                                                                                        • Unlimited execution duration: No time limits for long-running protection operations
                                                                                                                                                        • Predictable performance: Dedicated infrastructure ensures consistent throughput
                                                                                                                                                        • Better scaling control: Minimum and maximum instance count configuration

                                                                                                                                                        The Elastic Premium plan extends the Premium plan with additional elasticity and performance optimization:

                                                                                                                                                        • Rapid scale-out: Faster scaling response to demand spikes
                                                                                                                                                        • Greater instance limits: Support for larger-scale deployments
                                                                                                                                                        • Optimized cold start: Even faster initialization compared to standard Premium
                                                                                                                                                        • Event-driven scaling: More granular scaling based on event sources
                                                                                                                                                        • All Premium features: Includes VNET integration, pre-warmed instances, and unlimited execution time

                                                                                                                                                        Cloud Protect Recommendations

                                                                                                                                                        Cloud Protect on Azure recommends using either Premium or Elastic Premium plans for production deployments. These plans provide:

                                                                                                                                                        1. Consistent Performance: Pre-warmed instances ensure data protection operations execute immediately without cold start delays
                                                                                                                                                        2. Sufficient Resources: Memory and CPU resources adequate for cryptographic operations and high-volume data processing
                                                                                                                                                        3. Reliability: Dedicated infrastructure for predictable performance and SLA compliance
                                                                                                                                                        4. Security: VNET integration enables secure communication with ESA (Enterprise Security Administrator) and other protected resources
                                                                                                                                                        5. Scalability: Automatic scaling handles variable workloads while maintaining performance standards

                                                                                                                                                        Performance Considerations

                                                                                                                                                        When deploying Cloud Protect on Azure Functions, consider the following factors:

                                                                                                                                                        Instance Sizing

                                                                                                                                                        Select appropriate instance sizes based on your workload:

                                                                                                                                                        • EP1 (Elastic Premium 1): 1 vCPU, 3.5 GB RAM - suitable for moderate workloads
                                                                                                                                                        • EP2 (Elastic Premium 2): 2 vCPU, 7 GB RAM - recommended for standard production deployments
                                                                                                                                                        • EP3 (Elastic Premium 3): 4 vCPU, 14 GB RAM - for high-volume or resource-intensive operations

                                                                                                                                                        Scaling Configuration

                                                                                                                                                        Configure scaling parameters to match your protection requirements:

                                                                                                                                                        • Minimum instances: Set to at least 1-2 pre-warmed instances to eliminate cold starts
                                                                                                                                                        • Maximum instances: Configure based on peak load expectations and budget constraints
                                                                                                                                                        • Scale-out rules: Define appropriate triggers based on CPU, memory, or queue depth metrics

                                                                                                                                                        Network Considerations

                                                                                                                                                        • Use VNET integration to reduce latency when communicating with ESA servers
                                                                                                                                                        • Enable private endpoints for secure, high-performance connectivity to Azure services (Storage, Key Vault)
                                                                                                                                                        • Consider proximity placement to co-locate Function apps with dependent resources

                                                                                                                                                        Monitoring and Optimization

                                                                                                                                                        • Monitor execution duration metrics to identify bottlenecks
                                                                                                                                                        • Track instance count and scaling patterns to optimize configuration
                                                                                                                                                        • Review memory and CPU utilization to right-size your plan
                                                                                                                                                        • Set up Application Insights for detailed performance telemetry and diagnostics

                                                                                                                                                        Cost vs. Performance Trade-offs

                                                                                                                                                        While Premium and Elastic Premium plans have higher baseline costs compared to Consumption, they provide:

                                                                                                                                                        • Predictable performance and cost structure
                                                                                                                                                        • Reduced total cost for steady-state workloads (no per-execution charges)
                                                                                                                                                        • Better resource utilization through persistent instances
                                                                                                                                                        • Lower operational overhead from consistent behavior

                                                                                                                                                        For Cloud Protect deployments handling sensitive data with compliance requirements, the Premium/Elastic Premium investment ensures reliable, performant data protection operations.

                                                                                                                                                        2.2.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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Azure Event Hub instance where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated.

                                                                                                                                                          These sections show 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 so that audit records are not lost.

                                                                                                                                                          Protect Service Function Environment Variables

                                                                                                                                                          • PTY_CORE_FLUSHINTERVAL: Defines for how long audit logs are aggregated before they are sent to Azure Event Hub. Default value is ten seconds. Audit logs are always aggregated into one minute buckets, therefore a value greater than sixty seconds will affect mostly the batching interval.

                                                                                                                                                          • MAX_WAIT_TIME: Defines for how long aggregated audit logs are batched before they are sent to Azure Event Hub. Default value is ten seconds.

                                                                                                                                                            Increasing MAX_WAIT_TIME may result in:

                                                                                                                                                            1. Increased latency or lag of audit logs arriving to Event Hub and therefore ESA

                                                                                                                                                            2. Increased throughput rates due to fewer network requests overall

                                                                                                                                                            3. Increased aggregation rates for values up to one minute Lowering MAX_WAIT_TIME may result in:

                                                                                                                                                            4. Reduced latency or lag for audit logs to arrive to Event Hub and therefore ESA

                                                                                                                                                            5. Reduced throughput rates due to higher number of network requests overall

                                                                                                                                                            6. Reduced aggregation rates for values up to one minute It is not recommended to set MAX_WAIT_TIME lower in production workloads as it may overload the Event Hubs service. Lowering MAX_WAIT_TIME may be beneficial for speeding up log delivery to ESA in dev/test environments.

                                                                                                                                                          Log Forwarder ARM Template Parameters

                                                                                                                                                          • New Event Hub Namespace Sku Name and New Event Hub Namespace Sku Tier directly affect the quotas applied to new Event Hub instances. Review Azure Event Hub Quotas related to selected tier in Azure documentation: Azure Event Hub Quotas
                                                                                                                                                          • New Event Hub Namespace Sku Capacity: Event Hubs throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Capacity directly controls the purchased throughput of Event Hub instance. Review details in Azure documentation: Event Hub Instance Throughput
                                                                                                                                                          • New Event Hub Partition Count: The number of partitions represents the level of parallel log streams in the Event Hub. It is proportional to throughput capacity of the Event Hub instance. If the number of partitions is too low and the volume of audit logs is too high, a throughput ceiling may be reached on Event Hub and some audit records sent from protect function may be lost. Review details in Azure documentation: Event Hub Scalability
                                                                                                                                                          • New Event Hub Audit Log Retention In Days: Number of days audit logs are to be available in Event Hub. Applies to both primary Event Hub instance and dead-letter queue Event Hub instance. While audit logs are processed by Log Forwarder in near-realtime, it may be beneficial to keep audit logs available in Event Hub for extended period in case Log Forwarder or ESA require maintenance.
                                                                                                                                                          • Event Hub Name DLQ: Dead-letter Queue Event Hub name. This Event Hub will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ Event Hub can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                                                                                                          Monitoring Log Forwarder Performance

                                                                                                                                                          • Azure Event Hub Metrics: Any positive value in ‘Throttled Requests’ metric indicates that audit logs rate from protect function is too high. The recommended actions may include:

                                                                                                                                                            • Increase aggregation and batching intervals of Protect function by increasing values of PTY_CORE_FLUSHINTERVAL and MAX_WAIT_TIME
                                                                                                                                                            • Increase number of partitions for Event Hub
                                                                                                                                                            • Purchase additional capacity units for Event Hub
                                                                                                                                                            • Use a higher Event Hub namespace tier
                                                                                                                                                          • Azure Event Hub Metrics for DLQ Event Hub: Any positive value in ‘Incoming Messages’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Audit Log Forwarder Installation

                                                                                                                                                          • Protect Function Logs: If protect function is unable to send logs to Event Hub, it will log the following message:

                                                                                                                                                            Failed to forward {n} events to Event Hub
                                                                                                                                                            
                                                                                                                                                          • Count number of protect operations: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                                            traces
                                                                                                                                                            | where timestamp >= ago(20h)
                                                                                                                                                            | where message has 'additional_info'
                                                                                                                                                            | parse message with * "cnt\":" Count: long *  ",\"correlation" *
                                                                                                                                                            | summarize count_sum = sum(Count)
                                                                                                                                                            
                                                                                                                                                          • View number of function instances on a graph: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                                            requests
                                                                                                                                                            | summarize InstanceCount = dcount(cloud_RoleInstance) by bin(timestamp, 1s)
                                                                                                                                                            | where timestamp >= ago(2h)
                                                                                                                                                            | order by timestamp desc
                                                                                                                                                            | render timechart
                                                                                                                                                            

                                                                                                                                                          2.2.6 - Audit Logging

                                                                                                                                                          Audit log description/formatting

                                                                                                                                                            Audit Logging

                                                                                                                                                            Audit records and application logs stream to Azure Storage Account. 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 Azure Application Insights. For more information about forwarding your audit records to ESA, contact Protegrity. Azure Application Insights contains only a sample of the audit records. The complete audit records are written to Azure Storage Account. For more information about Azure Application Insights,, refer to the Azure Application Insights 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

                                                                                                                                                            Example Audit Records

                                                                                                                                                            The following are sample audit messages:

                                                                                                                                                            Protect Success:

                                                                                                                                                            {
                                                                                                                                                                  "additional_info": {
                                                                                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                                                    "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",
                                                                                                                                                                    "ip": "127.0.0.1",
                                                                                                                                                                    "time_utc": 1635363966
                                                                                                                                                                  },
                                                                                                                                                                  "protection": {
                                                                                                                                                                    "dataelement": "deAddress",
                                                                                                                                                                    "operation": "Protect",
                                                                                                                                                                    "audit_code": 6,
                                                                                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                                                                                    "policy_user": "test_user"
                                                                                                                                                                  },
                                                                                                                                                                  process":{
                                                                                                                                                                    "name":"protect",
                                                                                                                                                                    "id":"13",
                                                                                                                                                                    "module":"coreprovider",
                                                                                                                                                                    "thread_id":"573580544",
                                                                                                                                                                    "user":"sbx_user1051",
                                                                                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                                                                                    "version":"UNKNOWN"
                                                                                                                                                                  },
                                                                                                                                                                  "client": {
                                                                                                                                                                    "ip":"169.254.62.117"
                                                                                                                                                                  },
                                                                                                                                                                  "protector": {
                                                                                                                                                                    "family": "cp",
                                                                                                                                                                    "version": "4.0.0.102",
                                                                                                                                                                    "vendor": "aws.snowflake",
                                                                                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                                                    "lambda_version":"4.0.1"
                                                                                                                                                                  },
                                                                                                                                                                  "signature": {
                                                                                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                                                    "checksum": "B324AF7C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                                                  }
                                                                                                                                                                }
                                                                                                                                                            

                                                                                                                                                            User permission denied:

                                                                                                                                                            {
                                                                                                                                                                  "additional_info": {
                                                                                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                                                    "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",
                                                                                                                                                                    "ip": "127.0.0.1",
                                                                                                                                                                    "time_utc": 1635363966
                                                                                                                                                                  },
                                                                                                                                                                  "protection": {
                                                                                                                                                                    "dataelement": "deAddress",
                                                                                                                                                                    "operation": "Protect",
                                                                                                                                                                    "audit_code": 3,
                                                                                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                                                                                    "policy_user": "test_user"
                                                                                                                                                                  },
                                                                                                                                                                  process":{
                                                                                                                                                                    "name":"protect",
                                                                                                                                                                    "id":"13",
                                                                                                                                                                    "module":"coreprovider",
                                                                                                                                                                    "thread_id":"573580544",
                                                                                                                                                                    "user":"sbx_user1051",
                                                                                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                                                                                    "version":"UNKNOWN"
                                                                                                                                                                  },
                                                                                                                                                                  "client": {
                                                                                                                                                                    "ip":"169.254.62.117"
                                                                                                                                                                  },
                                                                                                                                                                  "protector": {
                                                                                                                                                                    "family": "cp",
                                                                                                                                                                    "version": "4.0.0.102",
                                                                                                                                                                    "vendor": "aws.snowflake",
                                                                                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                                                    "lambda_version":"4.0.1"
                                                                                                                                                                  },
                                                                                                                                                                  "signature": {
                                                                                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                                                    "checksum": "A216797C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                                                  }
                                                                                                                                                                }
                                                                                                                                                            

                                                                                                                                                            Data element not found:

                                                                                                                                                            {
                                                                                                                                                                  "additional_info": {
                                                                                                                                                                    "deployment_id": "Protegrity-Protect-function-deployment-id",
                                                                                                                                                                    "description": "The data element could not be found in the policy.",
                                                                                                                                                                    "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",
                                                                                                                                                                    "ip": "127.0.0.1",
                                                                                                                                                                    "time_utc": 1635363966
                                                                                                                                                                  },
                                                                                                                                                                  "protection": {
                                                                                                                                                                    "dataelement": "deAddress",
                                                                                                                                                                    "operation": "Protect",
                                                                                                                                                                    "audit_code": 2,
                                                                                                                                                                    "datastore": "SAMPLE_POLICY",
                                                                                                                                                                    "policy_user": "test_user"
                                                                                                                                                                  },
                                                                                                                                                                  process":{
                                                                                                                                                                    "name":"protect",
                                                                                                                                                                    "id":"13",
                                                                                                                                                                    "module":"coreprovider",
                                                                                                                                                                    "thread_id":"573580544",
                                                                                                                                                                    "user":"sbx_user1051",
                                                                                                                                                                    "platform":"\"Linux_x64\"",
                                                                                                                                                                    "version":"UNKNOWN"
                                                                                                                                                                  },
                                                                                                                                                                  "client": {
                                                                                                                                                                    "ip":"169.254.62.117"
                                                                                                                                                                  },
                                                                                                                                                                  "protector": {
                                                                                                                                                                    "family": "cp",
                                                                                                                                                                    "version": "4.0.0.102",
                                                                                                                                                                    "vendor": "aws.snowflake",
                                                                                                                                                                    "datastore":"SAMPLE_POLICY",
                                                                                                                                                                    "pcc_version": "4.0.0.9",
                                                                                                                                                                    "core_version": "2.1.4+0.g93016.2.1",
                                                                                                                                                                    "lambda_version":"4.0.1"
                                                                                                                                                                  },
                                                                                                                                                                  "signature": {
                                                                                                                                                                    "key_id": "95f5a194-b0a4-4351-a",
                                                                                                                                                                    "checksum": "AF09217C56944D91C47847A77C0367C594C0B948E7E75654B889571BD4F60A71"
                                                                                                                                                                  }
                                                                                                                                                                }
                                                                                                                                                            

                                                                                                                                                            2.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.2.8 - Upgrading To The Latest Version

                                                                                                                                                            Instructions for upgrading the protector.

                                                                                                                                                              Upload Deployment Artifacts

                                                                                                                                                              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.

                                                                                                                                                              After downloading the deployment package from the Protegrity Portal, go to Azure console. Navigate to the storage account that was previously created to upload deployment artifacts (see: Agent Policy Blob Container).

                                                                                                                                                              Upload the following artifacts to the Azure storage container:

                                                                                                                                                              • protegrity-protect-<version>.zip
                                                                                                                                                              • protegrity-agent-<version>.zip

                                                                                                                                                              After upload is complete, note the blob url for each file. Blob URL may be found in the blob properties.

                                                                                                                                                              Record Blob URL values below

                                                                                                                                                              New Protect Function Blob URL: ___________________

                                                                                                                                                              New Log Forwarder Function Blob URL: ___________________

                                                                                                                                                              New Agent Function Blob URL: ___________________

                                                                                                                                                              Perform the following steps to upgrade the Policy Agent, Protect, and Log Forwarder Functions separately.

                                                                                                                                                              Disable Protegrity Agent Function Timer Trigger

                                                                                                                                                              App Function Timer Trigger is used to periodically run Protegrity Agent Function to synchronize policy from ESA. The trigger must be disabled temporarily for the time of the upgrade process.

                                                                                                                                                              Follow the steps below to disable the Agent Function Timer Trigger.

                                                                                                                                                              1. From Azure Console, go to Function App service and select Protegrity Agent Function.

                                                                                                                                                              2. Navigate to Overview.

                                                                                                                                                              3. The functions list should contain agent function with Trigger type Timer and status Enabled.

                                                                                                                                                              4. Click on the three dots in the same row as the agent function. Then select Disable.

                                                                                                                                                              Upgrading Policy Agent Function

                                                                                                                                                              Upgrade Policy Agent Runtime Package

                                                                                                                                                              1. From Azure console, navigate to Function App service and select agent function app. Navigate to Settings > Environment variables.

                                                                                                                                                              2. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                              3. Save existing URL. You may need it to rollback upgrade.

                                                                                                                                                                WEBSITE_RUN_FROM_PACKAGE: _______________

                                                                                                                                                              4. Replace URL with New Agent Function Blob URL.

                                                                                                                                                              5. Click Apply then select Apply and Confirm to finalize.

                                                                                                                                                              6. Using menu on the left, navigate to Overview. Stop the function using Stop button at the top. Then start it again.

                                                                                                                                                              7. In the next section the Agent function will be tested to make sure it works as expected.

                                                                                                                                                              8. (Optional) If you need to rollback to older version of Agent Function, replace WEBSITE_RUN_FROM_PACKAGE with URL recorded in previous steps.

                                                                                                                                                              Disable Agent Policy Deployment and Test Policy Agent Function

                                                                                                                                                              Policy agent generates a backup of pulled policy when triggered. The policy will then be deployed to Protect and Log Forwarder functions. Deployment of policies to functions should be disabled during the upgrade process.

                                                                                                                                                              Follow the steps below to disable policy deployment:

                                                                                                                                                              1. From Azure Console, navigate to Policy Agent Function App

                                                                                                                                                              2. Navigate to Settings > Environment variables.

                                                                                                                                                              3. set DISABLE_DEPLOY to 1 if it is not already set.

                                                                                                                                                              4. Stop/Start the Agent function. It may take a few minutes for the function to start.

                                                                                                                                                              Test/Run Policy Agent Function to Generate Latest Policy

                                                                                                                                                              Follow the steps below to run the upgraded policy agent to refresh latest backup policy. Record the latest backup policy URL for later upgrade steps.

                                                                                                                                                              1. From Azure Console, navigate to the Policy Agent Function App

                                                                                                                                                              2. Navigate to the agent Test/Run feature as described in Test Agent Function Installation.

                                                                                                                                                              3. Run the policy agent. Verify the agent executed successfully by carefully inspecting the logs.

                                                                                                                                                              4. Use the following Azure Blob url from your Policy Agent Function Settings > Environment variables

                                                                                                                                                                AZURE_POLICY_BLOB_URL
                                                                                                                                                                

                                                                                                                                                                upgraded_agent_policy_blob_url: _______________________

                                                                                                                                                              Upgrading Protect Function

                                                                                                                                                              Diagram below illustrates upgrade steps.

                                                                                                                                                              Azure Protect Function Upgrade Steps

                                                                                                                                                              Create Staging Deployment Slot (Protector)

                                                                                                                                                              Creating new deployment slot allows updating the function without interruptions to the existing traffic.

                                                                                                                                                              1. From Azure console, navigate to Function App service and select the Protect Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                                              2. Click Add slot. Specify slot name.

                                                                                                                                                              3. Click Add. Wait for the slot to be created.

                                                                                                                                                              4. After the slot is added, select Close to close the dialog box.

                                                                                                                                                              5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done and tested, you will swap staging slot with production slot.

                                                                                                                                                              6. Click on the new deployment slot. This will open the newly created replica of Cloud Protect Function.

                                                                                                                                                              7. Copy the function URL from the overview window.

                                                                                                                                                                Staging Protect Function URL: ________________

                                                                                                                                                              8. Navigate to Identity section under Settings.

                                                                                                                                                              9. If your installation utilizes System Assigned Identity:

                                                                                                                                                                1. Select System Assigned tab and switch Status On. Click Save.

                                                                                                                                                                2. This will generate the Object ID for the newly deployed function in the deployment slot.

                                                                                                                                                                3. Add Role Assignments to the identity as described in section Function System-Assigned Managed Identity

                                                                                                                                                                4. Use the Object ID to update Key Vault policy to allow function in the deployment slot to use policy encryption key. See Protect Function Key Vault Access Policies for instructions how to update Key Vault policy.

                                                                                                                                                              10. If your installation utilizes User Assigned Identity:

                                                                                                                                                                1. Select User Assigned tab

                                                                                                                                                                2. Select Add. Choose the identity in use on the production function, then complete by selecting Add again.

                                                                                                                                                              11. Navigate to App Keys section from the menu on the left. Record default key value under Host Keys section.

                                                                                                                                                                Staging Protect Function Default Host Key: ________________

                                                                                                                                                              12. Navigate to the staging Function App Settings > Environment variables

                                                                                                                                                              13. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                              14. Replace value with New Protect Function Blob URL.

                                                                                                                                                              15. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template for the newly deployed log forwarder.

                                                                                                                                                              16. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                              17. Click Apply, then Apply to finalize.

                                                                                                                                                              Load Production Policy and Test New Protect Function In Staging

                                                                                                                                                              1. Navigate to the new staging Protect function Settings > Environment variables

                                                                                                                                                              2. Set AZURE_POLICY_BLOB_URL environment variable to the upgraded_agent_policy_blob_url value recorded in previous steps.

                                                                                                                                                              3. Start/Stop the protect function.

                                                                                                                                                              4. Test New Protect Function in staging. You can use curl command below, replacing Staging Protect Function URL and Staging Protect Function Default Host Key with values recorded in previous section.

                                                                                                                                                              curl -X POST "<Staging Protect Function URL>/api/Protect" -k \
                                                                                                                                                              -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 'x-functions-key: <Staging Protect Function Default Host Key>' \
                                                                                                                                                              -H 'Content-Type: application/json' \
                                                                                                                                                              -d '{
                                                                                                                                                                "data": [
                                                                                                                                                                  ["0", "UtfVk UHgcD!"]
                                                                                                                                                                ]
                                                                                                                                                              }'
                                                                                                                                                              
                                                                                                                                                              curl -X POST "<Protect Function URL>/api/v1/protect" -k \
                                                                                                                                                              -H 'x-functions-key: <Protect Function app key>' \
                                                                                                                                                              -H 'Content-Type: application/json' \
                                                                                                                                                              -d '{
                                                                                                                                                                "data": ["test"],
                                                                                                                                                                "user": "test",
                                                                                                                                                                "data_element": "test"
                                                                                                                                                              }'
                                                                                                                                                              

                                                                                                                                                              Finalize Protector upgrade

                                                                                                                                                              Upgraded Protect Function can now be swapped in to production deployment slot to serve production traffic.

                                                                                                                                                              1. Go to your main Protect Function.

                                                                                                                                                              2. Select deployment slots.

                                                                                                                                                              3. Select Swap.

                                                                                                                                                              4. Select staging Protect Function slot as source and production Function as target.

                                                                                                                                                              5. Click swap and wait until the functions are swapped.

                                                                                                                                                              6. If you need to rollback swap the application slots again.

                                                                                                                                                              Upgrading Log Forwarder Function

                                                                                                                                                              Disable Log Forwarder Event Hub Trigger

                                                                                                                                                              Disabling the Event Hub trigger will prevent audit log delivery during the upgrade process. This reduces the chance for any duplicate or lost audit logs. Later steps will indicate when this trigger may be re-enabled.

                                                                                                                                                              Follow the steps below to disable the Event Hub trigger:

                                                                                                                                                              1. From Azure Console, go to Function App service and select Protegrity Log Forwarder Function.

                                                                                                                                                              2. Navigate to Overview.

                                                                                                                                                              3. The functions list should contain AuditLogForwarder function with Trigger type Event Hub and Status Enabled.

                                                                                                                                                              4. Click on the three dots in the same row as the AuditLogForwarder function. Then select Disable.

                                                                                                                                                              Create Staging Deployment Slot (Log Forwarder)

                                                                                                                                                              Creating new deployment slot allows updating the function such that it may easily be rolled back. Log Forwarder Function will be disabled during the upgrade process. Logs generated during this time will be processed once Log Forwarder is re-enabled

                                                                                                                                                              1. From Azure console, navigate to Function App service and select the Log Forwarder Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                                              2. Click Add slot. Specify slot name.

                                                                                                                                                              3. Click Add. Wait for the slot to be created.

                                                                                                                                                              4. After the slot is added, select Close to close the dialog box.

                                                                                                                                                              5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done, you will swap staging slot with production slot.

                                                                                                                                                              6. Click on the new deployment slot. This will open the newly created replica of Log Forwarder Function.

                                                                                                                                                              7. Navigate to the staging Function App environment variable settings Settings > Environment variables

                                                                                                                                                              8. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                              9. Replace value with New Log Forwarder Function Blob URL. Click Apply.

                                                                                                                                                              10. Click on AZURE_POLICY_BLOB_URL configuration entry.

                                                                                                                                                              11. Replace value with upgraded_agent_policy_blob_url. Click Apply.

                                                                                                                                                              12. Click Apply and Confirm to push the configuration changes.

                                                                                                                                                              Finalize Log Forwarder Upgrade

                                                                                                                                                              Upgraded Log Forwarder Function will be swapped into production deployment slot to serve production traffic and re-enabled,

                                                                                                                                                              Swap Upgraded Function Slot to Production

                                                                                                                                                              1. Go to your main Log Forwarder Function.

                                                                                                                                                              2. Select deployment slots.

                                                                                                                                                              3. Select Swap.

                                                                                                                                                              4. Select staging Log Forwarder Function slot as source and current Function as target.

                                                                                                                                                              5. Click Start Swap and wait until the functions are swapped.

                                                                                                                                                              6. If you need to rollback, swap the application slots again.

                                                                                                                                                              Re-Enable Log Forwarder Function Trigger

                                                                                                                                                              1. Go to your main Log Forwarder Function.

                                                                                                                                                              2. Navigate to environment variable settings Settings > Environment variables

                                                                                                                                                              3. Click on AzureWebJobs.AuditLogForwarder.Disabled configuration entry.

                                                                                                                                                              4. Replace value with false. Click Apply then Apply and Confirm to finalize.

                                                                                                                                                              Re-enable Policy Agent Deployment Setting

                                                                                                                                                              Skip this step if changes were not made to the DISABLE_DEPLOY setting in previous upgrade steps

                                                                                                                                                              1. Navigate to Agent function Settings > Environment variables

                                                                                                                                                              2. Set DISABLE_DEPLOY to 0.

                                                                                                                                                              3. apply changes and restart the Agent Function App

                                                                                                                                                              Enable Protegrity Agent Function Timer Trigger

                                                                                                                                                              If the Agent Function Timer Trigger was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to enable Policy Agent Timer Trigger.

                                                                                                                                                              1. Navigate back to Protegrity Agent Function.

                                                                                                                                                              2. Select Overview.

                                                                                                                                                              3. Click on the three dots in the same row as the agent function in the list of functions. Then select Enable.

                                                                                                                                                              2.2.9 - Known Limitations

                                                                                                                                                              Known product limitations.
                                                                                                                                                              • FPE is supported only for ASCII values.
                                                                                                                                                              • Only the protect and unprotect operations are supported. The reprotect operation is not currently supported.

                                                                                                                                                              2.2.10 - Appendices

                                                                                                                                                              Additional references for the protector.

                                                                                                                                                              2.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.2.10.2 - Configuring Regular Expression to Extract Policy Username

                                                                                                                                                                Example configurations for user extraction with regular expressions

                                                                                                                                                                Configuring Regular Expression to Extract Policy Username

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

                                                                                                                                                                • USERNAME_REGEX 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

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                ^(.*)[@/].*$
                                                                                                                                                                

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                juliet.snow

                                                                                                                                                                2.2.10.3 - Sample Snowflake External Functions for Protegrity Integration

                                                                                                                                                                Explore example implementations of secure Snowflake external functions for Protegrity integration

                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                 

                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                 

                                                                                                                                                                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 URL>/api/Protect';  
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                
                                                                                                                                                                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 URL>/api/Protect';
                                                                                                                                                                

                                                                                                                                                                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.

                                                                                                                                                                2.2.10.4 - ARM Template Installation - Required Permissions

                                                                                                                                                                Outlines the required permissions to deploy Cloud Protect with provided ARM templates

                                                                                                                                                                ARM Template Installation - Required Permissions

                                                                                                                                                                Permissions below are required to install Protegrity service using ARM template.

                                                                                                                                                                All permissions in the table must be granted with the Resource group scope.

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.Insights/components/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.OperationalInsights/workspaces/read
                                                                                                                                                                

                                                                                                                                                                Read access to monitoring data and settings

                                                                                                                                                                Monitoring Reader

                                                                                                                                                                Microsoft.Insights/components/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.OperationalInsights/workspaces/write
                                                                                                                                                                

                                                                                                                                                                Write and manage access to monitoring data and settings

                                                                                                                                                                Monitoring Contributor

                                                                                                                                                                Microsoft.Web/serverFarms/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/sites/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/sites/host/listkeys/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/serverFarms/join/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/register/action
                                                                                                                                                                

                                                                                                                                                                Write and manage access to web apps

                                                                                                                                                                Website Contributor

                                                                                                                                                                Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.ManagedIdentity/userAssignedIdentities/read
                                                                                                                                                                

                                                                                                                                                                Manage and assign managed identities

                                                                                                                                                                Managed Identity Operator

                                                                                                                                                                Microsoft.Resources/deployments/validate/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/operationStatuses/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/read
                                                                                                                                                                

                                                                                                                                                                Manage and validate deployments

                                                                                                                                                                Deployment Contributor

                                                                                                                                                                         

                                                                                                                                                                Log Forwarder service ARM deployment requires additional permissions below:

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.EventHub/namespaces/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.EventHub/namespaces/eventhubs/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.EventHub/namespaces/networkrulesets/write
                                                                                                                                                                

                                                                                                                                                                Allow for the creation, update, and deletion of Event Hub namespaces, event hubs within those namespaces, and their network rule sets, enabling full management of Event Hub resources. Note: These permissions are only required when deploying new event Hub.

                                                                                                                                                                Event Hubs Contributor

                                                                                                                                                                Microsoft.EventHub/namespaces/read
                                                                                                                                                                

                                                                                                                                                                Read monitoring data and metrics, including Event Hub namespace data.

                                                                                                                                                                Monitoring Reader

                                                                                                                                                                  

                                                                                                                                                                      

                                                                                                                                                                The additional permissions listed below are required when API management is part of the deployment.

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.ApiManagement/service/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/diagnostics/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/operations/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/operations/policies/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/backends/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/loggers/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/policies/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/diagnostics/write
                                                                                                                                                                

                                                                                                                                                                Create or update API Management service instances, APIs, diagnostics, API operations, operation policies, backends, loggers, tenant policies, and API diagnostics.

                                                                                                                                                                API Management Service Contributor

                                                                                                                                                                Microsoft.ApiManagement/service/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/operationResults/read
                                                                                                                                                                

                                                                                                                                                                Read metadata for API Management service instances and get the status of long-running operations.

                                                                                                                                                                API Management Service Reader

                                                                                                                                                                2.2.10.5 - Associating ESA Data Store With Cloud Protect Agent

                                                                                                                                                                Configure ESA data store for Policy Agent

                                                                                                                                                                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
                                                                                                                                                                falseyes20.75.43.207
                                                                                                                                                                falseno20.75.43.207
                                                                                                                                                                169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                                                                                                                                                                trueno34.230.42.110
                                                                                                                                                                falseyes34.230.42.110
                                                                                                                                                                falseno34.230.42.110

                                                                                                                                                                2.3 -

                                                                                                                                                                Agent Function Outbound IP address

                                                                                                                                                                Agent Function App IP addresses may be useful for configuring ESA policy store and allowing traffic between Agent and ESA.

                                                                                                                                                                To obtain the list of Outbound IP addresses:

                                                                                                                                                                1. From Azure console navigate to Function App, select the Agent Function App.
                                                                                                                                                                2. Select Settings > Networking.
                                                                                                                                                                3. Under Outbound traffic configuration, select Show More next to Outbound addresses

                                                                                                                                                                2.4 -

                                                                                                                                                                Configure Function

                                                                                                                                                                Agent Function must be configured with parameters recorded in steps above.

                                                                                                                                                                To configure Function:

                                                                                                                                                                1. Open Function App service from the Azure console. Select the Function App created for policy agent in previous steps.

                                                                                                                                                                2. Navigate to Settings > Environment variables .

                                                                                                                                                                3. On the App Settings pane, click on Show values to reveal all configuration values

                                                                                                                                                                4. To modify multiple parameters, click the pencil icon Advanced edit at the top. Alternatively you may click on the environment variable name to edit single values.

                                                                                                                                                                5. Modify parameters according to the table below. If configuration has a default value you don’t have to change it

                                                                                                                                                                Parameter

                                                                                                                                                                Notes

                                                                                                                                                                AZURE_KEY_VAULT_NAME

                                                                                                                                                                Key Vault

                                                                                                                                                                AZURE_POLICY_BLOB_URL

                                                                                                                                                                URL of the Azure Blob file which is used to store Protegrity security policies for protector consumption. See ProtectFuncPolicyBlobUrl in Protect Function Policy Blob

                                                                                                                                                                AZURE_RETAIN_POLICY_BLOB

                                                                                                                                                                The amount of policy backups to retain. Default: 10. Allowed values: -1, >1. Value of -1 will disable cleanup of backup policies.

                                                                                                                                                                PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                                                Protegrity function to be updated when new policy is deployed. Provide a comma separated list of protect function app names for updating multiple protectors:

                                                                                                                                                                Protegrity-Protect-func1,Protegrity-Protect-func2
                                                                                                                                                                

                                                                                                                                                                PTY_ESA_IP

                                                                                                                                                                ESA Server

                                                                                                                                                                AZURE_ESA_CREDENTIALS_SECRET_ID

                                                                                                                                                                ESA Credentials In Azure Key Vault

                                                                                                                                                                AZURE_ENCRYPTION_KEY_ID

                                                                                                                                                                Create Policy Encryption Key

                                                                                                                                                                PEP_CONFIG_CASE_SENSITIVE

                                                                                                                                                                Default: No Allowed values: yes/no

                                                                                                                                                                Specifies whether policy usernames should be case sensitive

                                                                                                                                                                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

                                                                                                                                                                PEP_CONFIG_EMPTY_STRING

                                                                                                                                                                Default: empty Allowed values: null empty

                                                                                                                                                                Determines outcome of empty value operation. For example, (un)protect(’’) -> null (un)protect(’’) ->

                                                                                                                                                                DISABLE_DEPLOY

                                                                                                                                                                Default: 0

                                                                                                                                                                POLICY_PULL_TIMEOUT

                                                                                                                                                                Default: 20s

                                                                                                                                                                ESA_CONNECTION_TIMEOUT

                                                                                                                                                                Default: 5s

                                                                                                                                                                LOG_LEVEL

                                                                                                                                                                Default: INFO. Allowed values: DEBUG, INFO, WARNING, ERROR

                                                                                                                                                                AZURE_SUBSCRIPTION_ID

                                                                                                                                                                Default: Same as ARM Resource group

                                                                                                                                                                AZURE_RESOURCE_GROUP_NAME

                                                                                                                                                                Default: Same as ARM Resource group

                                                                                                                                                                POLICY_DOWNLOAD_CRON_EXPRESSION

                                                                                                                                                                Describes how often Agent Function will run Default: 0 0 * * * * (Every hour)

                                                                                                                                                                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.

                                                                                                                                                                PTY_ESA_CREDENTIALS_FUNCTION

                                                                                                                                                                Instead of supplying AZURE_ESA_CREDENTIALS_SECRET_ID environment variable, ESA credentials can be provided by a custom Azure Function App. Provide a value recorded for EsaCredentialsFnUrl

                                                                                                                                                                PTY_ESA_CREDENTIALS_FUNCTION_KEY

                                                                                                                                                                When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key. Provide a value recorded for EsaCredentialsFnKey

                                                                                                                                                                PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET

                                                                                                                                                                When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using function app key stored in Azure Key Vault. Provide a value recorded for EsaCredentialsFnKeySecretName

                                                                                                                                                                PTY_ESA_CREDENTIALS_FUNCTION_SCOPE

                                                                                                                                                                When ESA credentials are provided by a custom Azure Function App, Policy Agent can request credentials using its own identity. Provide a value here recorded for EsaCredentialsFnAppIdUri appended with /.default to create authentication scope. Review Microsoft identity platform default scope

                                                                                                                                                                PTY_SYNC_DATASTORE

                                                                                                                                                                Name of the target datastore

                                                                                                                                                                PTY_DATASTORE_KEY

                                                                                                                                                                The export key is the public part of an asymmetric key pair created in a Create Policy Encryption 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.

                                                                                                                                                                1. Click Apply at the bottom of the screen and then Confirm to save the changes.

                                                                                                                                                                Parameter

                                                                                                                                                                Notes

                                                                                                                                                                AZURE_CLIENT_ID

                                                                                                                                                                Sets the Managed Identity Client ID for Function App runtime. System-Assigned Identity is used when variable is not set.

                                                                                                                                                                APPLICATIONINSIGHTS_AUTHENTICATION_STRING

                                                                                                                                                                Define identity for Application Insights access. Managed Identity Client ID is provided to this setting with Function App Managed Identity ARM template parameter. See the corresponding Azure AD Authentication documentation: Azure AD authentication

                                                                                                                                                                APPLICATIONINSIGHTS_CONNECTION_STRING

                                                                                                                                                                Connection String for Application Insights instance. See the corresponding Azure Connection String documentation: Connection strings

                                                                                                                                                                FUNCTIONS_EXTENSION_VERSION

                                                                                                                                                                Azure Functions extension version

                                                                                                                                                                FUNCTIONS_WORKER_RUNTIME

                                                                                                                                                                Runtime of the function

                                                                                                                                                                WEBSITE_RUN_FROM_PACKAGE

                                                                                                                                                                URL to the zip file in blob storage with function runtime source

                                                                                                                                                                WEBSITE_RUN_FROM_PACKAGE_BLOB_MI_RESOURCE_ID

                                                                                                                                                                Managed Identity used to load function runtime source

                                                                                                                                                                AzureWebJobsStorage__blobServiceUri

                                                                                                                                                                URL of the storage account which hosts the blob identified in WEBSITE_RUN_FROM_PACKAGE

                                                                                                                                                                2.5 -

                                                                                                                                                                Create Policy Encryption Key

                                                                                                                                                                Create a policy encryption key.

                                                                                                                                                                To create policy encryption key:

                                                                                                                                                                1. From Azure console, navigate to Key Vaults and select Key Vault created in Key Vault.

                                                                                                                                                                2. Under Objects, select Keys.

                                                                                                                                                                3. Click Generate/Import.

                                                                                                                                                                4. Specify the following:

                                                                                                                                                                  a. Key name for the Name field.

                                                                                                                                                                  b. RSA for Key type.

                                                                                                                                                                  c. 2048 for RSA key size.

                                                                                                                                                                  d. Set Enabled toggle to Yes.

                                                                                                                                                                5. Select Create.

                                                                                                                                                                6. Click on the key name after creation is complete, then click on the key identifier row under CURRENT VERSION.

                                                                                                                                                                7. Copy the full URL value of Key Identifier. Record it for later use:

                                                                                                                                                                  Policy Encryption Key ID (PolicyEncryptionKey): _________________

                                                                                                                                                                2.6 -

                                                                                                                                                                Certificates on ESA

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

                                                                                                                                                                In case ESA is configured with publicly signed certificates, this section can be skipped since the agent 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 variable in the Policy Agent Function Configuration section Configure Function

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

                                                                                                                                                                2.7 -

                                                                                                                                                                Creating ESA Credentials

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

                                                                                                                                                                ESA Credentials In Azure Key Vault

                                                                                                                                                                Policy Agent Function uses Key Vault as secure store for sensitive information like ESA username and password.

                                                                                                                                                                Create ESA credentials secrets:

                                                                                                                                                                1. Navigate to Key Vault.

                                                                                                                                                                2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                3. Select Manual, then type in valid json as shown in the example for Secret value.

                                                                                                                                                                  {"username": "<policy_export_user>", "password": "<password>"}
                                                                                                                                                                  
                                                                                                                                                                4. Select Create.

                                                                                                                                                                5. Navigate to the secret details in Key Vault by selecting the newly created secret.

                                                                                                                                                                6. Inspect the current secret version properties by selecting the current version.

                                                                                                                                                                7. Copy the Secret Identifier value. For example https://<myvault>.vault.azure.net/secrets/<mysecret>/abcdefgxyz8edef595adaehij0d99123.

                                                                                                                                                                8. Record the Secret Identifier for later use.

                                                                                                                                                                ESA Credentials From Custom Azure Function App

                                                                                                                                                                Policy Agent Function requests ESA username and password from a custom Azure Function App, further referred to as ESA Credentials function. This method may be used to get the username and password from external vaults.

                                                                                                                                                                There are four options for configuring Policy Agent authorization with ESA Credentials function: Option 1, Option 2, Option 3 and Option 4. Only one option is expected to be configured at a time.

                                                                                                                                                                Create ESA credentials function:

                                                                                                                                                                1. Create Azure HTTP triggered ESA Credentials function using any supported runtime.

                                                                                                                                                                  a. There is no input needed.

                                                                                                                                                                  b. The function must accept an HTTP POST request.

                                                                                                                                                                  c. The function must return the following response schema

                                                                                                                                                                  ```
                                                                                                                                                                  response: 
                                                                                                                                                                  type: json object
                                                                                                                                                                    properties: 
                                                                                                                                                                      username: string 
                                                                                                                                                                      password: string  
                                                                                                                                                                  ```
                                                                                                                                                                  
                                                                                                                                                                  For example,
                                                                                                                                                                  
                                                                                                                                                                  ```
                                                                                                                                                                  {"username": "admin", "password": "Password1234"} 
                                                                                                                                                                  ```
                                                                                                                                                                  
                                                                                                                                                                2. Configure Policy Agent to use ESA Credentials function app.

                                                                                                                                                                  a. Navigate to HTTP triggered function to open ‘Code + Test’ page.

                                                                                                                                                                  b. Under ‘Code + Test’ tab on ‘Code + Test’ page select ‘Resource JSON’.

                                                                                                                                                                  c. In ‘Resource JSON’ blade record the value of ‘invoke_url_template’ property.

                                                                                                                                                                  **'invoke_url_template'** property is located towards the bottom of resource json.
                                                                                                                                                                  
                                                                                                                                                                  URL must be in the form of 'https://[function-app-name].azurewebsites.[net|us]/api/[http-trigger-name]'.
                                                                                                                                                                  
                                                                                                                                                                  **ESA Credentials function URL (EsaCredentialsFnUrl):__________**
                                                                                                                                                                  

                                                                                                                                                                  d. Navigate to Policy Agent function app.

                                                                                                                                                                  e. Expand Settings menu item.

                                                                                                                                                                  f. Select Environment Variables menu item.

                                                                                                                                                                  g. Click Add button.

                                                                                                                                                                  h. For Name use PTY_ESA_CREDENTIALS_FUNCTION.

                                                                                                                                                                  i. For Value use ESA Credentials function URL (EsaCredentialsFnUrl) recorded in previous steps.

                                                                                                                                                                  j. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                  k. Hit Apply in App Settings tab.

                                                                                                                                                                3. Configure Authorization Option 1: Function Key Option 2: Key Vault Option 3: System-assigned Identity Option 4: User-assigned Identity

                                                                                                                                                                Authorization Option 1: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from environment variables.
                                                                                                                                                                1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                                  Review Azure documentation on how to accomplish this.

                                                                                                                                                                2. Navigate to ESA Credentials function app.

                                                                                                                                                                3. Expand Functions menu item.

                                                                                                                                                                4. Select App Keys.

                                                                                                                                                                5. Record default key value.

                                                                                                                                                                  ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                                6. Navigate to Policy Agent function app.

                                                                                                                                                                7. Expand Settings menu item.

                                                                                                                                                                8. Select Environment Variables menu item.

                                                                                                                                                                9. Click Add button.

                                                                                                                                                                10. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY.

                                                                                                                                                                11. For Value use ESA Credentials function key (EsaCredentialsFnKey) recorded in previous steps.

                                                                                                                                                                12. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                13. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 2: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from Azure Key Vault.
                                                                                                                                                                1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                                  Review Azure documentation on how to accomplish this.

                                                                                                                                                                2. Navigate to ESA Credentials function app.

                                                                                                                                                                3. Expand Functions menu item.

                                                                                                                                                                4. Select App Keys.

                                                                                                                                                                5. Record default key value.

                                                                                                                                                                  ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                                6. Navigate to Key Vault.

                                                                                                                                                                7. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                8. Select Manual, type in secret name and use ESA Credentials function key value recorded in previous steps (EsaCredentialsFnKey) for Secret value.

                                                                                                                                                                9. Select Create.

                                                                                                                                                                10. Record Key Vault secret name.

                                                                                                                                                                  ESA Credentials function key secret name (EsaCredentialsFnKeySecretName):_______________

                                                                                                                                                                11. Navigate to Policy Agent function app.

                                                                                                                                                                12. Expand Settings menu item.

                                                                                                                                                                13. Select Environment Variables menu item.

                                                                                                                                                                14. Click Add button.

                                                                                                                                                                15. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET.

                                                                                                                                                                16. For Value use ESA Credentials function key secret name (EsaCredentialsFnKeySecretName) recorded in previous steps.

                                                                                                                                                                17. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                18. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 3: Configure ESA Credentials authentication provider to authorize Policy Agent system-assigned identity.
                                                                                                                                                                1. Navigate to Policy Agent function app

                                                                                                                                                                2. Expand Settings menu item

                                                                                                                                                                3. Select Identity

                                                                                                                                                                4. Select System assigned tab

                                                                                                                                                                5. Status should already be On

                                                                                                                                                                  Other Status indicates Policy Agent was installed without system-assigned identity. Before proceeding any further you need to either install Policy Agent with system-assigned identity or follow Option 4 which describes configuration steps for Policy Agent installed with user-assigned managed identity.

                                                                                                                                                                6. Copy Object (principal) ID

                                                                                                                                                                7. Navigate to ESA Credentials function app

                                                                                                                                                                8. Expand Settings menu item

                                                                                                                                                                9. Select Authentication

                                                                                                                                                                10. Select Add identity provider

                                                                                                                                                                  Review related Microsoft documentation

                                                                                                                                                                11. Select Microsoft in identity provider dropdown

                                                                                                                                                                12. For App registration type provide details of your choice

                                                                                                                                                                13. For Issuer URL accept the default value

                                                                                                                                                                14. For Client application requirement select Allow requests from any application

                                                                                                                                                                  Access will be limited to only the Policy Agent identity in the next step

                                                                                                                                                                15. For Identity requirement select Allow requests from specific identities

                                                                                                                                                                16. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                                17. For Restrict access select Require authentication

                                                                                                                                                                18. For Unauthenticated requests select HTTP 401 Unauthorized: recommended for APIs

                                                                                                                                                                19. Check Token store

                                                                                                                                                                20. Select Add

                                                                                                                                                                21. Click OK to apply constraint

                                                                                                                                                                22. Click Save

                                                                                                                                                                23. Navigate to Application of Microsoft identity provider

                                                                                                                                                                  A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                                24. Expand Manage menu item

                                                                                                                                                                25. Select Expose an API

                                                                                                                                                                26. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                                27. Record Application ID URI of identity provider

                                                                                                                                                                  ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                                28. Navigate to Policy Agent function app.

                                                                                                                                                                29. Expand Settings menu item.

                                                                                                                                                                30. Select Environment Variables menu item.

                                                                                                                                                                31. Click Add button.

                                                                                                                                                                32. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                                33. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                                  Review Microsoft identity platform default scope

                                                                                                                                                                34. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                35. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 4: Configure ESA Credentials authentication provider to authorize Policy Agent user-assigned identity.
                                                                                                                                                                1. Navigate to Policy Agent function app

                                                                                                                                                                2. Expand Settings menu item

                                                                                                                                                                3. Select Identity

                                                                                                                                                                4. Select User assigned tab

                                                                                                                                                                  User-assigned identity should already be provided. Missing user-assigned identity indicates Policy Agent was installed without user-assigned identity. Before proceeding any further you need to either install Policy Agent with user-assigned identity or follow Option 3 which describes configuration steps for Policy Agent installed with system-assigned managed identity.

                                                                                                                                                                5. Copy Client ID

                                                                                                                                                                6. Copy Object (principal) ID

                                                                                                                                                                7. Navigate to ESA Credentials function app

                                                                                                                                                                8. Expand Settings menu item

                                                                                                                                                                9. Select Authentication

                                                                                                                                                                10. Select Add identity provider

                                                                                                                                                                  Review related Microsoft documentation

                                                                                                                                                                11. Select Microsoft in identity provider dropdown

                                                                                                                                                                12. For App registration type provide details of your choice

                                                                                                                                                                13. For Issuer URL accept the default value

                                                                                                                                                                14. For Client application requirement select Allow requests from specific client applications

                                                                                                                                                                15. For Allowed client applications add Client ID copied in previous step

                                                                                                                                                                16. Click OK to apply constraint

                                                                                                                                                                17. For Identity requirement select Allow requests from specific identities

                                                                                                                                                                18. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                                19. Click OK to apply constraint

                                                                                                                                                                20. Click Save

                                                                                                                                                                21. Navigate to Application of Microsoft identity provider

                                                                                                                                                                  A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                                22. Expand Manage menu item

                                                                                                                                                                23. Select Expose an API

                                                                                                                                                                24. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                                25. Record Application ID URI of identity provider

                                                                                                                                                                  ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                                26. Navigate to Policy Agent function app.

                                                                                                                                                                27. Expand Settings menu item.

                                                                                                                                                                28. Select Environment Variables menu item.

                                                                                                                                                                29. Click Add button.

                                                                                                                                                                30. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                                31. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                                  Review Microsoft identity platform default scope

                                                                                                                                                                32. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                33. Hit Apply in App Settings tab.

                                                                                                                                                                2.8 -

                                                                                                                                                                ESA Credentials From Custom Azure Function App

                                                                                                                                                                Policy Agent Function requests ESA username and password from a custom Azure Function App, further referred to as ESA Credentials function. This method may be used to get the username and password from external vaults.

                                                                                                                                                                There are four options for configuring Policy Agent authorization with ESA Credentials function: Option 1, Option 2, Option 3 and Option 4. Only one option is expected to be configured at a time.

                                                                                                                                                                Create ESA credentials function:

                                                                                                                                                                1. Create Azure HTTP triggered ESA Credentials function using any supported runtime.

                                                                                                                                                                  a. There is no input needed.

                                                                                                                                                                  b. The function must accept an HTTP POST request.

                                                                                                                                                                  c. The function must return the following response schema

                                                                                                                                                                  ```
                                                                                                                                                                  response: 
                                                                                                                                                                  type: json object
                                                                                                                                                                    properties: 
                                                                                                                                                                      username: string 
                                                                                                                                                                      password: string  
                                                                                                                                                                  ```
                                                                                                                                                                  
                                                                                                                                                                  For example,
                                                                                                                                                                  
                                                                                                                                                                  ```
                                                                                                                                                                  {"username": "admin", "password": "Password1234"} 
                                                                                                                                                                  ```
                                                                                                                                                                  
                                                                                                                                                                2. Configure Policy Agent to use ESA Credentials function app.

                                                                                                                                                                  a. Navigate to HTTP triggered function to open ‘Code + Test’ page.

                                                                                                                                                                  b. Under ‘Code + Test’ tab on ‘Code + Test’ page select ‘Resource JSON’.

                                                                                                                                                                  c. In ‘Resource JSON’ blade record the value of ‘invoke_url_template’ property.

                                                                                                                                                                  **'invoke_url_template'** property is located towards the bottom of resource json.
                                                                                                                                                                  
                                                                                                                                                                  URL must be in the form of 'https://[function-app-name].azurewebsites.[net|us]/api/[http-trigger-name]'.
                                                                                                                                                                  
                                                                                                                                                                  **ESA Credentials function URL (EsaCredentialsFnUrl):__________**
                                                                                                                                                                  

                                                                                                                                                                  d. Navigate to Policy Agent function app.

                                                                                                                                                                  e. Expand Settings menu item.

                                                                                                                                                                  f. Select Environment Variables menu item.

                                                                                                                                                                  g. Click Add button.

                                                                                                                                                                  h. For Name use PTY_ESA_CREDENTIALS_FUNCTION.

                                                                                                                                                                  i. For Value use ESA Credentials function URL (EsaCredentialsFnUrl) recorded in previous steps.

                                                                                                                                                                  j. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                  k. Hit Apply in App Settings tab.

                                                                                                                                                                3. Configure Authorization Option 1: Function Key Option 2: Key Vault Option 3: System-assigned Identity Option 4: User-assigned Identity

                                                                                                                                                                Authorization Option 1: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from environment variables.
                                                                                                                                                                1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                                  Review Azure documentation on how to accomplish this.

                                                                                                                                                                2. Navigate to ESA Credentials function app.

                                                                                                                                                                3. Expand Functions menu item.

                                                                                                                                                                4. Select App Keys.

                                                                                                                                                                5. Record default key value.

                                                                                                                                                                  ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                                6. Navigate to Policy Agent function app.

                                                                                                                                                                7. Expand Settings menu item.

                                                                                                                                                                8. Select Environment Variables menu item.

                                                                                                                                                                9. Click Add button.

                                                                                                                                                                10. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY.

                                                                                                                                                                11. For Value use ESA Credentials function key (EsaCredentialsFnKey) recorded in previous steps.

                                                                                                                                                                12. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                13. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 2: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from Azure Key Vault.
                                                                                                                                                                1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

                                                                                                                                                                  Review Azure documentation on how to accomplish this.

                                                                                                                                                                2. Navigate to ESA Credentials function app.

                                                                                                                                                                3. Expand Functions menu item.

                                                                                                                                                                4. Select App Keys.

                                                                                                                                                                5. Record default key value.

                                                                                                                                                                  ESA Credentials function key (EsaCredentialsFnKey):_______________

                                                                                                                                                                6. Navigate to Key Vault.

                                                                                                                                                                7. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                8. Select Manual, type in secret name and use ESA Credentials function key value recorded in previous steps (EsaCredentialsFnKey) for Secret value.

                                                                                                                                                                9. Select Create.

                                                                                                                                                                10. Record Key Vault secret name.

                                                                                                                                                                  ESA Credentials function key secret name (EsaCredentialsFnKeySecretName):_______________

                                                                                                                                                                11. Navigate to Policy Agent function app.

                                                                                                                                                                12. Expand Settings menu item.

                                                                                                                                                                13. Select Environment Variables menu item.

                                                                                                                                                                14. Click Add button.

                                                                                                                                                                15. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET.

                                                                                                                                                                16. For Value use ESA Credentials function key secret name (EsaCredentialsFnKeySecretName) recorded in previous steps.

                                                                                                                                                                17. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                18. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 3: Configure ESA Credentials authentication provider to authorize Policy Agent system-assigned identity.
                                                                                                                                                                1. Navigate to Policy Agent function app

                                                                                                                                                                2. Expand Settings menu item

                                                                                                                                                                3. Select Identity

                                                                                                                                                                4. Select System assigned tab

                                                                                                                                                                5. Status should already be On

                                                                                                                                                                  Other Status indicates Policy Agent was installed without system-assigned identity. Before proceeding any further you need to either install Policy Agent with system-assigned identity or follow Option 4 which describes configuration steps for Policy Agent installed with user-assigned managed identity.

                                                                                                                                                                6. Copy Object (principal) ID

                                                                                                                                                                7. Navigate to ESA Credentials function app

                                                                                                                                                                8. Expand Settings menu item

                                                                                                                                                                9. Select Authentication

                                                                                                                                                                10. Select Add identity provider

                                                                                                                                                                  Review related Microsoft documentation

                                                                                                                                                                11. Select Microsoft in identity provider dropdown

                                                                                                                                                                12. For App registration type provide details of your choice

                                                                                                                                                                13. For Issuer URL accept the default value

                                                                                                                                                                14. For Client application requirement select Allow requests from any application

                                                                                                                                                                  Access will be limited to only the Policy Agent identity in the next step

                                                                                                                                                                15. For Identity requirement select Allow requests from specific identities

                                                                                                                                                                16. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                                17. For Restrict access select Require authentication

                                                                                                                                                                18. For Unauthenticated requests select HTTP 401 Unauthorized: recommended for APIs

                                                                                                                                                                19. Check Token store

                                                                                                                                                                20. Select Add

                                                                                                                                                                21. Click OK to apply constraint

                                                                                                                                                                22. Click Save

                                                                                                                                                                23. Navigate to Application of Microsoft identity provider

                                                                                                                                                                  A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                                24. Expand Manage menu item

                                                                                                                                                                25. Select Expose an API

                                                                                                                                                                26. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                                27. Record Application ID URI of identity provider

                                                                                                                                                                  ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                                28. Navigate to Policy Agent function app.

                                                                                                                                                                29. Expand Settings menu item.

                                                                                                                                                                30. Select Environment Variables menu item.

                                                                                                                                                                31. Click Add button.

                                                                                                                                                                32. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                                33. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                                  Review Microsoft identity platform default scope

                                                                                                                                                                34. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                35. Hit Apply in App Settings tab.

                                                                                                                                                                Authorization Option 4: Configure ESA Credentials authentication provider to authorize Policy Agent user-assigned identity.
                                                                                                                                                                1. Navigate to Policy Agent function app

                                                                                                                                                                2. Expand Settings menu item

                                                                                                                                                                3. Select Identity

                                                                                                                                                                4. Select User assigned tab

                                                                                                                                                                  User-assigned identity should already be provided. Missing user-assigned identity indicates Policy Agent was installed without user-assigned identity. Before proceeding any further you need to either install Policy Agent with user-assigned identity or follow Option 3 which describes configuration steps for Policy Agent installed with system-assigned managed identity.

                                                                                                                                                                5. Copy Client ID

                                                                                                                                                                6. Copy Object (principal) ID

                                                                                                                                                                7. Navigate to ESA Credentials function app

                                                                                                                                                                8. Expand Settings menu item

                                                                                                                                                                9. Select Authentication

                                                                                                                                                                10. Select Add identity provider

                                                                                                                                                                  Review related Microsoft documentation

                                                                                                                                                                11. Select Microsoft in identity provider dropdown

                                                                                                                                                                12. For App registration type provide details of your choice

                                                                                                                                                                13. For Issuer URL accept the default value

                                                                                                                                                                14. For Client application requirement select Allow requests from specific client applications

                                                                                                                                                                15. For Allowed client applications add Client ID copied in previous step

                                                                                                                                                                16. Click OK to apply constraint

                                                                                                                                                                17. For Identity requirement select Allow requests from specific identities

                                                                                                                                                                18. For Allowed identities add Object (principal) ID copied in previous step

                                                                                                                                                                19. Click OK to apply constraint

                                                                                                                                                                20. Click Save

                                                                                                                                                                21. Navigate to Application of Microsoft identity provider

                                                                                                                                                                  A link to identity providers application is available under Authentication menu item of ESA Credentials function

                                                                                                                                                                22. Expand Manage menu item

                                                                                                                                                                23. Select Expose an API

                                                                                                                                                                24. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

                                                                                                                                                                25. Record Application ID URI of identity provider

                                                                                                                                                                  ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

                                                                                                                                                                26. Navigate to Policy Agent function app.

                                                                                                                                                                27. Expand Settings menu item.

                                                                                                                                                                28. Select Environment Variables menu item.

                                                                                                                                                                29. Click Add button.

                                                                                                                                                                30. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

                                                                                                                                                                31. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

                                                                                                                                                                  Review Microsoft identity platform default scope

                                                                                                                                                                32. Hit Apply in Add/Edit application setting blade.

                                                                                                                                                                33. Hit Apply in App Settings tab.

                                                                                                                                                                2.9 -

                                                                                                                                                                ESA Credentials In Azure Key Vault

                                                                                                                                                                Policy Agent Function uses Key Vault as secure store for sensitive information like ESA username and password.

                                                                                                                                                                Create ESA credentials secrets:

                                                                                                                                                                1. Navigate to Key Vault.

                                                                                                                                                                2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                3. Select Manual, then type in valid json as shown in the example for Secret value.

                                                                                                                                                                  {"username": "<policy_export_user>", "password": "<password>"}
                                                                                                                                                                  
                                                                                                                                                                4. Select Create.

                                                                                                                                                                5. Navigate to the secret details in Key Vault by selecting the newly created secret.

                                                                                                                                                                6. Inspect the current secret version properties by selecting the current version.

                                                                                                                                                                7. Copy the Secret Identifier value. For example https://<myvault>.vault.azure.net/secrets/<mysecret>/abcdefgxyz8edef595adaehij0d99123.

                                                                                                                                                                8. Record the Secret Identifier for later use.

                                                                                                                                                                2.10 -

                                                                                                                                                                ESA Server

                                                                                                                                                                Policy Agent function requires ESA server running and accessible from Agent Function App on TCP port 8443. Make sure inbound connections on TCP:8443 are allowed for the network where ESA is hosted. You can find the list of Agent Function Outbound IP addresses after you deploy the function in Agent Function Outbound IP address

                                                                                                                                                                Note down ESA IP to be accessed form Agent Function:

                                                                                                                                                                ESA IP Address (EsaIpAddress): ___________________

                                                                                                                                                                2.11 -

                                                                                                                                                                Install Agent via ARM template

                                                                                                                                                                Resources created with ARM template include Function App, Premium V3 App Service Plan (optional) and Application Insights service. Run Azure Resource Manager deployment.

                                                                                                                                                                To install Agent via ARM template:

                                                                                                                                                                1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                                                2. Select Build your own template in editor.

                                                                                                                                                                3. Select Load File and upload pty_agent_arm_v2.json. Click Save.

                                                                                                                                                                4. Select Resource Group.

                                                                                                                                                                5. Specify Name for the resources (All resources will be prefixed with Protegrity-Agent).

                                                                                                                                                                6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                                                7. For Agent Function Blob Url use the value from Upload Files

                                                                                                                                                                8. For Function App Managed Identity Optionally use the value from Agent Function User-Assigned Managed Identity. If value is not given, a system-assigned managed identity will be enabled.

                                                                                                                                                                9. If you set Use Existing App Service Plan to True, you must specify existing Linux App Service Plan name in the next parameter.

                                                                                                                                                                10. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Agent Function Blob Url.

                                                                                                                                                                11. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                                                12. After deployment is complete, go to Outputs and record agentFunctionName:

                                                                                                                                                                  Agent Function Name: __________________

                                                                                                                                                                2.12 -

                                                                                                                                                                Agent Function Key Vault Access Policies

                                                                                                                                                                Agent Function requires access to Key Vault created in Key Vault to encrypt policy and to access configuration secrets.

                                                                                                                                                                1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                                2. Select Access policies.
                                                                                                                                                                3. Click Create.
                                                                                                                                                                4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Wrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                                5. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Agent Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Agent via ARM template
                                                                                                                                                                6. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                                7. Review permissions and Create.

                                                                                                                                                                2.13 -

                                                                                                                                                                Function System-Assigned Managed Identity

                                                                                                                                                                System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                If you have not created a user-assigned managed identity at Agent Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                                1. Navigate to the function

                                                                                                                                                                2. Select Settings, Identity.

                                                                                                                                                                3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                                4. Click on Azure role assignments button.

                                                                                                                                                                5. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner with scope Storage account
                                                                                                                                                                  • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                                                  • Website Contributor with scope Resource Group

                                                                                                                                                                2.14 -

                                                                                                                                                                Test Agent Function Installation

                                                                                                                                                                After configuration is complete you can test the function.

                                                                                                                                                                To test Agent function installation:

                                                                                                                                                                1. Navigate to Overview.

                                                                                                                                                                2. Select the function agent from the Functions tab.

                                                                                                                                                                3. Click Code + Test > Test/Run and then Run to execute the function.

                                                                                                                                                                4. You should see a 202 Accepted response.

                                                                                                                                                                5. Expand Logs output at the bottom of the page. Click Maximize to enlarge log output.

                                                                                                                                                                6. Below is an example log output from successful agent run.

                                                                                                                                                                  
                                                                                                                                                                  INFO:AZURE_SUBSCRIPTION_ID: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]
                                                                                                                                                                  INFO:AZURE_KEY_VAULT_NAME: [vault-name]
                                                                                                                                                                  INFO:AZURE_ENCRYPTION_KEY_ID: [https://vault-name.vault.azure.net/keys/key-name/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]
                                                                                                                                                                  INFO:AZURE_RESOURCE_GROUP_NAME: [resource-group-name]
                                                                                                                                                                  INFO:AZURE_POLICY_BLOB_URL: [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip]
                                                                                                                                                                  INFO:AZURE_RETAIN_POLICY_BLOB: [3]
                                                                                                                                                                  INFO:PROTEGRITY_PROTECT_FUNCTION: [Protegrity-Protect-xxxx]
                                                                                                                                                                  INFO:DISABLE_DEPLOY: [0]
                                                                                                                                                                  INFO:PTY_ESA_IP: [xxx.xxx.xxx.xxx]
                                                                                                                                                                  INFO:PTY_SYNC_DATASTORE: []
                                                                                                                                                                  INFO:POLICY_PULL_TIMEOUT: [40]
                                                                                                                                                                  INFO:LOG_LEVEL: [info]
                                                                                                                                                                  INFO:PTY_CORE_EMPTYSTRING: [empty]
                                                                                                                                                                  INFO:PTY_CORE_CASESENSITIVE: [no]
                                                                                                                                                                  INFO:PTY_ADDIPADDRESSHEADER: [yes]
                                                                                                                                                                  INFO:Starting policy agent [4.0.3] ...
                                                                                                                                                                  INFO:ESA_CONNECTION_TIMEOUT: [60]
                                                                                                                                                                  INFO:Using ESA CA certificate from PTY_ESA_CA_SERVER_CERT environment variable.
                                                                                                                                                                  INFO:ResilientPackageClient initialized.
                                                                                                                                                                  INFO:Retrieving ESA rps version
                                                                                                                                                                  INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[]
                                                                                                                                                                  INFO:RPS Version: 1.9.2, Build: 1.9.2+1.g4bfba.1.9
                                                                                                                                                                  INFO:Checking ESA rps export availability
                                                                                                                                                                  INFO:Resilient package correlation_id=[xxxxxxxxxxxxxxxxxxxxxxxxx] datastore=[QA_DATA_STORE]
                                                                                                                                                                  INFO:Export available, Last-Modified: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                                                  INFO:Getting current policy metadata [https://resource-group-name.blob.core.windows.net/policy/protegrity-policy-name.zip] ...
                                                                                                                                                                  INFO:Last modified: [Thu, 01 Jan 2026 00:00:00 GMT], Last deployed: [Thu, 01 Jan 2026 00:00:00 GMT]
                                                                                                                                                                  WARNING:Current policy deployment has no checksum_mapping metadata:
                                                                                                                                                                  INFO:No changes in the policy since last download. Skipping policy deployment.
                                                                                                                                                                  INFO:Checking container for the last deployed policy [https://resource-group-name.blob.core.windows.net/policy]...
                                                                                                                                                                  INFO:[Protegrity-Protect-xxxx] current policy blob url: [https://resource-group-name.blob.core.windows.net/policy/2026-02-01_18-00-00/protegrity-policy-name.zip]
                                                                                                                                                                  INFO:Policy blob in sync for function [Protegrity-Protect-xxxx]
                                                                                                                                                                  INFO:[0] blobs are outside of the retention period [3]
                                                                                                                                                                  
                                                                                                                                                                7. If the log output in this window pauses or is difficult to read, you may navigate back to the Agent Function App overview and select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to view logs.

                                                                                                                                                                2.15 -

                                                                                                                                                                Troubleshooting

                                                                                                                                                                To review the most recent invocation traces, navigate to the function app instance. Select Monitoring > Logs from the menu on the left. Run the query traces in the query editor to retrieve the full history of executions with detailed traces.

                                                                                                                                                                2.16 -

                                                                                                                                                                Agent Function User-Assigned Managed Identity

                                                                                                                                                                User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                                2. Select Create

                                                                                                                                                                3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                                4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                                5. For Region provide recorded value of ApiRegion

                                                                                                                                                                6. For Name provide a name of the new identity

                                                                                                                                                                7. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner with scope Storage account
                                                                                                                                                                  • Monitoring Metrics Publisher with scope Resource Group
                                                                                                                                                                  • Website Contributor with scope Resource Group
                                                                                                                                                                8. Record Agent function user-assigned identity

                                                                                                                                                                  Agent Function User-Assigned Identity (AgentFuncUserAssignedIdentity): ____________________

                                                                                                                                                                2.17 -

                                                                                                                                                                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
                                                                                                                                                                falseyes20.75.43.207
                                                                                                                                                                falseno20.75.43.207
                                                                                                                                                                169.254.144.8120.75.43.20734.230.42.110trueyes169.254.144.81
                                                                                                                                                                trueno34.230.42.110
                                                                                                                                                                falseyes34.230.42.110
                                                                                                                                                                falseno34.230.42.110

                                                                                                                                                                2.18 -

                                                                                                                                                                ARM Template Installation - Required Permissions

                                                                                                                                                                Permissions below are required to install Protegrity service using ARM template.

                                                                                                                                                                All permissions in the table must be granted with the Resource group scope.

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.Insights/components/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.OperationalInsights/workspaces/read
                                                                                                                                                                

                                                                                                                                                                Read access to monitoring data and settings

                                                                                                                                                                Monitoring Reader

                                                                                                                                                                Microsoft.Insights/components/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.OperationalInsights/workspaces/write
                                                                                                                                                                

                                                                                                                                                                Write and manage access to monitoring data and settings

                                                                                                                                                                Monitoring Contributor

                                                                                                                                                                Microsoft.Web/serverFarms/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/sites/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/sites/host/listkeys/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/serverFarms/join/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Web/register/action
                                                                                                                                                                

                                                                                                                                                                Write and manage access to web apps

                                                                                                                                                                Website Contributor

                                                                                                                                                                Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.ManagedIdentity/userAssignedIdentities/read
                                                                                                                                                                

                                                                                                                                                                Manage and assign managed identities

                                                                                                                                                                Managed Identity Operator

                                                                                                                                                                Microsoft.Resources/deployments/validate/action
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/operationStatuses/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.Resources/deployments/read
                                                                                                                                                                

                                                                                                                                                                Manage and validate deployments

                                                                                                                                                                Deployment Contributor

                                                                                                                                                                         

                                                                                                                                                                Log Forwarder service ARM deployment requires additional permissions below:

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.EventHub/namespaces/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.EventHub/namespaces/eventhubs/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.EventHub/namespaces/networkrulesets/write
                                                                                                                                                                

                                                                                                                                                                Allow for the creation, update, and deletion of Event Hub namespaces, event hubs within those namespaces, and their network rule sets, enabling full management of Event Hub resources. Note: These permissions are only required when deploying new event Hub.

                                                                                                                                                                Event Hubs Contributor

                                                                                                                                                                Microsoft.EventHub/namespaces/read
                                                                                                                                                                

                                                                                                                                                                Read monitoring data and metrics, including Event Hub namespace data.

                                                                                                                                                                Monitoring Reader

                                                                                                                                                                  

                                                                                                                                                                      

                                                                                                                                                                The additional permissions listed below are required when API management is part of the deployment.

                                                                                                                                                                Permissions

                                                                                                                                                                Description

                                                                                                                                                                Built-In Azure Role

                                                                                                                                                                Microsoft.ApiManagement/service/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/diagnostics/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/operations/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/operations/policies/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/backends/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/loggers/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/policies/write
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/apis/diagnostics/write
                                                                                                                                                                

                                                                                                                                                                Create or update API Management service instances, APIs, diagnostics, API operations, operation policies, backends, loggers, tenant policies, and API diagnostics.

                                                                                                                                                                API Management Service Contributor

                                                                                                                                                                Microsoft.ApiManagement/service/read
                                                                                                                                                                
                                                                                                                                                                Microsoft.ApiManagement/service/operationResults/read
                                                                                                                                                                

                                                                                                                                                                Read metadata for API Management service instances and get the status of long-running operations.

                                                                                                                                                                API Management Service Reader

                                                                                                                                                                2.19 -

                                                                                                                                                                Configuring Regular Expression to Extract Policy Username

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

                                                                                                                                                                • USERNAME_REGEX 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

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                ^(.*)[@/].*$
                                                                                                                                                                

                                                                                                                                                                juliet.snow@domain.com

                                                                                                                                                                juliet.snow

                                                                                                                                                                juliet.snow/ad_postfix

                                                                                                                                                                juliet.snow

                                                                                                                                                                2.20 -

                                                                                                                                                                Audit Log Forwarding Architecture

                                                                                                                                                                Audit logs are by default sent to Azure Blob Storage and Application Insights. The Cloud Protect product can also be configured to send audit logs to ESA. Such configuration requires deploying audit Log Forwarder component which is available as part of Cloud Protect deployment bundle. The diagram below shows additional resources deployed with Log Forwarder component.

                                                                                                                                                                The audit log forwarding solution includes Azure Event Hubs data-streaming service and an Azure Function App deployment called Log Forwarder. Protect function delivers audit logs to Azure Event Hub instance, Event Hub instance batches audit logs and delivers them to Log Forwarder function. Log Forwarder function then delivers audit logs to ESA. Audit log aggregation occurs on both Protect and Log Forwarder functions. Aggregation rules are described in the Understanding the log aggregation section. If Log Forwarder cannot deliver audit logs to ESA due to temporary ESA connection loss, it will send undelivered audit logs to a dead-letter queue Event Hub. Audit logs in dead-letter queue Event Hub can be re-delivered to ESA using another instance of Log Forwarder, which can be configured to run either manually or on schedule.

                                                                                                                                                                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 function which verifies individual logs signature. The signature verification is done upon arrival from Azure Event Hub 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 client certificate to authenticate calls to ESA.

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

                                                                                                                                                                2.21 -

                                                                                                                                                                The following sections provide installation steps for the Log Forwarder component in Azure. The Log Forwarder deployment allows for the audit logs generated by Protect Service to be delivered to ESA for auditing and governance purposes. Log Forwarder component is optional and is not required for the Protect Service to work properly. See Audit Log Forwarder Architecture for more information. Some of the installation steps are not required for the operation of the software but recommended for establishing a secure environment. Contact Protegrity for further guidance on configuration alternatives in the cloud.

                                                                                                                                                                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 (Audit Store) or 24284 (td-agent).

                                                                                                                                                                2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                                                                                                                3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                                                                                                                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 Log Forwarder variable in section Install Log Forwarder via ARM template

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

                                                                                                                                                                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:

                                                                                                                                                                • client.key
                                                                                                                                                                • client.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"
                                                                                                                                                                

                                                                                                                                                                There are two options to configure Log Forwarder for certificate authentication:

                                                                                                                                                                • While installing using ARM template
                                                                                                                                                                  1. Provide single-line client certificate for Esa Client Cert
                                                                                                                                                                  2. Provide Azure Key Vault secret name for Esa Client Cert Key Secret Name which stores single-line certificate key file.
                                                                                                                                                                • When re-configuring after installation using environment variables
                                                                                                                                                                  1. Provide single-line client certificate for ESA_CLIENT_CERT
                                                                                                                                                                  2. Provide Azure Key Vault secret name for ESA_CLIENT_CERT_KEY_SECRET_NAME which stores single-line certificate key file.

                                                                                                                                                                Create Key Vault Secrets

                                                                                                                                                                Log Forwarder uses Key Vault as a secure store for certificate key file.

                                                                                                                                                                Create secret in Key Vault for certificate key file:

                                                                                                                                                                1. Navigate to Key Vault.

                                                                                                                                                                2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                3. Select Manual, type in secret name and specify single-line certificate key file value for Secret value.

                                                                                                                                                                4. Select Create.

                                                                                                                                                                5. Record secret name:

                                                                                                                                                                  ESA Client Cert Key Secret Name (EsaClientCertKeySecretName): ___________________

                                                                                                                                                                Function User-Assigned Managed Identity

                                                                                                                                                                User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                                2. Select Create

                                                                                                                                                                3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                                4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                                5. For Region provide recorded value of ApiRegion

                                                                                                                                                                6. For Name provide a name of the new identity

                                                                                                                                                                7. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                                                8. Record Forward function user-assigned identity

                                                                                                                                                                  Forward Function User-Assigned Identity (ForwardFuncUserAssignedIdentity): ____________________

                                                                                                                                                                Install Log Forwarder via ARM template

                                                                                                                                                                Resources created with ARM template include Function App, App Service Plan and Application Insights service. Optionally, a new Event Hub namespace and Event Hub instance can be created.

                                                                                                                                                                To install Log Forwarder via ARM template:

                                                                                                                                                                1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                                                2. Select Build your own template in editor.

                                                                                                                                                                3. Select Load File and upload pty_forward_arm_v2.json. Click Save.

                                                                                                                                                                4. Select Resource Group.

                                                                                                                                                                5. Specify Name for the resources (All resources will be prefixed with Protegrity-Forward).

                                                                                                                                                                6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                                                7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Forward Function Blob Url.

                                                                                                                                                                8. For Forward Function Blob Url use the value from Upload Files.

                                                                                                                                                                9. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                                                                10. For Function Sku Count Minimum number of workers to keep active.

                                                                                                                                                                11. For WorkSpace Sku Azure Monitor log analytics pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                                12. For Log Retention In Days The workSpace data retention in days. Allowed values are per pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                                13. For Forward Logs to ESA select whether to collect audit logs from a new or an existing Event Hub. A new Event Hub namespace and new Event Hub instance will be created for ‘From new Event Hub’ option.

                                                                                                                                                                14. For Audit Log Output select whether to send logs directly to Audit Store or td-agent on ESA

                                                                                                                                                                15. For Event Hub Namespace enter Event Hub namespace name. Depending on previous option, a new namespace with this name will be created or an existing namespace with this name will be used.

                                                                                                                                                                16. For New Event Hub Namespace Sku Name select Event Hub namespace SKU name. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                17. For New Event Hub Namespace Sku Tier select Event Hub namespace SKU Tier used for new Event Hub namespace. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                18. For New Event Hub Namespace Sku Capacity enter a value of Event Hub throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                19. For Event Hub Name enter Event Hub instance name. A new Event Hub instance with this name will be created or an existing Event Hub instance with this name will be used.

                                                                                                                                                                20. For Event Hub Name DLQ enter Event Hub name for the dead-letter queue, where messages will be delivered to in case connection to ESA is lost. A new Event Hub instance with this name will be created or an existing Event Hub with this name will be used.

                                                                                                                                                                21. For New Event Hub Partition Count enter number of partitions to create in a new Event Hub. Allowed values are from 1 to 32 partitions. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                22. For New Event Hub Audit Log Retention In Days enter number of days audit logs will be available in Event Hub. Applies to both primary Event Hub and dead-letter queue Event Hub. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                23. For Log Destination Esa Ip enter ESA IP address.

                                                                                                                                                                24. For Esa Client Cert enter single-line ESA client certificate. See section Certificate Authentication for details.

                                                                                                                                                                25. For Esa Client Cert Key Secret Name enter secret name which stores ESA client certificate single-line private key. See section Certificate Authentication for details.

                                                                                                                                                                26. For Key Vault Uri enter URI of the Key Vault that stores ESA username/password secrets.

                                                                                                                                                                27. For Esa Tls Disable Cert Verify Set to ‘0’ to enable ESA certificate validation. Set to ‘1’ to disable ESA certificate verification. Disable only for initial setup and development purposes, do not disable in production environments.

                                                                                                                                                                28. If ESA is configured with self-signed certificate, set Pty Esa Ca Server Cert. Use the ESA CA Server Certificate escaped content recorded in Certificates on ESA.

                                                                                                                                                                  Note that for development and troubleshooting purposes, ESA certificate validation can be disabled by either redeploying this function with this ARM template where Esa Tls Disable Cert Verify option is set to ‘1’ or by directly setting PTY_ESA_DISABLE_TLS_CERT_VERIFY environment variable to ‘1’.

                                                                                                                                                                29. For Esa Connect Timeout set time in seconds to wait for the ESA connection response. Minimum value: 1. Default: 5.

                                                                                                                                                                30. For Esa Virtual Host provide ESA virtual hostname. This configuration is optional. It can be used when proxy server is present and supports TLS SNI extension.

                                                                                                                                                                31. For Min Log Level select minimum log level. Accepted values: off, severe, warning, info, config, all

                                                                                                                                                                32. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                                                After deployment is complete:

                                                                                                                                                                1. Go to Outputs and record:

                                                                                                                                                                  Forward Function Name (ForwardFuncName):__________________

                                                                                                                                                                2. Record:

                                                                                                                                                                  Event Hub Name (EventHubName):__________________

                                                                                                                                                                  Event Hub Namespace (EventHubNamespace):__________________

                                                                                                                                                                Function System-Assigned Managed Identity

                                                                                                                                                                System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                If you have not created a user-assigned managed identity at Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                                1. Navigate to the function

                                                                                                                                                                2. Select Settings, Identity.

                                                                                                                                                                3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                                4. Click on Azure role assignments button.

                                                                                                                                                                5. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                                                6. From Azure console, navigate to Function App and select audit log forwarder function deployed in previous section.

                                                                                                                                                                7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                                                Update Function Key Vault Access Policies

                                                                                                                                                                The Key vault must be updated to allow the Function App to decrypt the policy files. The Forwarder is using policy to confirm the authenticity of audit logs it receives from Event Hub and to digitally sign the aggregated logs that it sends to ESA. Update the Key vault access policies with function identity. To update the key vault access policies:

                                                                                                                                                                1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                                2. Select Access policies.
                                                                                                                                                                3. Click Create.
                                                                                                                                                                4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                                5. Proceed Next to Principal.
                                                                                                                                                                6. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Log Forwarder via ARM template
                                                                                                                                                                7. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                                8. Review permissions and Create.

                                                                                                                                                                Test Log Forwarder Installation

                                                                                                                                                                Follow the steps to validate Log Forwarder installation. Successful Log Forwarder installation will aggregate logs, connect to ESA and send audit log events.

                                                                                                                                                                Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                                                                                                                Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                                                                                                                1. In the following command, replace ‘forwarder-function-name’ with your function name

                                                                                                                                                                2. In the following command, replace ‘forwarder-function-key’ with your function key

                                                                                                                                                                3. Run the command in PowerShell:

                                                                                                                                                                  
                                                                                                                                                                  $forwarderFunctionName='forwarder-function-name'
                                                                                                                                                                  $forwarderFunctionKey='forwarder-function-key'
                                                                                                                                                                  
                                                                                                                                                                  Invoke-WebRequest -UseBasicParsing -Uri "https://$forwarderFunctionName.azurewebsites.net/admin/functions/auditlogforwarder" `
                                                                                                                                                                  -Method POST `
                                                                                                                                                                  -Headers @{
                                                                                                                                                                    "x-functions-key" = $forwarderFunctionKey
                                                                                                                                                                  } `
                                                                                                                                                                  -ContentType "application/json" `
                                                                                                                                                                  -Body "{`"input`":`"{\`"additional_info\`":{\`"description\`":\`"Data unprotect operation was successful.\`",\`"request_id\`":\`"f0ffbbf8-ab5b-42b7-90f4-51db7443af77\`"},\`"cnt\`": 1,\`"correlationid\`": \`"clfwrqgme0021nj329mijk52w\`",\`"logtype\`": \`"Protection\`",\`"level\`": \`"SUCCESS\`",\`"origin\`": {  \`"hostname\`": \`"169.254.197.189\`",  \`"ip\`": \`"169.254.197.189\`", \`"time_utc\`": 1722941687},\`"protection\`": {\`"dataelement\`": \`"alpha\`", \`"operation\`": \`"Unprotect\`",\`"audit_code\`": 8,\`"policy_user\`": \`"test_user\`",\`"datastore\`": \`"SAMPLE_POLICY\`"},\`"process\`": {  \`"name\`": \`"N/A\`",  \`"id\`": \`"15\`",\`"thread_id\`": \`"2243954624\`",\`"user\`": \`"sbx_user1051\`", \`"platform\`": \`"Linux_x32\`"},\`"client\`": {\`"username\`":\`"sbx_user1051\`",\`"ip\`":\`"169.254.197.189\`"},\`"protector\`": {\`"family\`": \`"IAP Lambda\`",\`"version\`": \`"3.1.0\`",\`"vendor\`": \`"Cloud Protect\`",\`"pcc_version\`": \`"3.5.0.1\`", \`"core_version\`": \`"2.0.1\`"},\`"signature\`": { \`"key_id\`":\`"5f143892-bbe4-4794-b1f4-ed28ca2a077e\`", \`"checksum\`": \`"90BC9BF39354869BD4BC5381820D201797DF4AF53B5A7F5F3AE01EC607C41A6E\`"}}`"}"
                                                                                                                                                                  

                                                                                                                                                                4. Run following query to see your function logs, allow for a few minutes for Azure to deliver the logs

                                                                                                                                                                  
                                                                                                                                                                  traces
                                                                                                                                                                  | project timestamp, message
                                                                                                                                                                  | where timestamp > ago(5m)
                                                                                                                                                                  
                                                                                                                                                                5. Test is successful if the logs contain the following entry:

                                                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                                                  

                                                                                                                                                                  If the log entry is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                                                                                                Update Protect Service With Event Hub details

                                                                                                                                                                In this section, Event Hub details will be provided to the Protect Service installation.

                                                                                                                                                                1. Navigate to the Protect function environment variables.

                                                                                                                                                                2. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                                3. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                                4. Apply and Confirm to apply the changes.

                                                                                                                                                                Update Policy Agent With Log Forwarder Function Target

                                                                                                                                                                Log Forwarder requires a Protegrity policy which is in sync with the Protector Service. This section will describe the steps to update the Policy Agent to include updating the Log Forwarder.

                                                                                                                                                                1. Navigate to the Policy Agent function created in Install Agent via ARM template

                                                                                                                                                                2. Select Settings > Environment variables > PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                                                3. Edit the value for environment variable PROTEGRITY_PROTECT_FUNCTION to include the Log Forwarder function’s name in the comma separated list of function names.

                                                                                                                                                                4. Select Apply > Apply > Confirm to save the changes

                                                                                                                                                                5. Test Policy Agent installation as described in Test Agent Function Installation

                                                                                                                                                                Test Full Log Forwarder Installation

                                                                                                                                                                1. Install and configure Protegrity Agent, Protect Service and Log Forwarder components.
                                                                                                                                                                2. Set EVENT_LEVEL environment variable on Protect Service function to Informational.
                                                                                                                                                                3. Set PTY_LOG_LEVEL environment variable on both Protect Service function and Log Forwarder function to config.

                                                                                                                                                                Test Installation

                                                                                                                                                                1. Make a protect operation using a data element or user which will result in audit log generation

                                                                                                                                                                2. Navigate to the Logs for the Protect Service function

                                                                                                                                                                3. Execute ’traces’ query

                                                                                                                                                                4. Expect to see a log similar to the below:

                                                                                                                                                                  
                                                                                                                                                                  Completed publishing events for Event Hub: audit-logs (Partition Id/Key: '0'), Operation Id: 'e17bacd6-91e6-4fb5-8281-2929788bef09'. Service Retry Count: 0; Duration: '0.02' seconds
                                                                                                                                                                  
                                                                                                                                                                5. Navigate to the Logs for the Log Forwarder function

                                                                                                                                                                6. Execute ’traces’ query

                                                                                                                                                                7. Expect to see a log similar to the below:

                                                                                                                                                                  
                                                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                                                  

                                                                                                                                                                Troubleshooting

                                                                                                                                                                Configure additional logging for functions:

                                                                                                                                                                1. Set EVENT_LEVEL environment variable on Protect function to Informational.
                                                                                                                                                                2. Set PTY_LOG_LEVEL environment variable on both Protect function and Log Forwarder function to config.

                                                                                                                                                                Error

                                                                                                                                                                Detail

                                                                                                                                                                
                                                                                                                                                                Unhandled exception. System.Exception: Failed to initialize 
                                                                                                                                                                function type,expecting environment variable 
                                                                                                                                                                'AzureWebJobs.AuditLogForwarder.Disabled' 
                                                                                                                                                                to be set to either 'true' or 'false'
                                                                                                                                                                
                                                                                                                                                                1. An environment variable ‘AzureWebJobs.AuditLogForwarder.Disabled’ is expected. This environment variable is added automatically when functions are deployed with ARM templates.
                                                                                                                                                                2. Verify this environment variable exists and is set to ’true’ for Protect Service functions and is set to ‘false’ for Log Forwarder functions.
                                                                                                                                                                
                                                                                                                                                                [2024/08/08 10:00:00] [error] [tls] error: unexpected EOF
                                                                                                                                                                

                                                                                                                                                                Log Forwarder failed to verify ESA certificate

                                                                                                                                                                1. If ESA is configured with self-signed certificate, verify that Log Forwarder ‘PTY_ESA_CA_SERVER_CERT’ is correctly set to ESA CA certificate string. Refer to Certificates on ESA for details.
                                                                                                                                                                2. If ESA is configured with publicly signed certificate, ensure Log Forwarder ‘PTY_LOG_LEVEL’ is set to ‘all’ level, restart and re-test the Log Forwarder. Review the logs to see if your root CA is used. If not used, you may supply your public CA in Log forwarder configuration ‘PTY_ESA_CA_SERVER_CERT’.
                                                                                                                                                                3. During initial non-production setup, SSL verification can be disabled by setting ‘PTY_ESA_DISABLE_TLS_CERT_VERIFY’ environment variable to ‘1’ or ’true’
                                                                                                                                                                
                                                                                                                                                                Failed to aggregate audit logs, 1 audit logs dropped, error: 
                                                                                                                                                                The user, group or application 'appid=;oid=;iss=' does not have 
                                                                                                                                                                secrets get permission on key vault ';location='...
                                                                                                                                                                Status: 403 (Forbidden)
                                                                                                                                                                ErrorCode: Forbidden
                                                                                                                                                                

                                                                                                                                                                Log Forwarder has no permissions to use Key Vault

                                                                                                                                                                1. Verify Log Forwarder has access to the Key Vault.
                                                                                                                                                                2. Consult section Update Function Key Vault Access Policies
                                                                                                                                                                
                                                                                                                                                                TCP connection timed out: 001.001.001.001:9200
                                                                                                                                                                

                                                                                                                                                                Log Forwarder failed to connect to ESA

                                                                                                                                                                1. Ensure ESA is available on given IP address and 9200 port
                                                                                                                                                                2. Consult section ESA Audit Store Configuration
                                                                                                                                                                
                                                                                                                                                                fail: Protect.Aggregate[0] Failed to aggregate audit logs, 
                                                                                                                                                                1 audit logs dropped, error: Invalid URI: The format of the URI 
                                                                                                                                                                could not be determined. 
                                                                                                                                                                info: iap[0] Shared memory segment POLICY does not exist: The 
                                                                                                                                                                system cannot find the file specified.
                                                                                                                                                                

                                                                                                                                                                Invalid Key Vault Uri format

                                                                                                                                                                1. Ensure that environment variable KEY_VAULT_URI has correctly formatted url.
                                                                                                                                                                2. Example 1: https://<keyvaultname>.vault.azure.net/
                                                                                                                                                                3. Example 2: https://<keyvaultname>.vault.usgovcloudapi.net/
                                                                                                                                                                
                                                                                                                                                                [Error] Azure-Messaging-EventHubs: An exception occurred while 
                                                                                                                                                                publishing a batch of events for buffered producer instance with 
                                                                                                                                                                identifier 'x' to Event Hub: audit-logs, Partition Id: '0', 
                                                                                                                                                                Operation Id: 'x'. Error Message: 'Unauthorized access.
                                                                                                                                                                

                                                                                                                                                                Protect Service function failed to send messages to Event Hub

                                                                                                                                                                1. Ensure Forwarder Function managed identity has ‘Azure Event Hubs Data Sender’ role assigned for the Event Hub resource.
                                                                                                                                                                2. See Function User-Assigned Managed Identity and Function System-Assigned Managed Identity

                                                                                                                                                                2.22 -

                                                                                                                                                                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 Log Forwarder variable in section Install Log Forwarder via ARM template

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

                                                                                                                                                                2.23 -

                                                                                                                                                                Create Key Vault Secrets

                                                                                                                                                                Log Forwarder uses Key Vault as a secure store for certificate key file.

                                                                                                                                                                Create secret in Key Vault for certificate key file:

                                                                                                                                                                1. Navigate to Key Vault.

                                                                                                                                                                2. Under Objects, select Secrets > Generate/import.

                                                                                                                                                                3. Select Manual, type in secret name and specify single-line certificate key file value for Secret value.

                                                                                                                                                                4. Select Create.

                                                                                                                                                                5. Record secret name:

                                                                                                                                                                  ESA Client Cert Key Secret Name (EsaClientCertKeySecretName): ___________________

                                                                                                                                                                2.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:

                                                                                                                                                                • client.key
                                                                                                                                                                • client.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"
                                                                                                                                                                

                                                                                                                                                                There are two options to configure Log Forwarder for certificate authentication:

                                                                                                                                                                • While installing using ARM template
                                                                                                                                                                  1. Provide single-line client certificate for Esa Client Cert
                                                                                                                                                                  2. Provide Azure Key Vault secret name for Esa Client Cert Key Secret Name which stores single-line certificate key file.
                                                                                                                                                                • When re-configuring after installation using environment variables
                                                                                                                                                                  1. Provide single-line client certificate for ESA_CLIENT_CERT
                                                                                                                                                                  2. Provide Azure Key Vault secret name for ESA_CLIENT_CERT_KEY_SECRET_NAME which stores single-line certificate key file.

                                                                                                                                                                2.25 -

                                                                                                                                                                Install Log Forwarder via ARM template

                                                                                                                                                                Resources created with ARM template include Function App, App Service Plan and Application Insights service. Optionally, a new Event Hub namespace and Event Hub instance can be created.

                                                                                                                                                                To install Log Forwarder via ARM template:

                                                                                                                                                                1. From Azure Console, select Create a resource, search for template and then select Template deployment > Create.

                                                                                                                                                                2. Select Build your own template in editor.

                                                                                                                                                                3. Select Load File and upload pty_forward_arm_v2.json. Click Save.

                                                                                                                                                                4. Select Resource Group.

                                                                                                                                                                5. Specify Name for the resources (All resources will be prefixed with Protegrity-Forward).

                                                                                                                                                                6. For Location input specify Azure region name or leave default to deploy in the same region as resource group

                                                                                                                                                                7. For Storage Account Blob Service Url Optionally use the value recorded in Create Storage Account. If value is not given, it will be automatically derived from Forward Function Blob Url.

                                                                                                                                                                8. For Forward Function Blob Url use the value from Upload Files.

                                                                                                                                                                9. For Function Sku either EP1 or EP3 are recommended. Note that this will affect the running cost.

                                                                                                                                                                10. For Function Sku Count Minimum number of workers to keep active.

                                                                                                                                                                11. For WorkSpace Sku Azure Monitor log analytics pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                                12. For Log Retention In Days The workSpace data retention in days. Allowed values are per pricing plan. See Azure Monitor Pricing tiers documentation for details: Azure Monitor Pricing

                                                                                                                                                                13. For Forward Logs to ESA select whether to collect audit logs from a new or an existing Event Hub. A new Event Hub namespace and new Event Hub instance will be created for ‘From new Event Hub’ option.

                                                                                                                                                                14. For Audit Log Output select whether to send logs directly to Audit Store or td-agent on ESA

                                                                                                                                                                15. For Event Hub Namespace enter Event Hub namespace name. Depending on previous option, a new namespace with this name will be created or an existing namespace with this name will be used.

                                                                                                                                                                16. For New Event Hub Namespace Sku Name select Event Hub namespace SKU name. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                17. For New Event Hub Namespace Sku Tier select Event Hub namespace SKU Tier used for new Event Hub namespace. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                18. For New Event Hub Namespace Sku Capacity enter a value of Event Hub throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                19. For Event Hub Name enter Event Hub instance name. A new Event Hub instance with this name will be created or an existing Event Hub instance with this name will be used.

                                                                                                                                                                20. For Event Hub Name DLQ enter Event Hub name for the dead-letter queue, where messages will be delivered to in case connection to ESA is lost. A new Event Hub instance with this name will be created or an existing Event Hub with this name will be used.

                                                                                                                                                                21. For New Event Hub Partition Count enter number of partitions to create in a new Event Hub. Allowed values are from 1 to 32 partitions. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                22. For New Event Hub Audit Log Retention In Days enter number of days audit logs will be available in Event Hub. Applies to both primary Event Hub and dead-letter queue Event Hub. Applicable only when ‘From new Event Hub’ is selected.

                                                                                                                                                                23. For Log Destination Esa Ip enter ESA IP address.

                                                                                                                                                                24. For Esa Client Cert enter single-line ESA client certificate. See section Certificate Authentication for details.

                                                                                                                                                                25. For Esa Client Cert Key Secret Name enter secret name which stores ESA client certificate single-line private key. See section Certificate Authentication for details.

                                                                                                                                                                26. For Key Vault Uri enter URI of the Key Vault that stores ESA username/password secrets.

                                                                                                                                                                27. For Esa Tls Disable Cert Verify Set to ‘0’ to enable ESA certificate validation. Set to ‘1’ to disable ESA certificate verification. Disable only for initial setup and development purposes, do not disable in production environments.

                                                                                                                                                                28. If ESA is configured with self-signed certificate, set Pty Esa Ca Server Cert. Use the ESA CA Server Certificate escaped content recorded in Certificates on ESA.

                                                                                                                                                                  Note that for development and troubleshooting purposes, ESA certificate validation can be disabled by either redeploying this function with this ARM template where Esa Tls Disable Cert Verify option is set to ‘1’ or by directly setting PTY_ESA_DISABLE_TLS_CERT_VERIFY environment variable to ‘1’.

                                                                                                                                                                29. For Esa Connect Timeout set time in seconds to wait for the ESA connection response. Minimum value: 1. Default: 5.

                                                                                                                                                                30. For Esa Virtual Host provide ESA virtual hostname. This configuration is optional. It can be used when proxy server is present and supports TLS SNI extension.

                                                                                                                                                                31. For Min Log Level select minimum log level. Accepted values: off, severe, warning, info, config, all

                                                                                                                                                                32. Select Review + create then Create. Wait for all resources to deploy

                                                                                                                                                                After deployment is complete:

                                                                                                                                                                1. Go to Outputs and record:

                                                                                                                                                                  Forward Function Name (ForwardFuncName):__________________

                                                                                                                                                                2. Record:

                                                                                                                                                                  Event Hub Name (EventHubName):__________________

                                                                                                                                                                  Event Hub Namespace (EventHubNamespace):__________________

                                                                                                                                                                2.26 -

                                                                                                                                                                Update Function Key Vault Access Policies

                                                                                                                                                                The Key vault must be updated to allow the Function App to decrypt the policy files. The Forwarder is using policy to confirm the authenticity of audit logs it receives from Event Hub and to digitally sign the aggregated logs that it sends to ESA. Update the Key vault access policies with function identity. To update the key vault access policies:

                                                                                                                                                                1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                                2. Select Access policies.
                                                                                                                                                                3. Click Create.
                                                                                                                                                                4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                                5. Proceed Next to Principal.
                                                                                                                                                                6. For Principal provide function identity a. For functions with user-assigned identity enter identity recorded in step Function User-Assigned Managed Identity b. For functions with system-assigned identity enter function name recorded in step Install Log Forwarder via ARM template
                                                                                                                                                                7. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                                8. Review permissions and Create.

                                                                                                                                                                2.27 -

                                                                                                                                                                Function System-Assigned Managed Identity

                                                                                                                                                                System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                If you have not created a user-assigned managed identity at Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                                1. Navigate to the function

                                                                                                                                                                2. Select Settings, Identity.

                                                                                                                                                                3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                                4. Click on Azure role assignments button.

                                                                                                                                                                5. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                                                6. From Azure console, navigate to Function App and select audit log forwarder function deployed in previous section.

                                                                                                                                                                7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                                                2.28 -

                                                                                                                                                                Test Full Log Forwarder Installation

                                                                                                                                                                1. Install and configure Protegrity Agent, Protect Service and Log Forwarder components.
                                                                                                                                                                2. Set EVENT_LEVEL environment variable on Protect Service function to Informational.
                                                                                                                                                                3. Set PTY_LOG_LEVEL environment variable on both Protect Service function and Log Forwarder function to config.

                                                                                                                                                                Test Installation

                                                                                                                                                                1. Make a protect operation using a data element or user which will result in audit log generation

                                                                                                                                                                2. Navigate to the Logs for the Protect Service function

                                                                                                                                                                3. Execute ’traces’ query

                                                                                                                                                                4. Expect to see a log similar to the below:

                                                                                                                                                                  
                                                                                                                                                                  Completed publishing events for Event Hub: audit-logs (Partition Id/Key: '0'), Operation Id: 'e17bacd6-91e6-4fb5-8281-2929788bef09'. Service Retry Count: 0; Duration: '0.02' seconds
                                                                                                                                                                  
                                                                                                                                                                5. Navigate to the Logs for the Log Forwarder function

                                                                                                                                                                6. Execute ’traces’ query

                                                                                                                                                                7. Expect to see a log similar to the below:

                                                                                                                                                                  
                                                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                                                  

                                                                                                                                                                2.29 -

                                                                                                                                                                Test Log Forwarder Installation

                                                                                                                                                                Follow the steps to validate Log Forwarder installation. Successful Log Forwarder installation will aggregate logs, connect to ESA and send audit log events.

                                                                                                                                                                Testing in this section validates the connectivity between Log Forwarder and ESA. The sample policy included with the initial installation and test event below are not based on your ESA policy. Any logs forwarded to ESA which are not signed with a policy generated by your ESA will not be added to the audit store.

                                                                                                                                                                Install Log Forwarder and configure according to previous sections. Log Forwarder configuration MinLogLevel must be at least info level.

                                                                                                                                                                1. In the following command, replace ‘forwarder-function-name’ with your function name

                                                                                                                                                                2. In the following command, replace ‘forwarder-function-key’ with your function key

                                                                                                                                                                3. Run the command in PowerShell:

                                                                                                                                                                  
                                                                                                                                                                  $forwarderFunctionName='forwarder-function-name'
                                                                                                                                                                  $forwarderFunctionKey='forwarder-function-key'
                                                                                                                                                                  
                                                                                                                                                                  Invoke-WebRequest -UseBasicParsing -Uri "https://$forwarderFunctionName.azurewebsites.net/admin/functions/auditlogforwarder" `
                                                                                                                                                                  -Method POST `
                                                                                                                                                                  -Headers @{
                                                                                                                                                                    "x-functions-key" = $forwarderFunctionKey
                                                                                                                                                                  } `
                                                                                                                                                                  -ContentType "application/json" `
                                                                                                                                                                  -Body "{`"input`":`"{\`"additional_info\`":{\`"description\`":\`"Data unprotect operation was successful.\`",\`"request_id\`":\`"f0ffbbf8-ab5b-42b7-90f4-51db7443af77\`"},\`"cnt\`": 1,\`"correlationid\`": \`"clfwrqgme0021nj329mijk52w\`",\`"logtype\`": \`"Protection\`",\`"level\`": \`"SUCCESS\`",\`"origin\`": {  \`"hostname\`": \`"169.254.197.189\`",  \`"ip\`": \`"169.254.197.189\`", \`"time_utc\`": 1722941687},\`"protection\`": {\`"dataelement\`": \`"alpha\`", \`"operation\`": \`"Unprotect\`",\`"audit_code\`": 8,\`"policy_user\`": \`"test_user\`",\`"datastore\`": \`"SAMPLE_POLICY\`"},\`"process\`": {  \`"name\`": \`"N/A\`",  \`"id\`": \`"15\`",\`"thread_id\`": \`"2243954624\`",\`"user\`": \`"sbx_user1051\`", \`"platform\`": \`"Linux_x32\`"},\`"client\`": {\`"username\`":\`"sbx_user1051\`",\`"ip\`":\`"169.254.197.189\`"},\`"protector\`": {\`"family\`": \`"IAP Lambda\`",\`"version\`": \`"3.1.0\`",\`"vendor\`": \`"Cloud Protect\`",\`"pcc_version\`": \`"3.5.0.1\`", \`"core_version\`": \`"2.0.1\`"},\`"signature\`": { \`"key_id\`":\`"5f143892-bbe4-4794-b1f4-ed28ca2a077e\`", \`"checksum\`": \`"90BC9BF39354869BD4BC5381820D201797DF4AF53B5A7F5F3AE01EC607C41A6E\`"}}`"}"
                                                                                                                                                                  

                                                                                                                                                                4. Run following query to see your function logs, allow for a few minutes for Azure to deliver the logs

                                                                                                                                                                  
                                                                                                                                                                  traces
                                                                                                                                                                  | project timestamp, message
                                                                                                                                                                  | where timestamp > ago(5m)
                                                                                                                                                                  
                                                                                                                                                                5. Test is successful if the logs contain the following entry:

                                                                                                                                                                  opensearch.0: All logs successfully send to destination
                                                                                                                                                                  

                                                                                                                                                                  If the log entry is not present, please consult the Troubleshooting section for common errors and solutions.

                                                                                                                                                                2.30 -

                                                                                                                                                                Troubleshooting

                                                                                                                                                                Configure additional logging for functions:

                                                                                                                                                                1. Set EVENT_LEVEL environment variable on Protect function to Informational.
                                                                                                                                                                2. Set PTY_LOG_LEVEL environment variable on both Protect function and Log Forwarder function to config.

                                                                                                                                                                Error

                                                                                                                                                                Detail

                                                                                                                                                                
                                                                                                                                                                Unhandled exception. System.Exception: Failed to initialize 
                                                                                                                                                                function type,expecting environment variable 
                                                                                                                                                                'AzureWebJobs.AuditLogForwarder.Disabled' 
                                                                                                                                                                to be set to either 'true' or 'false'
                                                                                                                                                                
                                                                                                                                                                1. An environment variable ‘AzureWebJobs.AuditLogForwarder.Disabled’ is expected. This environment variable is added automatically when functions are deployed with ARM templates.
                                                                                                                                                                2. Verify this environment variable exists and is set to ’true’ for Protect Service functions and is set to ‘false’ for Log Forwarder functions.
                                                                                                                                                                
                                                                                                                                                                [2024/08/08 10:00:00] [error] [tls] error: unexpected EOF
                                                                                                                                                                

                                                                                                                                                                Log Forwarder failed to verify ESA certificate

                                                                                                                                                                1. If ESA is configured with self-signed certificate, verify that Log Forwarder ‘PTY_ESA_CA_SERVER_CERT’ is correctly set to ESA CA certificate string. Refer to Certificates on ESA for details.
                                                                                                                                                                2. If ESA is configured with publicly signed certificate, ensure Log Forwarder ‘PTY_LOG_LEVEL’ is set to ‘all’ level, restart and re-test the Log Forwarder. Review the logs to see if your root CA is used. If not used, you may supply your public CA in Log forwarder configuration ‘PTY_ESA_CA_SERVER_CERT’.
                                                                                                                                                                3. During initial non-production setup, SSL verification can be disabled by setting ‘PTY_ESA_DISABLE_TLS_CERT_VERIFY’ environment variable to ‘1’ or ’true’
                                                                                                                                                                
                                                                                                                                                                Failed to aggregate audit logs, 1 audit logs dropped, error: 
                                                                                                                                                                The user, group or application 'appid=;oid=;iss=' does not have 
                                                                                                                                                                secrets get permission on key vault ';location='...
                                                                                                                                                                Status: 403 (Forbidden)
                                                                                                                                                                ErrorCode: Forbidden
                                                                                                                                                                

                                                                                                                                                                Log Forwarder has no permissions to use Key Vault

                                                                                                                                                                1. Verify Log Forwarder has access to the Key Vault.
                                                                                                                                                                2. Consult section Update Function Key Vault Access Policies
                                                                                                                                                                
                                                                                                                                                                TCP connection timed out: 001.001.001.001:9200
                                                                                                                                                                

                                                                                                                                                                Log Forwarder failed to connect to ESA

                                                                                                                                                                1. Ensure ESA is available on given IP address and 9200 port
                                                                                                                                                                2. Consult section ESA Audit Store Configuration
                                                                                                                                                                
                                                                                                                                                                fail: Protect.Aggregate[0] Failed to aggregate audit logs, 
                                                                                                                                                                1 audit logs dropped, error: Invalid URI: The format of the URI 
                                                                                                                                                                could not be determined. 
                                                                                                                                                                info: iap[0] Shared memory segment POLICY does not exist: The 
                                                                                                                                                                system cannot find the file specified.
                                                                                                                                                                

                                                                                                                                                                Invalid Key Vault Uri format

                                                                                                                                                                1. Ensure that environment variable KEY_VAULT_URI has correctly formatted url.
                                                                                                                                                                2. Example 1: https://<keyvaultname>.vault.azure.net/
                                                                                                                                                                3. Example 2: https://<keyvaultname>.vault.usgovcloudapi.net/
                                                                                                                                                                
                                                                                                                                                                [Error] Azure-Messaging-EventHubs: An exception occurred while 
                                                                                                                                                                publishing a batch of events for buffered producer instance with 
                                                                                                                                                                identifier 'x' to Event Hub: audit-logs, Partition Id: '0', 
                                                                                                                                                                Operation Id: 'x'. Error Message: 'Unauthorized access.
                                                                                                                                                                

                                                                                                                                                                Protect Service function failed to send messages to Event Hub

                                                                                                                                                                1. Ensure Forwarder Function managed identity has ‘Azure Event Hubs Data Sender’ role assigned for the Event Hub resource.
                                                                                                                                                                2. See Function User-Assigned Managed Identity and Function System-Assigned Managed Identity

                                                                                                                                                                2.31 -

                                                                                                                                                                Update Policy Agent With Log Forwarder Function Target

                                                                                                                                                                Log Forwarder requires a Protegrity policy which is in sync with the Protector Service. This section will describe the steps to update the Policy Agent to include updating the Log Forwarder.

                                                                                                                                                                1. Navigate to the Policy Agent function created in Install Agent via ARM template

                                                                                                                                                                2. Select Settings > Environment variables > PROTEGRITY_PROTECT_FUNCTION

                                                                                                                                                                3. Edit the value for environment variable PROTEGRITY_PROTECT_FUNCTION to include the Log Forwarder function’s name in the comma separated list of function names.

                                                                                                                                                                4. Select Apply > Apply > Confirm to save the changes

                                                                                                                                                                5. Test Policy Agent installation as described in Test Agent Function Installation

                                                                                                                                                                2.32 -

                                                                                                                                                                Update Protect Service With Event Hub details

                                                                                                                                                                In this section, Event Hub details will be provided to the Protect Service installation.

                                                                                                                                                                1. Navigate to the Protect function environment variables.

                                                                                                                                                                2. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                                3. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                                4. Apply and Confirm to apply the changes.

                                                                                                                                                                2.33 -

                                                                                                                                                                Function User-Assigned Managed Identity

                                                                                                                                                                User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                                2. Select Create

                                                                                                                                                                3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                                4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                                5. For Region provide recorded value of ApiRegion

                                                                                                                                                                6. For Name provide a name of the new identity

                                                                                                                                                                7. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Receiver
                                                                                                                                                                8. Record Forward function user-assigned identity

                                                                                                                                                                  Forward Function User-Assigned Identity (ForwardFuncUserAssignedIdentity): ____________________

                                                                                                                                                                2.34 -

                                                                                                                                                                Log Forwarder ARM Template Parameters

                                                                                                                                                                • New Event Hub Namespace Sku Name and New Event Hub Namespace Sku Tier directly affect the quotas applied to new Event Hub instances. Review Azure Event Hub Quotas related to selected tier in Azure documentation: Azure Event Hub Quotas
                                                                                                                                                                • New Event Hub Namespace Sku Capacity: Event Hubs throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units. Capacity directly controls the purchased throughput of Event Hub instance. Review details in Azure documentation: Event Hub Instance Throughput
                                                                                                                                                                • New Event Hub Partition Count: The number of partitions represents the level of parallel log streams in the Event Hub. It is proportional to throughput capacity of the Event Hub instance. If the number of partitions is too low and the volume of audit logs is too high, a throughput ceiling may be reached on Event Hub and some audit records sent from protect function may be lost. Review details in Azure documentation: Event Hub Scalability
                                                                                                                                                                • New Event Hub Audit Log Retention In Days: Number of days audit logs are to be available in Event Hub. Applies to both primary Event Hub instance and dead-letter queue Event Hub instance. While audit logs are processed by Log Forwarder in near-realtime, it may be beneficial to keep audit logs available in Event Hub for extended period in case Log Forwarder or ESA require maintenance.
                                                                                                                                                                • Event Hub Name DLQ: Dead-letter Queue Event Hub name. This Event Hub will be used by Log Forwarder in case ESA is temporarily unavailable. Messages from DLQ Event Hub can be re-processed by another instance of Log Forwarder either manually or on schedule once ESA connectivity is restored.

                                                                                                                                                                2.35 -

                                                                                                                                                                Monitoring Log Forwarder Performance

                                                                                                                                                                • Azure Event Hub Metrics: Any positive value in ‘Throttled Requests’ metric indicates that audit logs rate from protect function is too high. The recommended actions may include:

                                                                                                                                                                  • Increase aggregation and batching intervals of Protect function by increasing values of PTY_CORE_FLUSHINTERVAL and MAX_WAIT_TIME
                                                                                                                                                                  • Increase number of partitions for Event Hub
                                                                                                                                                                  • Purchase additional capacity units for Event Hub
                                                                                                                                                                  • Use a higher Event Hub namespace tier
                                                                                                                                                                • Azure Event Hub Metrics for DLQ Event Hub: Any positive value in ‘Incoming Messages’ metric indicates that not all audit logs are being delivered to ESA. Review whether connection to ESA is set up in Audit Log Forwarder Installation

                                                                                                                                                                • Protect Function Logs: If protect function is unable to send logs to Event Hub, it will log the following message:

                                                                                                                                                                  Failed to forward {n} events to Event Hub
                                                                                                                                                                  
                                                                                                                                                                • Count number of protect operations: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                                                  traces
                                                                                                                                                                  | where timestamp >= ago(20h)
                                                                                                                                                                  | where message has 'additional_info'
                                                                                                                                                                  | parse message with * "cnt\":" Count: long *  ",\"correlation" *
                                                                                                                                                                  | summarize count_sum = sum(Count)
                                                                                                                                                                  
                                                                                                                                                                • View number of function instances on a graph: Query logs in Log Analytics workspace of Protect Service or Log Forwarder functions:

                                                                                                                                                                  requests
                                                                                                                                                                  | summarize InstanceCount = dcount(cloud_RoleInstance) by bin(timestamp, 1s)
                                                                                                                                                                  | where timestamp >= ago(2h)
                                                                                                                                                                  | order by timestamp desc
                                                                                                                                                                  | render timechart
                                                                                                                                                                  

                                                                                                                                                                2.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 protect function instances, where audit logs from consecutive requests to an instance are batched and aggregated. The second level of batching takes place in Azure Event Hub instance where log records from different protect function instances are additionally batched and sent to log forwarder function where they are aggregated.

                                                                                                                                                                These sections show 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 so that audit records are not lost.

                                                                                                                                                                2.37 -

                                                                                                                                                                Protect Service Function Environment Variables

                                                                                                                                                                • PTY_CORE_FLUSHINTERVAL: Defines for how long audit logs are aggregated before they are sent to Azure Event Hub. Default value is ten seconds. Audit logs are always aggregated into one minute buckets, therefore a value greater than sixty seconds will affect mostly the batching interval.

                                                                                                                                                                • MAX_WAIT_TIME: Defines for how long aggregated audit logs are batched before they are sent to Azure Event Hub. Default value is ten seconds.

                                                                                                                                                                  Increasing MAX_WAIT_TIME may result in:

                                                                                                                                                                  1. Increased latency or lag of audit logs arriving to Event Hub and therefore ESA

                                                                                                                                                                  2. Increased throughput rates due to fewer network requests overall

                                                                                                                                                                  3. Increased aggregation rates for values up to one minute Lowering MAX_WAIT_TIME may result in:

                                                                                                                                                                  4. Reduced latency or lag for audit logs to arrive to Event Hub and therefore ESA

                                                                                                                                                                  5. Reduced throughput rates due to higher number of network requests overall

                                                                                                                                                                  6. Reduced aggregation rates for values up to one minute It is not recommended to set MAX_WAIT_TIME lower in production workloads as it may overload the Event Hubs service. Lowering MAX_WAIT_TIME may be beneficial for speeding up log delivery to ESA in dev/test environments.

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

                                                                                                                                                                2.39 -

                                                                                                                                                                Key Vault

                                                                                                                                                                Key Vault is required to store secrets and encrypt policy deployment package. Identify existing Key Vault or create new.

                                                                                                                                                                To create Key Vault:

                                                                                                                                                                1. From the Azure Console select Create a resource.

                                                                                                                                                                2. Navigate to Key Vault > Create.

                                                                                                                                                                3. Select a Resource group.

                                                                                                                                                                4. Enter a Key vault name.

                                                                                                                                                                5. Select a Region. For the best performance, use the same region for all resources.

                                                                                                                                                                6. Set the Pricing tier to Standard.

                                                                                                                                                                7. Under Access configuration, select Vault access policy as the Permission model.

                                                                                                                                                                8. Under Networking, ensure that Enable public access is selected.

                                                                                                                                                                9. Under Review + create, click Create.

                                                                                                                                                                10. Record Key Vault Name:

                                                                                                                                                                  Key Vault Name (PolicyKeyValue): ___________________

                                                                                                                                                                2.40 -

                                                                                                                                                                Resource Group

                                                                                                                                                                Identify or create a new Azure Resource Group where the Protegrity solution will be installed. It is recommended that a new Resource group is created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some of the subsequent installation steps.

                                                                                                                                                                Azure Subscription ID (AzureSubscriptionID): ____________________

                                                                                                                                                                Azure Resource Group ID (ApiResourceGroupID): ___________________

                                                                                                                                                                Azure Region (ApiRegion): ___________________

                                                                                                                                                                2.41 -

                                                                                                                                                                Resource Group

                                                                                                                                                                Identify or create a new Azure Resource Group where the Protegrity solution will be installed. It is recommended that a new Resource group is created. This can provide greater security controls and help avoid conflicts with other applications that might impact regional account limits. An individual with the Cloud Administrator role will be required for some of the subsequent installation steps.

                                                                                                                                                                Azure Subscription ID (AzureSubscriptionID): ____________________

                                                                                                                                                                Azure Resource Group ID (AzureResourceGroupID): ___________________

                                                                                                                                                                2.42 -

                                                                                                                                                                Function App Storage

                                                                                                                                                                Create Storage Account

                                                                                                                                                                Create a storage account to host Protegrity deployment packages provided in installation artifact bundle. Note that turning on the firewall or restricting access to selected virtual networks or IP address ranges will require additional configuration and is beyond the scope of this document.

                                                                                                                                                                To create Function App storage:

                                                                                                                                                                1. From the Azure Console select Create a resource.

                                                                                                                                                                2. Navigate to Storage account > Create.

                                                                                                                                                                3. Select the Resource group where the Protegrity solution will be deployed.

                                                                                                                                                                4. Enter a Storage account name.

                                                                                                                                                                5. Select the Region where the Protegrity solution will be deployed.

                                                                                                                                                                6. Set the Preferred storage type to Azure Blob Storage or Azure Data Lake Storage

                                                                                                                                                                7. Set the Primary workload to Cloud native

                                                                                                                                                                8. Setting for Performance should be set to Standard.

                                                                                                                                                                9. Setting for Redundancy should be set to Geo-redundant storage (GRS).

                                                                                                                                                                10. Continue to Advanced setup and verify Enable hierarchical namespace is unchecked

                                                                                                                                                                11. Adjust the Networking and Data protection configurations according to your security requirements or use the default values.

                                                                                                                                                                12. Under Review + create, click Create.

                                                                                                                                                                13. Record the storage account name

                                                                                                                                                                  Storage Account Name (StorageAccountName): ____________________

                                                                                                                                                                14. Record the storage blob service URL. Navigate to created Storage Account, select Settings, Endpoints, record the value of Blob Service

                                                                                                                                                                  Storage Account Blob Service Url (StorageAccountBlobServiceUrl): ____________________

                                                                                                                                                                Upload Files

                                                                                                                                                                Create a deployment container using the Azure Blob Service.

                                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                                4. Upload the following installation artifacts to the container:

                                                                                                                                                                • protegrity-protect-azure-<version>.zip
                                                                                                                                                                • protegrity-agent-azure-<version>.zip
                                                                                                                                                                1. Record Protect function blob URL:

                                                                                                                                                                  Protect Function Blob URL (ProtectFuncURL): ____________________

                                                                                                                                                                2. Record Forward function blob URL. Both Protect and Forward functions use the same protegrity-protect-azure-<version>.zip distribution:

                                                                                                                                                                  Forward Function Blob URL (ForwardFuncURL): ____________________

                                                                                                                                                                3. Record Agent function blob URL:

                                                                                                                                                                  Agent Function Blob URL (AgentFuncURL): ____________________

                                                                                                                                                                Create Protect Function Policy Blob

                                                                                                                                                                Create a blob container for encrypted Protegrity security policy using Azure Blob Service. Agent will store encrypted policy in this container. Both Protect and Log Forwarder functions will load policy from this container.

                                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                                4. Right-click the container name, and select Container properties to obtain URL.

                                                                                                                                                                  Append the name of the policy file to the container URL, e.g, https://<your-storage-account>.blob.core.windows.net/<your-policy-container>/<your-policy-file-name>.zip. Record the blob url.

                                                                                                                                                                  Protect Function Policy Blob URL (ProtectFuncPolicyBlobUrl): ____________________

                                                                                                                                                                Create Agent Policy Blob Container

                                                                                                                                                                The Agent function uploads an encrypted policy zip package to a blob container which is used as a staging storage. Create the policy staging container

                                                                                                                                                                To prepare the policy blob container:

                                                                                                                                                                1. Under Storage account created in previous step, select Data storage > Containers and click + Container .

                                                                                                                                                                2. Type in a container name and click Create .

                                                                                                                                                                  Agent Policy Blob Container Name (AgentPolicyBlobContainer): ___________________

                                                                                                                                                                2.43 -

                                                                                                                                                                Create Agent Policy Blob Container

                                                                                                                                                                The Agent function uploads an encrypted policy zip package to a blob container which is used as a staging storage. Create the policy staging container

                                                                                                                                                                To prepare the policy blob container:

                                                                                                                                                                1. Under Storage account created in previous step, select Data storage > Containers and click + Container .

                                                                                                                                                                2. Type in a container name and click Create .

                                                                                                                                                                  Agent Policy Blob Container Name (AgentPolicyBlobContainer): ___________________

                                                                                                                                                                2.44 -

                                                                                                                                                                Create Protect Function Policy Blob

                                                                                                                                                                Create a blob container for encrypted Protegrity security policy using Azure Blob Service. Agent will store encrypted policy in this container. Both Protect and Log Forwarder functions will load policy from this container.

                                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                                4. Right-click the container name, and select Container properties to obtain URL.

                                                                                                                                                                  Append the name of the policy file to the container URL, e.g, https://<your-storage-account>.blob.core.windows.net/<your-policy-container>/<your-policy-file-name>.zip. Record the blob url.

                                                                                                                                                                  Protect Function Policy Blob URL (ProtectFuncPolicyBlobUrl): ____________________

                                                                                                                                                                2.45 -

                                                                                                                                                                Create Storage Account

                                                                                                                                                                Create a storage account to host Protegrity deployment packages provided in installation artifact bundle. Note that turning on the firewall or restricting access to selected virtual networks or IP address ranges will require additional configuration and is beyond the scope of this document.

                                                                                                                                                                To create Function App storage:

                                                                                                                                                                1. From the Azure Console select Create a resource.

                                                                                                                                                                2. Navigate to Storage account > Create.

                                                                                                                                                                3. Select the Resource group where the Protegrity solution will be deployed.

                                                                                                                                                                4. Enter a Storage account name.

                                                                                                                                                                5. Select the Region where the Protegrity solution will be deployed.

                                                                                                                                                                6. Set the Preferred storage type to Azure Blob Storage or Azure Data Lake Storage

                                                                                                                                                                7. Set the Primary workload to Cloud native

                                                                                                                                                                8. Setting for Performance should be set to Standard.

                                                                                                                                                                9. Setting for Redundancy should be set to Geo-redundant storage (GRS).

                                                                                                                                                                10. Continue to Advanced setup and verify Enable hierarchical namespace is unchecked

                                                                                                                                                                11. Adjust the Networking and Data protection configurations according to your security requirements or use the default values.

                                                                                                                                                                12. Under Review + create, click Create.

                                                                                                                                                                13. Record the storage account name

                                                                                                                                                                  Storage Account Name (StorageAccountName): ____________________

                                                                                                                                                                14. Record the storage blob service URL. Navigate to created Storage Account, select Settings, Endpoints, record the value of Blob Service

                                                                                                                                                                  Storage Account Blob Service Url (StorageAccountBlobServiceUrl): ____________________

                                                                                                                                                                2.46 -

                                                                                                                                                                Upload Files

                                                                                                                                                                Create a deployment container using the Azure Blob Service.

                                                                                                                                                                1. Go Storage Account created in the previous step.

                                                                                                                                                                2. Under Data storage section, select Containers and click + Container .

                                                                                                                                                                3. Type in container name and click Create .

                                                                                                                                                                4. Upload the following installation artifacts to the container:

                                                                                                                                                                • protegrity-protect-azure-<version>.zip
                                                                                                                                                                • protegrity-agent-azure-<version>.zip
                                                                                                                                                                1. Record Protect function blob URL:

                                                                                                                                                                  Protect Function Blob URL (ProtectFuncURL): ____________________

                                                                                                                                                                2. Record Forward function blob URL. Both Protect and Forward functions use the same protegrity-protect-azure-<version>.zip distribution:

                                                                                                                                                                  Forward Function Blob URL (ForwardFuncURL): ____________________

                                                                                                                                                                3. Record Agent function blob URL:

                                                                                                                                                                  Agent Function Blob URL (AgentFuncURL): ____________________

                                                                                                                                                                2.47 -

                                                                                                                                                                Azure Services

                                                                                                                                                                The following table describes the Azure services that may be part of your Protegrity installation.

                                                                                                                                                                All permissions in the table must be granted with the Resource group scope.

                                                                                                                                                                Service

                                                                                                                                                                Description

                                                                                                                                                                Microsoft Entra ID Application

                                                                                                                                                                Allows authentication with Azure Function app

                                                                                                                                                                Azure Managed Identity

                                                                                                                                                                Allows functions assume user-defined managed identity

                                                                                                                                                                Function App

                                                                                                                                                                Provides serverless compute for Protegrity protection operations and ESA integration to fetch policy updates or deliver audit logs.

                                                                                                                                                                API Management Service

                                                                                                                                                                Provides the end-point and access control

                                                                                                                                                                Azure Key Vault

                                                                                                                                                                Provides cryptographic keys for envelope encryption/decryption of the policy. Stores secrets required during deployment, e.g., ESA credentials

                                                                                                                                                                Blob storage

                                                                                                                                                                Intermediate storage location for the encrypted ESA policy package

                                                                                                                                                                Application Insights

                                                                                                                                                                Application and audit logs, performance monitoring, and alerts

                                                                                                                                                                Azure Event Hubs

                                                                                                                                                                Required if audit logs are to be sent to ESA. Set up and configuration of a new Event Hub is covered in section Audit Log Forwarder Installation.

                                                                                                                                                                2.48 -

                                                                                                                                                                Preparation

                                                                                                                                                                1. Ensure that all the steps in Pre-Configuration are performed.

                                                                                                                                                                2. Login to the Azure account console where Protegrity will be installed.

                                                                                                                                                                3. Ensure the Azure Resource Manager templates provided by Protegrity are available on your local computer.

                                                                                                                                                                2.49 -

                                                                                                                                                                Register an Entra ID App

                                                                                                                                                                A Microsoft Entra ID App provides the mechanism for Client to authenticate with the Function App instance. Creating an Entra ID app requires appropriate permissions to the Azure Subscription and is typically performed by the Azure Account Administrator.

                                                                                                                                                                To register an Entra ID App:

                                                                                                                                                                1. In the Azure portal navigate to Microsoft Entra ID.

                                                                                                                                                                2. Click + Add and select App registration.

                                                                                                                                                                3. Enter a Name and select Accounts in any organizational directory.

                                                                                                                                                                4. Leave the Redirect URI empty and select Register.

                                                                                                                                                                5. After registration is complete record the application name and application id displayed in the overview window.

                                                                                                                                                                  Entra ID Application Name (EntraIDApplicationName): ___________________

                                                                                                                                                                  Entra ID Application ID (EntraIDApplicationID): ___________________

                                                                                                                                                                2.50 -

                                                                                                                                                                Function System-Assigned Managed Identity

                                                                                                                                                                System-assigned Azure managed identity is enabled if user-assigned managed identity is not used. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                If you have not created a user-assigned managed identity at Protect Function User-Assigned Managed Identity, setup following role assignments for system-assigned managed identity:

                                                                                                                                                                1. Navigate to the function

                                                                                                                                                                2. Select Settings, Identity.

                                                                                                                                                                3. Confirm Status of system-assigned identity is already On on System Assigned tab

                                                                                                                                                                4. Click on Azure role assignments button.

                                                                                                                                                                5. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                                                                6. From Azure console, navigate to Function App and select protect function deployed in previous section.

                                                                                                                                                                7. Select Overview and click Restart button. Wait until function restart completes.

                                                                                                                                                                2.51 -

                                                                                                                                                                Troubleshooting

                                                                                                                                                                To review live requests, navigate to Application Insights service and select item with the same name as the protect function. Under Investigate, select Live Metrics. Wait for the dashboard to load, then go to Sample Telemetry pane on the right and look for the requests in question.

                                                                                                                                                                To review the full history of requests from Application Insights under Monitoring select Logs:

                                                                                                                                                                1. Select the Tables tab.
                                                                                                                                                                2. Hover over one of the table names under Application Insights header, for example exceptions.
                                                                                                                                                                3. Click on See preview data.
                                                                                                                                                                4. Click Use in editor.

                                                                                                                                                                You can also run the query directly in the query editor. For instance to select the 10 latest exceptions run the following query.

                                                                                                                                                                exceptions 
                                                                                                                                                                | where timestamp > ago(24h)
                                                                                                                                                                | order by timestamp
                                                                                                                                                                | limit 10
                                                                                                                                                                

                                                                                                                                                                2.52 -

                                                                                                                                                                Update Key Vault Access Policies

                                                                                                                                                                The Key vault must be updated to allow the Function App to decrypt the policy files. Azure assigns a unique identifier to each Function App instance that can be used to grant permissions to that instance. Update the Key vault access policies with the Protect function. To update the key vault access policies:

                                                                                                                                                                Obtain Function App identifier

                                                                                                                                                                1. Navigate to the Function App service in the Azure portal.

                                                                                                                                                                2. Select the newly created Protect Function App instance.

                                                                                                                                                                3. Select the Identity option under Settings.

                                                                                                                                                                4. Ensure that setting System assigned is set to Status On.

                                                                                                                                                                5. Record the Object ID:

                                                                                                                                                                  Protect Function Object ID: ___________________

                                                                                                                                                                Update the Key vault access policies with the Protect function’s Object ID

                                                                                                                                                                1. From Azure console navigate to Key Vaults, select the Key Vault created in Key Vault.
                                                                                                                                                                2. Select Access policies.
                                                                                                                                                                3. Click Create.
                                                                                                                                                                4. Select the following permissions in Permissions tab: a. Get under Key Management Operations. b. Unwrap Key under Cryptographic Operations. c. Get under Secret Permissions.
                                                                                                                                                                5. Proceed Next to Principal.
                                                                                                                                                                6. Enter the Protect Function Object ID recorded in this section into the search field.
                                                                                                                                                                7. Select the Function App instance.
                                                                                                                                                                8. Proceed Next to Application and Next again to Review + Create.
                                                                                                                                                                9. Review permissions and Create.

                                                                                                                                                                2.53 -

                                                                                                                                                                Upload the Sample Policy

                                                                                                                                                                The Protegrity installation bundle contains a sample policy which can be used to test the protect service installation without an ESA. Upload the sample policy artifact to the policy Blob storage container:

                                                                                                                                                                1. Go to Azure console and select Storage Account Name (StorageAccountName) recorded in step Create Storage Account.

                                                                                                                                                                2. Under Data storage select Blob Containers and select container created in Protect Function Policy Blob Container

                                                                                                                                                                3. Click Upload and select protegrity-sample-policy-<version>.zip file from your local computer.

                                                                                                                                                                4. Click Upload and wait for the file to complete uploading.

                                                                                                                                                                5. Record the sample policy blob url:

                                                                                                                                                                  Sample Policy Blob Url (SamplePolicyBlobUrl): ___________________

                                                                                                                                                                2.54 -

                                                                                                                                                                Protect Function User-Assigned Managed Identity

                                                                                                                                                                User-assigned Azure managed identities are optional. If a user-assigned identity is not provided, a system-assigned managed identity will be enabled the function. User-assigned managed identities offer less frequent updates to Azure resources and allow for configuration of permissions ahead of function creation.

                                                                                                                                                                1. In the search box, enter Managed Identities. Under Services, select Managed Identities

                                                                                                                                                                2. Select Create

                                                                                                                                                                3. For Subscription provide recorded value of AzureSubscriptionID

                                                                                                                                                                4. For Resource Group provide recorded value of ApiResourceGroup

                                                                                                                                                                5. For Region provide recorded value of ApiRegion

                                                                                                                                                                6. For Name provide a name of the new identity

                                                                                                                                                                7. Assign following roles to this identity:

                                                                                                                                                                  • Storage Blob Data Owner
                                                                                                                                                                  • Monitoring Metrics Publisher
                                                                                                                                                                  • Azure Event Hubs Data Sender: required only if function is sending logs to ESA
                                                                                                                                                                8. Record Protect function user-assigned identity

                                                                                                                                                                  Protect Function User-Assigned Identity (ProtectFuncUserAssignedIdentity): ____________________

                                                                                                                                                                2.55 -

                                                                                                                                                                Disable Agent Policy Deployment and Test Policy Agent Function

                                                                                                                                                                Policy agent generates a backup of pulled policy when triggered. The policy will then be deployed to Protect and Log Forwarder functions. Deployment of policies to functions should be disabled during the upgrade process.

                                                                                                                                                                Follow the steps below to disable policy deployment:

                                                                                                                                                                1. From Azure Console, navigate to Policy Agent Function App

                                                                                                                                                                2. Navigate to Settings > Environment variables.

                                                                                                                                                                3. set DISABLE_DEPLOY to 1 if it is not already set.

                                                                                                                                                                4. Stop/Start the Agent function. It may take a few minutes for the function to start.

                                                                                                                                                                2.56 -

                                                                                                                                                                Disable Protegrity Agent Function Timer Trigger

                                                                                                                                                                App Function Timer Trigger is used to periodically run Protegrity Agent Function to synchronize policy from ESA. The trigger must be disabled temporarily for the time of the upgrade process.

                                                                                                                                                                Follow the steps below to disable the Agent Function Timer Trigger.

                                                                                                                                                                1. From Azure Console, go to Function App service and select Protegrity Agent Function.

                                                                                                                                                                2. Navigate to Overview.

                                                                                                                                                                3. The functions list should contain agent function with Trigger type Timer and status Enabled.

                                                                                                                                                                4. Click on the three dots in the same row as the agent function. Then select Disable.

                                                                                                                                                                2.57 -

                                                                                                                                                                Upload Deployment Artifacts

                                                                                                                                                                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.

                                                                                                                                                                After downloading the deployment package from the Protegrity Portal, go to Azure console. Navigate to the storage account that was previously created to upload deployment artifacts (see: Agent Policy Blob Container).

                                                                                                                                                                Upload the following artifacts to the Azure storage container:

                                                                                                                                                                • protegrity-protect-<version>.zip
                                                                                                                                                                • protegrity-agent-<version>.zip

                                                                                                                                                                After upload is complete, note the blob url for each file. Blob URL may be found in the blob properties.

                                                                                                                                                                Record Blob URL values below

                                                                                                                                                                New Protect Function Blob URL: ___________________

                                                                                                                                                                New Log Forwarder Function Blob URL: ___________________

                                                                                                                                                                New Agent Function Blob URL: ___________________

                                                                                                                                                                Perform the following steps to upgrade the Policy Agent, Protect, and Log Forwarder Functions separately.

                                                                                                                                                                2.58 -

                                                                                                                                                                Re-enable Policy Agent Deployment Setting

                                                                                                                                                                Skip this step if changes were not made to the DISABLE_DEPLOY setting in previous upgrade steps

                                                                                                                                                                1. Navigate to Agent function Settings > Environment variables

                                                                                                                                                                2. Set DISABLE_DEPLOY to 0.

                                                                                                                                                                3. apply changes and restart the Agent Function App

                                                                                                                                                                2.59 -

                                                                                                                                                                Enable Protegrity Agent Function Timer Trigger

                                                                                                                                                                If the Agent Function Timer Trigger was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to enable Policy Agent Timer Trigger.

                                                                                                                                                                1. Navigate back to Protegrity Agent Function.

                                                                                                                                                                2. Select Overview.

                                                                                                                                                                3. Click on the three dots in the same row as the agent function in the list of functions. Then select Enable.

                                                                                                                                                                2.60 -

                                                                                                                                                                Test/Run Policy Agent Function to Generate Latest Policy

                                                                                                                                                                Follow the steps below to run the upgraded policy agent to refresh latest backup policy. Record the latest backup policy URL for later upgrade steps.

                                                                                                                                                                1. From Azure Console, navigate to the Policy Agent Function App

                                                                                                                                                                2. Navigate to the agent Test/Run feature as described in Test Agent Function Installation.

                                                                                                                                                                3. Run the policy agent. Verify the agent executed successfully by carefully inspecting the logs.

                                                                                                                                                                4. Use the following Azure Blob url from your Policy Agent Function Settings > Environment variables

                                                                                                                                                                  AZURE_POLICY_BLOB_URL
                                                                                                                                                                  

                                                                                                                                                                  upgraded_agent_policy_blob_url: _______________________

                                                                                                                                                                2.61 -

                                                                                                                                                                Upgrading Policy Agent Function

                                                                                                                                                                Upgrade Policy Agent Runtime Package

                                                                                                                                                                1. From Azure console, navigate to Function App service and select agent function app. Navigate to Settings > Environment variables.

                                                                                                                                                                2. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                                3. Save existing URL. You may need it to rollback upgrade.

                                                                                                                                                                  WEBSITE_RUN_FROM_PACKAGE: _______________

                                                                                                                                                                4. Replace URL with New Agent Function Blob URL.

                                                                                                                                                                5. Click Apply then select Apply and Confirm to finalize.

                                                                                                                                                                6. Using menu on the left, navigate to Overview. Stop the function using Stop button at the top. Then start it again.

                                                                                                                                                                7. In the next section the Agent function will be tested to make sure it works as expected.

                                                                                                                                                                8. (Optional) If you need to rollback to older version of Agent Function, replace WEBSITE_RUN_FROM_PACKAGE with URL recorded in previous steps.

                                                                                                                                                                2.62 -

                                                                                                                                                                Enable Protegrity Agent Function Timer Trigger

                                                                                                                                                                If the Agent Function Timer Trigger was disabled at the beginning of the upgrade process, you must re-enabled it. Follow the steps below to enable Policy Agent Timer Trigger.

                                                                                                                                                                1. Navigate back to Protegrity Agent Function.

                                                                                                                                                                2. Select Overview.

                                                                                                                                                                3. Click on the three dots in the same row as the agent function in the list of functions. Then select Enable.

                                                                                                                                                                2.63 -

                                                                                                                                                                Re-enable Policy Agent Deployment Setting

                                                                                                                                                                Skip this step if changes were not made to the DISABLE_DEPLOY setting in previous upgrade steps

                                                                                                                                                                1. Navigate to Agent function Settings > Environment variables

                                                                                                                                                                2. Set DISABLE_DEPLOY to 0.

                                                                                                                                                                3. apply changes and restart the Agent Function App

                                                                                                                                                                2.64 -

                                                                                                                                                                Finalize Log Forwarder Upgrade

                                                                                                                                                                Upgraded Log Forwarder Function will be swapped into production deployment slot to serve production traffic and re-enabled,

                                                                                                                                                                2.65 -

                                                                                                                                                                Re-Enable Log Forwarder Function Trigger

                                                                                                                                                                1. Go to your main Log Forwarder Function.

                                                                                                                                                                2. Navigate to environment variable settings Settings > Environment variables

                                                                                                                                                                3. Click on AzureWebJobs.AuditLogForwarder.Disabled configuration entry.

                                                                                                                                                                4. Replace value with false. Click Apply then Apply and Confirm to finalize.

                                                                                                                                                                2.66 -

                                                                                                                                                                Swap Upgraded Function Slot to Production

                                                                                                                                                                1. Go to your main Log Forwarder Function.

                                                                                                                                                                2. Select deployment slots.

                                                                                                                                                                3. Select Swap.

                                                                                                                                                                4. Select staging Log Forwarder Function slot as source and current Function as target.

                                                                                                                                                                5. Click Start Swap and wait until the functions are swapped.

                                                                                                                                                                6. If you need to rollback, swap the application slots again.

                                                                                                                                                                2.67 -

                                                                                                                                                                Upgrading Log Forwarder Function

                                                                                                                                                                2.68 -

                                                                                                                                                                Disable Log Forwarder Event Hub Trigger

                                                                                                                                                                Disabling the Event Hub trigger will prevent audit log delivery during the upgrade process. This reduces the chance for any duplicate or lost audit logs. Later steps will indicate when this trigger may be re-enabled.

                                                                                                                                                                Follow the steps below to disable the Event Hub trigger:

                                                                                                                                                                1. From Azure Console, go to Function App service and select Protegrity Log Forwarder Function.

                                                                                                                                                                2. Navigate to Overview.

                                                                                                                                                                3. The functions list should contain AuditLogForwarder function with Trigger type Event Hub and Status Enabled.

                                                                                                                                                                4. Click on the three dots in the same row as the AuditLogForwarder function. Then select Disable.

                                                                                                                                                                2.69 -

                                                                                                                                                                Create Staging Deployment Slot (Log Forwarder)

                                                                                                                                                                Creating new deployment slot allows updating the function such that it may easily be rolled back. Log Forwarder Function will be disabled during the upgrade process. Logs generated during this time will be processed once Log Forwarder is re-enabled

                                                                                                                                                                1. From Azure console, navigate to Function App service and select the Log Forwarder Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                                                2. Click Add slot. Specify slot name.

                                                                                                                                                                3. Click Add. Wait for the slot to be created.

                                                                                                                                                                4. After the slot is added, select Close to close the dialog box.

                                                                                                                                                                5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done, you will swap staging slot with production slot.

                                                                                                                                                                6. Click on the new deployment slot. This will open the newly created replica of Log Forwarder Function.

                                                                                                                                                                7. Navigate to the staging Function App environment variable settings Settings > Environment variables

                                                                                                                                                                8. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                                9. Replace value with New Log Forwarder Function Blob URL. Click Apply.

                                                                                                                                                                10. Click on AZURE_POLICY_BLOB_URL configuration entry.

                                                                                                                                                                11. Replace value with upgraded_agent_policy_blob_url. Click Apply.

                                                                                                                                                                12. Click Apply and Confirm to push the configuration changes.

                                                                                                                                                                2.70 -

                                                                                                                                                                Upgrading Protect Function

                                                                                                                                                                Diagram below illustrates upgrade steps.

                                                                                                                                                                Azure Protect Function Upgrade Steps

                                                                                                                                                                2.71 -

                                                                                                                                                                Create Staging Deployment Slot (Protector)

                                                                                                                                                                Creating new deployment slot allows updating the function without interruptions to the existing traffic.

                                                                                                                                                                1. From Azure console, navigate to Function App service and select the Protect Function App to upgrade. Navigate to Deployments > Deployment Slots.

                                                                                                                                                                2. Click Add slot. Specify slot name.

                                                                                                                                                                3. Click Add. Wait for the slot to be created.

                                                                                                                                                                4. After the slot is added, select Close to close the dialog box.

                                                                                                                                                                5. There should be a new slot available in the list of deployment slots. You will use this deployment slot as staging for the upgraded function. After upgrade is done and tested, you will swap staging slot with production slot.

                                                                                                                                                                6. Click on the new deployment slot. This will open the newly created replica of Cloud Protect Function.

                                                                                                                                                                7. Copy the function URL from the overview window.

                                                                                                                                                                  Staging Protect Function URL: ________________

                                                                                                                                                                8. Navigate to Identity section under Settings.

                                                                                                                                                                9. If your installation utilizes System Assigned Identity:

                                                                                                                                                                  1. Select System Assigned tab and switch Status On. Click Save.

                                                                                                                                                                  2. This will generate the Object ID for the newly deployed function in the deployment slot.

                                                                                                                                                                  3. Add Role Assignments to the identity as described in section Function System-Assigned Managed Identity

                                                                                                                                                                  4. Use the Object ID to update Key Vault policy to allow function in the deployment slot to use policy encryption key. See Protect Function Key Vault Access Policies for instructions how to update Key Vault policy.

                                                                                                                                                                10. If your installation utilizes User Assigned Identity:

                                                                                                                                                                  1. Select User Assigned tab

                                                                                                                                                                  2. Select Add. Choose the identity in use on the production function, then complete by selecting Add again.

                                                                                                                                                                11. Navigate to App Keys section from the menu on the left. Record default key value under Host Keys section.

                                                                                                                                                                  Staging Protect Function Default Host Key: ________________

                                                                                                                                                                12. Navigate to the staging Function App Settings > Environment variables

                                                                                                                                                                13. Click on WEBSITE_RUN_FROM_PACKAGE configuration entry.

                                                                                                                                                                14. Replace value with New Protect Function Blob URL.

                                                                                                                                                                15. Set EVENTHUB_NAME to the output value recorded in Install Log Forwarder via ARM template for the newly deployed log forwarder.

                                                                                                                                                                16. Set EventHub__fullyQualifiedNamespace to the output value recorded in Install Log Forwarder via ARM template.

                                                                                                                                                                17. Click Apply, then Apply to finalize.

                                                                                                                                                                2.72 -

                                                                                                                                                                Load Production Policy and Test New Protect Function In Staging

                                                                                                                                                                1. Navigate to the new staging Protect function Settings > Environment variables

                                                                                                                                                                2. Set AZURE_POLICY_BLOB_URL environment variable to the upgraded_agent_policy_blob_url value recorded in previous steps.

                                                                                                                                                                3. Start/Stop the protect function.

                                                                                                                                                                4. Test New Protect Function in staging. You can use curl command below, replacing Staging Protect Function URL and Staging Protect Function Default Host Key with values recorded in previous section.

                                                                                                                                                                curl -X POST "<Staging Protect Function URL>/api/Protect" -k \
                                                                                                                                                                -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 'x-functions-key: <Staging Protect Function Default Host Key>' \
                                                                                                                                                                -H 'Content-Type: application/json' \
                                                                                                                                                                -d '{
                                                                                                                                                                  "data": [
                                                                                                                                                                    ["0", "UtfVk UHgcD!"]
                                                                                                                                                                  ]
                                                                                                                                                                }'
                                                                                                                                                                
                                                                                                                                                                curl -X POST "<Protect Function URL>/api/v1/protect" -k \
                                                                                                                                                                -H 'x-functions-key: <Protect Function app key>' \
                                                                                                                                                                -H 'Content-Type: application/json' \
                                                                                                                                                                -d '{
                                                                                                                                                                  "data": ["test"],
                                                                                                                                                                  "user": "test",
                                                                                                                                                                  "data_element": "test"
                                                                                                                                                                }'
                                                                                                                                                                

                                                                                                                                                                2.73 -

                                                                                                                                                                Finalize Protector upgrade

                                                                                                                                                                Upgraded Protect Function can now be swapped in to production deployment slot to serve production traffic.

                                                                                                                                                                1. Go to your main Protect Function.

                                                                                                                                                                2. Select deployment slots.

                                                                                                                                                                3. Select Swap.

                                                                                                                                                                4. Select staging Protect Function slot as source and production Function as target.

                                                                                                                                                                5. Click swap and wait until the functions are swapped.

                                                                                                                                                                6. If you need to rollback swap the application slots again.

                                                                                                                                                                3 - GCP

                                                                                                                                                                Protegrity products for GCP.

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

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

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

                                                                                                                                                                    3.1.3 - Installation

                                                                                                                                                                    Product Installation Guide.

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

                                                                                                                                                                      3.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: ___________________

                                                                                                                                                                        3.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}
                                                                                                                                                                            

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

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                3.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=="}]}}}
                                                                                                                                                                                

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

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

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

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

                                                                                                                                                                                3.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>
                                                                                                                                                                                        }
                                                                                                                                                                                      ]
                                                                                                                                                                                    }
                                                                                                                                                                                  }
                                                                                                                                                                                }
                                                                                                                                                                                

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

                                                                                                                                                                                3.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=="}]}}}
                                                                                                                                                                                

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

                                                                                                                                                                                3.1.5 - Performance

                                                                                                                                                                                Performance benchmarks and considerations.

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

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

                                                                                                                                                                                  3.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"
                                                                                                                                                                                          }
                                                                                                                                                                                        }
                                                                                                                                                                                    

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

                                                                                                                                                                                    3.1.8 - Upgrading To The Latest Version

                                                                                                                                                                                    Instructions for upgrading the protector.

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

                                                                                                                                                                                    3.1.10 - Appendices

                                                                                                                                                                                    Additional references for the protector.

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

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

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

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

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

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

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

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

                                                                                                                                                                                            3.2.3 - Installation

                                                                                                                                                                                            Product Installation Guide.

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

                                                                                                                                                                                              3.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: ___________________

                                                                                                                                                                                                3.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!"]}
                                                                                                                                                                                                    

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

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

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

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

                                                                                                                                                                                                        3.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\""
                                                                                                                                                                                                          

                                                                                                                                                                                                          3.2.5 - Performance

                                                                                                                                                                                                          Performance benchmarks and considerations.

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

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

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

                                                                                                                                                                                                          3.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"
                                                                                                                                                                                                                  }
                                                                                                                                                                                                                }
                                                                                                                                                                                                            

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

                                                                                                                                                                                                            3.2.8 - Upgrading To The Latest Version

                                                                                                                                                                                                            Instructions for upgrading the protector.

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

                                                                                                                                                                                                            3.2.10 - Appendices

                                                                                                                                                                                                            Additional references for the protector.

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                                                3.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.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.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.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.3 - Installation

                                                                                                                                                                                                                    Product Installation Guide.

                                                                                                                                                                                                                    3.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.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.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.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.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.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.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.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.3.4 - Understanding Snowflake Objects

                                                                                                                                                                                                                                  Key concepts in understanding the Protegrity Serverless with Snowflake.

                                                                                                                                                                                                                                  3.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.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.3.5 - Performance

                                                                                                                                                                                                                                  Performance benchmarks and considerations.

                                                                                                                                                                                                                                  3.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.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.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.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.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.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.3.8 - Upgrading To The Latest Version

                                                                                                                                                                                                                                    Instructions for upgrading the protector.

                                                                                                                                                                                                                                    3.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.3.10 - Appendices

                                                                                                                                                                                                                                    Additional references for the protector.

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

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

                                                                                                                                                                                                                                        3.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: _______________

                                                                                                                                                                                                                                        3.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: _______________

                                                                                                                                                                                                                                        3.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: ___________________

                                                                                                                                                                                                                                        3.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): ___________________

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

                                                                                                                                                                                                                                        3.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" 
                                                                                                                                                                                                                                          

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                                                                        3.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: ___________________

                                                                                                                                                                                                                                        3.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: ___________________

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

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

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

                                                                                                                                                                                                                                        3.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: __________________

                                                                                                                                                                                                                                        3.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: ___________________

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

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

                                                                                                                                                                                                                                        3.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: _________________

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

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

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

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

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

                                                                                                                                                                                                                                        3.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: ___________________

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

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

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

                                                                                                                                                                                                                                        3.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: ___________________

                                                                                                                                                                                                                                        3.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: ___________________

                                                                                                                                                                                                                                        3.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: ___________________

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

                                                                                                                                                                                                                                        3.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: ___________________

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

                                                                                                                                                                                                                                        3.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: ___________________

                                                                                                                                                                                                                                        3.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:___________________

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

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

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

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

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

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

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

                                                                                                                                                                                                                                        3.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: ___________________

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

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

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

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

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

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

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

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

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

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

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

                                                                                                                                                                                                                                        4 -

                                                                                                                                                                                                                                        Payload Encoding

                                                                                                                                                                                                                                        The following encoding formats are supported in the REST API.

                                                                                                                                                                                                                                        For every encoding, the resultant protected data is returned in the same encoding. For example, if request is hex-encoded, the response is also hex-encoded.

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

                                                                                                                                                                                                                                        Encoding

                                                                                                                                                                                                                                        Supported by data elements

                                                                                                                                                                                                                                        Notes

                                                                                                                                                                                                                                        utf8

                                                                                                                                                                                                                                        All except binary data elements.

                                                                                                                                                                                                                                        Default encoding if encoding is not specified.

                                                                                                                                                                                                                                        hex

                                                                                                                                                                                                                                        All

                                                                                                                                                                                                                                        Default encoding for binary data elements.

                                                                                                                                                                                                                                        base64

                                                                                                                                                                                                                                        All

                                                                                                                                                                                                                                        base64_mime

                                                                                                                                                                                                                                        All

                                                                                                                                                                                                                                        • Uses RFC 2045 Alphabet.
                                                                                                                                                                                                                                        • Accepts input on multiple lines.
                                                                                                                                                                                                                                        • Lines can be separated by any combination of CR and LF characters.
                                                                                                                                                                                                                                        • Lines must not be longer than 76 characters long.
                                                                                                                                                                                                                                        • Response lines are separated by CRLF characters.
                                                                                                                                                                                                                                        • Optional padding.
                                                                                                                                                                                                                                        • Does not accept any non-base64 characters.

                                                                                                                                                                                                                                        base64_pem

                                                                                                                                                                                                                                        All

                                                                                                                                                                                                                                        • Uses RFC 1421 Alphabet.
                                                                                                                                                                                                                                        • Accepts input on multiple lines.
                                                                                                                                                                                                                                        • Lines can be separated by any combination of CR and LF characters.
                                                                                                                                                                                                                                        • Lines must not be longer than 64 characters long.
                                                                                                                                                                                                                                        • Response lines are separated by CRLF characters.
                                                                                                                                                                                                                                        • Optional padding.
                                                                                                                                                                                                                                        • Does not accept any non-base64 characters.

                                                                                                                                                                                                                                        base64_url

                                                                                                                                                                                                                                        All

                                                                                                                                                                                                                                        The following sections provide the payload schema and its examples.

                                                                                                                                                                                                                                        5 -

                                                                                                                                                                                                                                        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=="}]}}}
                                                                                                                                                                                                                                        

                                                                                                                                                                                                                                        6 -

                                                                                                                                                                                                                                        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.

                                                                                                                                                                                                                                        7 -

                                                                                                                                                                                                                                        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 (Audit Store) or 24284 (td-agent).

                                                                                                                                                                                                                                        2. Audit Store service is configured and running on ESA. Applies when audit logs are output to Audit Store directly or through td-agent. For information related to ESA Audit Store configuration, refer to Audit Store Guide.

                                                                                                                                                                                                                                        3. (Optional) td-agent is configured for external input. For more information related to td-agent configuration, refer to ESA guide Sending logs to an external security information and event management (SIEM).

                                                                                                                                                                                                                                        8 -

                                                                                                                                                                                                                                        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

                                                                                                                                                                                                                                        9 -

                                                                                                                                                                                                                                        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.

                                                                                                                                                                                                                                        10 -

                                                                                                                                                                                                                                        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.

                                                                                                                                                                                                                                        11 -

                                                                                                                                                                                                                                        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.

                                                                                                                                                                                                                                        12 -

                                                                                                                                                                                                                                        Prerequisites

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

                                                                                                                                                                                                                                        13 -

                                                                                                                                                                                                                                        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

                                                                                                                                                                                                                                        14 -

                                                                                                                                                                                                                                        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';
                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                        

                                                                                                                                                                                                                                        15 -

                                                                                                                                                                                                                                          © 2026 Protegrity Corporation. All rights reserved.
                                                                                                                                                                                                                                          IP Attributions

                                                                                                                                                                                                                                          The information provided in this documentation is “as is” with no guarantee of accuracy or completeness.