Protect Service Installation
Preparation
Ensure that all the steps in Pre-Configuration are performed.
Login to the AWS account console where Amazon Redshift Protector will be installed.
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:
From the AWS IAM console, select Policies > Create Policy.
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/*" ] } ] }For the KMS policy, replace the Resource with the ARN for the KMS key created in a previous step.
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:
From the AWS IAM console, select Roles > Create Role.
Select AWS Service > Lambda > Next.
In the list, search and select the policy created in Create Protect Lambda IAM Execution Policy.
Click Next
Type the role name, for example, ProtegrityProtectRole
Click Create role
Record the role ARN.
Role ARN (LambdaExecutionRoleArn): ___________________
Install through CloudFormation
The following steps describe the deployment of the Lambda function.
To install through CloudFormation:
Access CloudFormation and select the target AWS Region in the console.
Click Create Stack and choose With new resources.
Specify the template.
Select Upload a template file.
Upload the Protegrity-provided CloudFormation template called pty_protect_cf.json and click Next.
Specify the stack details. Enter a stack name.
Note
The stack name will be appended to all the services created by the template.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.
Note
See Configuring Regular Expression to Extract Policy Username to learn how to extract username from the requestIf 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 Parameters Description KinesisLogStreamArn The ARN of the AWS Kinesis stream where audit logs will be sent for aggregation AuditLogFlushInterval Time interval in seconds used to accumulate audit logs before sending to Kinesis. Default value: 30. See Log Forwarder Performance section for more details. Proceed to the last step of the Create Stack wizard with defaults and click Submit to create CloudFormation stack.
Select Outputs tab of the stack after stack is created.
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:
From Services, access API Gateway.
Select the API Gateway service that is created.
Note
Sort by Created date. The name will have the same extension as the stack name created aboveClick Actions > Delete.
Add Lambda Protect IAM Permissions to Role
To add inline Lambda Protect IAM permissions to role:
Select the role created in section Create IAM Account Role (DBRoleName).
Tip
Sort descending by created date.In the Permissions tab, click Add inline policy.
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:*" } ] }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.
Note
This step is not required when the Protegrity Solution is not installed on the same AWS account as Amazon Redshift Cluster. For more information about Cross-Account Installation, refer to Cross-Account Configuration.Attach the IAM role (DBRoleName) created in Create IAM Account Role to the Redshift cluster.
To attach IAM account role to Redshift:
From the AWS console, access Amazon Redshift and click on the cluster.
Select Actions > Manage IAM Roles.
Under Available IAM roles, select Enter ARN.
Enter the Role ARN recorded in Create Protect Lambda IAM Role.
Click Add IAM role.
Note
After attaching the role, wait for the cluster to complete modification status (in the cluster status) before proceeding to test connectivity.
Test Connectivity
Perform the following steps to verify if Redshift is working correctly with the Protegrity product.
To test the connectivity:
Access the Redshift SQL console.
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>Replace the placeholder values with the lambda function name and role created in earlier steps.
Run the following command in the console:
select pty_unprotect_alpha('UtfVk UHgcD!')Verify that the string hello world! is returned.
Troubleshooting Tips
Error | Action |
|---|---|
Empty result or Invalid operation error |
|
What’s Next
Feedback
Was this page helpful?