# cdk-comprehend-s3olap
[![License](https://img.shields.io/badge/License-Apache%202.0-green)](https://opensource.org/licenses/Apache-2.0) [![Release](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/actions/workflows/release.yml/badge.svg)](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/actions/workflows/release.yml) [![npm downloads](https://img.shields.io/npm/dt/cdk-comprehend-s3olap?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/cdk-comprehend-s3olap?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/cdk-comprehend-s3olap?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/cdk-comprehend-s3olap?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Comprehend.S3olap?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Comprehend.S3olap?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-comprehend-s3olap?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-comprehend-s3olap?label=repo%20languages&style=plastic)
| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |
| --- | --- | --- | --- | --- |
| [Link](https://www.npmjs.com/package/cdk-comprehend-s3olap) | [Link](https://pypi.org/project/cdk_comprehend_s3olap/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/cdk-comprehend-s3olap) | [Link](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap-go) | [Link](https://www.nuget.org/packages/Comprehend.S3olap/) |
This construct creates the foundation for developers to explore the combination of Amazon S3 Object Lambda and Amazon Comprehend for PII scenarios and it is designed with flexibility, i.e, the developers could tweak arguments via CDK to see how AWS services work and behave.
# Table of Contents
* [Serverless Architecture](#serverless-architecture)
* [Access Control](#access-control)
* [Redaction](#rerfaction)
* [Introduction](#introduction)
* [Example](#example)
* [Typescript](#typescript)
* [Python](#python)
* [Java](#java)
* [C#](#c)
* [Some Notes](#some-notes)
# Serverless Architecture
## Access Control
**Data Flow**
![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/1-2891.jpg)
*Ram R. and Austin Q., 2021*
**Arhictecture**
![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/2-2891.jpg)
*Ram R. and Austin Q., 2021*
## Redaction
![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/3-2891.jpg)
*Ram R. and Austin Q., 2021*
![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/4-2891.jpg)
*Ram R. and Austin Q., 2021*
# Introduction
The architecture was introduced by **Ram Ramani** and **Austin Quam** and was posted on the AWS Blog as [*Protect PII using Amazon S3 Object Lambda to process and modify data during retrieval*](https://aws.amazon.com/tw/blogs/machine-learning/protect-pii-using-amazon-s3-object-lambda-to-process-and-modify-data-during-retrieval/).
I converted the architecture into a CDK constrcut for 4 programming languages. With this construct, you could manage the properties of IAM roles, the Lambda functions with Amazon Comprehend, and few for the constrcut.
Before deploying the construct via the CDK, you could either places the text files, i.e., those for the access control case and redaction case, under a directory with a specific name as the following or just deploying directly yet you need to upload the text files onto the S3 buckets manually yourself. It's all your choie.
```bash
# For the access control case.
$ cd ${ROOT_DIRECTORY_CDK_APPLICATION}
$ mkdir -p files/access_control
$ curl -o survey-results.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/access-control/survey-results.txt
$ curl -o innocuous.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/access-control/innocuous.txt
# For the redaction case.
$ cd ${ROOT_DIRECTORY_CDK_APPLICATION}
$ mkdir -p files/redaction
$ curl -o transcript.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/redaction/transcript.txt
```
# Example
## Typescript
You could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/typescript).
```bash
$ cdk --init language typescript
$ yarn add cdk-comprehend-s3olap
```
```python
import * as cdk from '@aws-cdk/core';
import { ComprehendS3olab } from 'cdk-comprehend-s3olap';
class TypescriptStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const s3olab = new ComprehendS3olab(this, 'PiiDemo', {
adminRedactionLambdaConfig: {
maskCharacter: ' ',
unsupportedFileHandling: 'PASS',
},
billingRedactionLambdaConfig: {
maskMode: 'REPLACE_WITH_PII_ENTITY_TYPE',
piiEntityTypes: 'AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN',
},
cusrtSupportRedactionLambdaConfig: {
maskMode: 'REPLACE_WITH_PII_ENTITY_TYPE',
piiEntityTypes: ' BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN',
},
});
new cdk.CfnOutput(this, 'OPiiAccessControlLambdaArn', { value: s3olab.piiAccessConrtolLambdaArn });
new cdk.CfnOutput(this, 'OAdminLambdaArn', { value: s3olab.adminLambdaArn });
new cdk.CfnOutput(this, 'OBillingLambdaArn', { value: s3olab.billingLambdaArn });
new cdk.CfnOutput(this, 'OCustomerSupportLambdaArn', { value: s3olab.customerSupportLambdaArn });
new cdk.CfnOutput(this, 'OS3ObjectLambdaGeneralArn', { value: s3olab.s3objectLambdaAccessControlArn });
new cdk.CfnOutput(this, 'OS3ObjectLambdaAdminArn', { value: s3olab.s3objectLambdaAdminArn });
new cdk.CfnOutput(this, 'OS3ObjectLambdaBillingArn', { value: s3olab.s3objectLambdaBillingArn });
new cdk.CfnOutput(this, 'OS3ObjectLambdaCustomerSupportArn', { value: s3olab.customerSupportLambdaArn });
}
}
const app = new cdk.App();
new TypescriptStack(app, 'TypescriptStack', {
stackName: 'Comprehend-S3olap',
});
```
## Python
You could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/python).
```bash
# upgrading related Python packages
$ python -m ensurepip --upgrade
$ python -m pip install --upgrade pip
$ python -m pip install --upgrade virtualenv
# initialize a CDK Python project
$ cdk init --language python
# make packages installed locally instead of globally
$ source .venv/bin/activate
$ # add "cdk-comprehend-s3olap==2.0.113" into `setup.py`
$ python -m pip install --upgrade -r requirements.txt
```
The demonstration sample code of Python can be viewed via the Python tab of this package on the [Constrcut Hub](https://constructs.dev/).
## Java
You could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/java).
```bash
$ cdk init --language java
$ mvn package # If you include the construct, you need to tweak the test case for Java in order to package with success via Maven.
```xml
.
.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cdk.version>2.72.1</cdk.version>
<constrcut.verion>2.0.113</constrcut.verion>
<junit.version>5.7.1</junit.version>
</properties>
.
.
<dependencies>
<!-- AWS Cloud Development Kit -->
<dependency>
<groupId>software.amazon.awscdk</groupId>
<artifactId>core</artifactId>
<version>${cdk.version}</version>
</dependency>
<dependency>
<groupId>io.github.hsiehshujeng</groupId>
<artifactId>cdk-comprehend-s3olap</artifactId>
<version>${constrcut.verion}</version>
</dependency>
.
.
.
</dependencies>
```
```java
package com.myorg;
import software.amazon.awscdk.core.CfnOutput;
import software.amazon.awscdk.core.CfnOutputProps;
import software.amazon.awscdk.core.Construct;
import software.amazon.awscdk.core.Stack;
import software.amazon.awscdk.core.StackProps;
import io.github.hsiehshujeng.cdk.comprehend.s3olap.RedactionLambdaProps;
import io.github.hsiehshujeng.cdk.comprehend.s3olap.ComprehendS3olab;
import io.github.hsiehshujeng.cdk.comprehend.s3olap.ComprehendS3olabProps;
public class JavaStack extends Stack {
public JavaStack(final Construct scope, final String id) {
this(scope, id, null);
}
public JavaStack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);
ComprehendS3olab s3olab = new ComprehendS3olab(this, "PiiDemo", ComprehendS3olabProps.builder()
.adminRedactionLambdaConfig(
RedactionLambdaProps.builder()
.maskCharacter(" ")
.unsupportedFileHandling("PASS").build())
.billingRedactionLambdaConfig(
RedactionLambdaProps.builder()
.maskMode("REPLACE_WITH_PII_ENTITY_TYPE")
.piiEntityTypes("AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN")
.build())
.cusrtSupportRedactionLambdaConfig(
RedactionLambdaProps.builder()
.maskMode("REPLACE_WITH_PII_ENTITY_TYPE")
.piiEntityTypes("BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN")
.build())
.exampleFileDir("/opt/learning/cdk-comprehend-s3olap/src/demo/java")
.build()
);
new CfnOutput(this, "OPiiAccessControlLambdaArn", CfnOutputProps.builder().value(s3olab.getPiiAccessConrtolLambdaArn()).build());
new CfnOutput(this, "OAdminLambdaArn", CfnOutputProps.builder().value(s3olab.getAdminLambdaArn()).build());
new CfnOutput(this, "OBillingLambdaArn", CfnOutputProps.builder().value(s3olab.getBillingLambdaArn()).build());
new CfnOutput(this, "OCustomerSupportLambdaArn", CfnOutputProps.builder().value(s3olab.getCustomerSupportLambdaArn()).build());
new CfnOutput(this, "OS3ObjectLambdaGeneralArn", CfnOutputProps.builder().value(s3olab.getS3objectLambdaAccessControlArn()).build());
new CfnOutput(this, "OS3ObjectLambdaAdminArn", CfnOutputProps.builder().value(s3olab.getS3objectLambdaAdminArn()).build());
new CfnOutput(this, "OS3ObjectLambdaBillingArn", CfnOutputProps.builder().value(s3olab.getS3objectLambdaBillingArn()).build());
new CfnOutput(this, "OS3ObjectLambdaCustomerSupportArn", CfnOutputProps.builder().value(s3olab.getCustomerSupportLambdaArn()).build());
}
}
```
## C#
You could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/csharp).
```bash
$ cdk init --language csharp
$ dotnet add src/Csharp package Comprehend.S3olap --version 2.0.113
```
```cs
using Amazon.CDK;
using ScottHsieh.Cdk;
namespace Csharp
{
public class CsharpStack : Stack
{
internal CsharpStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
var S3olab = new ComprehendS3olab(this, "PiiDemo", new ComprehendS3olabProps
{
AdminRedactionLambdaConfig = new RedactionLambdaProps
{
MaskCharacter = " ",
UnsupportedFileHandling = "PASS"
},
BillingRedactionLambdaConfig = new RedactionLambdaProps
{
MaskMode = "REPLACE_WITH_PII_ENTITY_TYPE",
PiiEntityTypes = "AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN"
},
CusrtSupportRedactionLambdaConfig = new RedactionLambdaProps
{
MaskMode = "REPLACE_WITH_PII_ENTITY_TYPE",
PiiEntityTypes = "BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN"
},
ExampleFileDir = "/opt/learning/cdk-comprehend-s3olap/src/demo/csharp"
});
new CfnOutput(this, "OPiiAccessControlLambdaArn", new CfnOutputProps { Value = S3olab.PiiAccessConrtolLambdaArn });
new CfnOutput(this, "OAdminLambdaArn", new CfnOutputProps { Value = S3olab.AdminLambdaArn });
new CfnOutput(this, "OBillingLambdaArn", new CfnOutputProps { Value = S3olab.BillingLambdaArn });
new CfnOutput(this, "OCustomerSupportLambdaArn", new CfnOutputProps { Value = S3olab.CustomerSupportLambdaArn });
new CfnOutput(this, "OS3ObjectLambdaGeneralArn", new CfnOutputProps { Value = S3olab.S3objectLambdaAccessControlArn });
new CfnOutput(this, "OS3ObjectLambdaAdminArn", new CfnOutputProps { Value = S3olab.S3objectLambdaAdminArn });
new CfnOutput(this, "OS3ObjectLambdaBillingArn", new CfnOutputProps { Value = S3olab.S3objectLambdaBillingArn });
new CfnOutput(this, "OS3ObjectLambdaCustomerSupportArn", new CfnOutputProps { Value = S3olab.CustomerSupportLambdaArn });
}
}
}
```
# Some Notes
1. You should see similar items as the following diagram displays after deploying the constrcut.
![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-comprehend-s3olap/main/images/s3olap_console.png)
2. After creating the foundation with success, you could switch roles that the consrtcut creates for you and see how **Amazon S3 Object Lambda** works. For what switching roles is, please refer to [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html) for the detail.
![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-comprehend-s3olap/main/images/switch_roles.png)
3. You explore **Amazon S3 Object Lambda** through the Object Lambda access points on the AWS Console and open or download the text files via one of the IAM roles.
4. Lambda code that incorporates with **Amazon Comprehend** could be see [here](https://github.com/aws-samples/amazon-comprehend-examples/tree/master/s3_object_lambda_pii_protection_blog).
Raw data
{
"_id": null,
"home_page": "https://github.com/HsiehShuJeng/cdk-comprehend-s3olap.git",
"name": "cdk-comprehend-s3olap",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Shu-Jeng Hsieh",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0d/ae/9f994a35e9d0b7ec4e24c1c6e0dce808f979516b6438119daca771e40cb0/cdk_comprehend_s3olap-2.0.527.tar.gz",
"platform": null,
"description": "# cdk-comprehend-s3olap\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-green)](https://opensource.org/licenses/Apache-2.0) [![Release](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/actions/workflows/release.yml/badge.svg)](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/actions/workflows/release.yml) [![npm downloads](https://img.shields.io/npm/dt/cdk-comprehend-s3olap?label=npm%20downloads&style=plastic)](https://img.shields.io/npm/dt/cdk-comprehend-s3olap?label=npm%20downloads&style=plastic) [![pypi downloads](https://img.shields.io/pypi/dm/cdk-comprehend-s3olap?label=pypi%20downloads&style=plastic)](https://img.shields.io/pypi/dm/cdk-comprehend-s3olap?label=pypi%20downloads&style=plastic) [![NuGet downloads](https://img.shields.io/nuget/dt/Comprehend.S3olap?label=NuGet%20downloads&style=plastic)](https://img.shields.io/nuget/dt/Comprehend.S3olap?label=NuGet%20downloads&style=plastic) [![repo languages](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-comprehend-s3olap?label=repo%20languages&style=plastic)](https://img.shields.io/github/languages/count/HsiehShuJeng/cdk-comprehend-s3olap?label=repo%20languages&style=plastic)\n\n| npm (JS/TS) | PyPI (Python) | Maven (Java) | Go | NuGet |\n| --- | --- | --- | --- | --- |\n| [Link](https://www.npmjs.com/package/cdk-comprehend-s3olap) | [Link](https://pypi.org/project/cdk_comprehend_s3olap/) | [Link](https://search.maven.org/artifact/io.github.hsiehshujeng/cdk-comprehend-s3olap) | [Link](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap-go) | [Link](https://www.nuget.org/packages/Comprehend.S3olap/) |\n\nThis construct creates the foundation for developers to explore the combination of Amazon S3 Object Lambda and Amazon Comprehend for PII scenarios and it is designed with flexibility, i.e, the developers could tweak arguments via CDK to see how AWS services work and behave.\n\n# Table of Contents\n\n* [Serverless Architecture](#serverless-architecture)\n\n * [Access Control](#access-control)\n * [Redaction](#rerfaction)\n* [Introduction](#introduction)\n* [Example](#example)\n\n * [Typescript](#typescript)\n * [Python](#python)\n * [Java](#java)\n * [C#](#c)\n* [Some Notes](#some-notes)\n\n# Serverless Architecture\n\n## Access Control\n\n**Data Flow**\n![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/1-2891.jpg)\n*Ram R. and Austin Q., 2021*\n**Arhictecture**\n![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/2-2891.jpg)\n*Ram R. and Austin Q., 2021*\n\n## Redaction\n\n![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/3-2891.jpg)\n*Ram R. and Austin Q., 2021*\n![image](https://d2908q01vomqb2.cloudfront.net/f1f836cb4ea6efb2a0b1b99f41ad8b103eff4b59/2021/05/07/4-2891.jpg)\n*Ram R. and Austin Q., 2021*\n\n# Introduction\n\nThe architecture was introduced by **Ram Ramani** and **Austin Quam** and was posted on the AWS Blog as [*Protect PII using Amazon S3 Object Lambda to process and modify data during retrieval*](https://aws.amazon.com/tw/blogs/machine-learning/protect-pii-using-amazon-s3-object-lambda-to-process-and-modify-data-during-retrieval/).\nI converted the architecture into a CDK constrcut for 4 programming languages. With this construct, you could manage the properties of IAM roles, the Lambda functions with Amazon Comprehend, and few for the constrcut.\nBefore deploying the construct via the CDK, you could either places the text files, i.e., those for the access control case and redaction case, under a directory with a specific name as the following or just deploying directly yet you need to upload the text files onto the S3 buckets manually yourself. It's all your choie.\n\n```bash\n# For the access control case.\n$ cd ${ROOT_DIRECTORY_CDK_APPLICATION}\n$ mkdir -p files/access_control\n$ curl -o survey-results.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/access-control/survey-results.txt\n$ curl -o innocuous.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/access-control/innocuous.txt\n# For the redaction case.\n$ cd ${ROOT_DIRECTORY_CDK_APPLICATION}\n$ mkdir -p files/redaction\n$ curl -o transcript.txt https://raw.githubusercontent.com/aws-samples/amazon-comprehend-examples/master/s3_object_lambda_pii_protection_blog/redaction/transcript.txt\n```\n\n# Example\n\n## Typescript\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/typescript).\n\n```bash\n$ cdk --init language typescript\n$ yarn add cdk-comprehend-s3olap\n```\n\n```python\nimport * as cdk from '@aws-cdk/core';\nimport { ComprehendS3olab } from 'cdk-comprehend-s3olap';\n\nclass TypescriptStack extends cdk.Stack {\n constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {\n super(scope, id, props);\n const s3olab = new ComprehendS3olab(this, 'PiiDemo', {\n adminRedactionLambdaConfig: {\n maskCharacter: ' ',\n unsupportedFileHandling: 'PASS',\n },\n billingRedactionLambdaConfig: {\n maskMode: 'REPLACE_WITH_PII_ENTITY_TYPE',\n piiEntityTypes: 'AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN',\n },\n cusrtSupportRedactionLambdaConfig: {\n maskMode: 'REPLACE_WITH_PII_ENTITY_TYPE',\n piiEntityTypes: ' BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN',\n },\n });\n\n new cdk.CfnOutput(this, 'OPiiAccessControlLambdaArn', { value: s3olab.piiAccessConrtolLambdaArn });\n new cdk.CfnOutput(this, 'OAdminLambdaArn', { value: s3olab.adminLambdaArn });\n new cdk.CfnOutput(this, 'OBillingLambdaArn', { value: s3olab.billingLambdaArn });\n new cdk.CfnOutput(this, 'OCustomerSupportLambdaArn', { value: s3olab.customerSupportLambdaArn });\n new cdk.CfnOutput(this, 'OS3ObjectLambdaGeneralArn', { value: s3olab.s3objectLambdaAccessControlArn });\n new cdk.CfnOutput(this, 'OS3ObjectLambdaAdminArn', { value: s3olab.s3objectLambdaAdminArn });\n new cdk.CfnOutput(this, 'OS3ObjectLambdaBillingArn', { value: s3olab.s3objectLambdaBillingArn });\n new cdk.CfnOutput(this, 'OS3ObjectLambdaCustomerSupportArn', { value: s3olab.customerSupportLambdaArn });\n }\n}\n\nconst app = new cdk.App();\nnew TypescriptStack(app, 'TypescriptStack', {\n stackName: 'Comprehend-S3olap',\n});\n```\n\n## Python\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-databrew-cicd/tree/main/src/demo/python).\n\n```bash\n# upgrading related Python packages\n$ python -m ensurepip --upgrade\n$ python -m pip install --upgrade pip\n$ python -m pip install --upgrade virtualenv\n# initialize a CDK Python project\n$ cdk init --language python\n# make packages installed locally instead of globally\n$ source .venv/bin/activate\n$ # add \"cdk-comprehend-s3olap==2.0.113\" into `setup.py`\n$ python -m pip install --upgrade -r requirements.txt\n```\n\nThe demonstration sample code of Python can be viewed via the Python tab of this package on the [Constrcut Hub](https://constructs.dev/).\n\n## Java\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/java).\n\n```bash\n$ cdk init --language java\n$ mvn package # If you include the construct, you need to tweak the test case for Java in order to package with success via Maven.\n```xml\n.\n.\n<properties>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n <cdk.version>2.72.1</cdk.version>\n <constrcut.verion>2.0.113</constrcut.verion>\n <junit.version>5.7.1</junit.version>\n</properties>\n.\n.\n<dependencies>\n <!-- AWS Cloud Development Kit -->\n <dependency>\n <groupId>software.amazon.awscdk</groupId>\n <artifactId>core</artifactId>\n <version>${cdk.version}</version>\n </dependency>\n <dependency>\n <groupId>io.github.hsiehshujeng</groupId>\n <artifactId>cdk-comprehend-s3olap</artifactId>\n <version>${constrcut.verion}</version>\n </dependency>\n .\n .\n .\n</dependencies>\n```\n\n```java\npackage com.myorg;\n\nimport software.amazon.awscdk.core.CfnOutput;\nimport software.amazon.awscdk.core.CfnOutputProps;\nimport software.amazon.awscdk.core.Construct;\nimport software.amazon.awscdk.core.Stack;\nimport software.amazon.awscdk.core.StackProps;\nimport io.github.hsiehshujeng.cdk.comprehend.s3olap.RedactionLambdaProps;\nimport io.github.hsiehshujeng.cdk.comprehend.s3olap.ComprehendS3olab;\nimport io.github.hsiehshujeng.cdk.comprehend.s3olap.ComprehendS3olabProps;\n\npublic class JavaStack extends Stack {\n public JavaStack(final Construct scope, final String id) {\n this(scope, id, null);\n }\n\n public JavaStack(final Construct scope, final String id, final StackProps props) {\n super(scope, id, props);\n\n ComprehendS3olab s3olab = new ComprehendS3olab(this, \"PiiDemo\", ComprehendS3olabProps.builder()\n .adminRedactionLambdaConfig(\n RedactionLambdaProps.builder()\n .maskCharacter(\" \")\n .unsupportedFileHandling(\"PASS\").build())\n .billingRedactionLambdaConfig(\n RedactionLambdaProps.builder()\n .maskMode(\"REPLACE_WITH_PII_ENTITY_TYPE\")\n .piiEntityTypes(\"AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN\")\n .build())\n .cusrtSupportRedactionLambdaConfig(\n RedactionLambdaProps.builder()\n .maskMode(\"REPLACE_WITH_PII_ENTITY_TYPE\")\n .piiEntityTypes(\"BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN\")\n .build())\n .exampleFileDir(\"/opt/learning/cdk-comprehend-s3olap/src/demo/java\")\n .build()\n );\n\n new CfnOutput(this, \"OPiiAccessControlLambdaArn\", CfnOutputProps.builder().value(s3olab.getPiiAccessConrtolLambdaArn()).build());\n new CfnOutput(this, \"OAdminLambdaArn\", CfnOutputProps.builder().value(s3olab.getAdminLambdaArn()).build());\n new CfnOutput(this, \"OBillingLambdaArn\", CfnOutputProps.builder().value(s3olab.getBillingLambdaArn()).build());\n new CfnOutput(this, \"OCustomerSupportLambdaArn\", CfnOutputProps.builder().value(s3olab.getCustomerSupportLambdaArn()).build());\n new CfnOutput(this, \"OS3ObjectLambdaGeneralArn\", CfnOutputProps.builder().value(s3olab.getS3objectLambdaAccessControlArn()).build());\n new CfnOutput(this, \"OS3ObjectLambdaAdminArn\", CfnOutputProps.builder().value(s3olab.getS3objectLambdaAdminArn()).build());\n new CfnOutput(this, \"OS3ObjectLambdaBillingArn\", CfnOutputProps.builder().value(s3olab.getS3objectLambdaBillingArn()).build());\n new CfnOutput(this, \"OS3ObjectLambdaCustomerSupportArn\", CfnOutputProps.builder().value(s3olab.getCustomerSupportLambdaArn()).build());\n }\n}\n```\n\n## C#\n\nYou could also refer to [here](https://github.com/HsiehShuJeng/cdk-comprehend-s3olap/tree/main/src/demo/csharp).\n\n```bash\n$ cdk init --language csharp\n$ dotnet add src/Csharp package Comprehend.S3olap --version 2.0.113\n```\n\n```cs\nusing Amazon.CDK;\nusing ScottHsieh.Cdk;\n\nnamespace Csharp\n{\n public class CsharpStack : Stack\n {\n internal CsharpStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)\n {\n var S3olab = new ComprehendS3olab(this, \"PiiDemo\", new ComprehendS3olabProps\n {\n AdminRedactionLambdaConfig = new RedactionLambdaProps\n {\n MaskCharacter = \" \",\n UnsupportedFileHandling = \"PASS\"\n },\n BillingRedactionLambdaConfig = new RedactionLambdaProps\n {\n MaskMode = \"REPLACE_WITH_PII_ENTITY_TYPE\",\n PiiEntityTypes = \"AGE,DRIVER_ID,IP_ADDRESS,MAC_ADDRESS,PASSPORT_NUMBER,PASSWORD,SSN\"\n },\n CusrtSupportRedactionLambdaConfig = new RedactionLambdaProps\n {\n MaskMode = \"REPLACE_WITH_PII_ENTITY_TYPE\",\n PiiEntityTypes = \"BANK_ACCOUNT_NUMBER,BANK_ROUTING,CREDIT_DEBIT_CVV,CREDIT_DEBIT_EXPIRY,CREDIT_DEBIT_NUMBER,SSN\"\n },\n ExampleFileDir = \"/opt/learning/cdk-comprehend-s3olap/src/demo/csharp\"\n });\n\n new CfnOutput(this, \"OPiiAccessControlLambdaArn\", new CfnOutputProps { Value = S3olab.PiiAccessConrtolLambdaArn });\n new CfnOutput(this, \"OAdminLambdaArn\", new CfnOutputProps { Value = S3olab.AdminLambdaArn });\n new CfnOutput(this, \"OBillingLambdaArn\", new CfnOutputProps { Value = S3olab.BillingLambdaArn });\n new CfnOutput(this, \"OCustomerSupportLambdaArn\", new CfnOutputProps { Value = S3olab.CustomerSupportLambdaArn });\n new CfnOutput(this, \"OS3ObjectLambdaGeneralArn\", new CfnOutputProps { Value = S3olab.S3objectLambdaAccessControlArn });\n new CfnOutput(this, \"OS3ObjectLambdaAdminArn\", new CfnOutputProps { Value = S3olab.S3objectLambdaAdminArn });\n new CfnOutput(this, \"OS3ObjectLambdaBillingArn\", new CfnOutputProps { Value = S3olab.S3objectLambdaBillingArn });\n new CfnOutput(this, \"OS3ObjectLambdaCustomerSupportArn\", new CfnOutputProps { Value = S3olab.CustomerSupportLambdaArn });\n }\n }\n}\n```\n\n# Some Notes\n\n1. You should see similar items as the following diagram displays after deploying the constrcut.\n ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-comprehend-s3olap/main/images/s3olap_console.png)\n2. After creating the foundation with success, you could switch roles that the consrtcut creates for you and see how **Amazon S3 Object Lambda** works. For what switching roles is, please refer to [here](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html) for the detail.\n ![image](https://raw.githubusercontent.com/HsiehShuJeng/cdk-comprehend-s3olap/main/images/switch_roles.png)\n3. You explore **Amazon S3 Object Lambda** through the Object Lambda access points on the AWS Console and open or download the text files via one of the IAM roles.\n4. Lambda code that incorporates with **Amazon Comprehend** could be see [here](https://github.com/aws-samples/amazon-comprehend-examples/tree/master/s3_object_lambda_pii_protection_blog).\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A constrcut for PII and redaction scenarios with Amazon Comprehend and S3 Object Lambda",
"version": "2.0.527",
"project_urls": {
"Homepage": "https://github.com/HsiehShuJeng/cdk-comprehend-s3olap.git",
"Source": "https://github.com/HsiehShuJeng/cdk-comprehend-s3olap.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3a8662efa3b5041188cb279c5f3a9ca4835f350ba4b33f580e923d4e23129139",
"md5": "7efdf6616904f0a52c053264a9205e86",
"sha256": "fb94011bde45492a6e93be863d247cf4d5af8f5b523af2fff05ec8b1c21322d1"
},
"downloads": -1,
"filename": "cdk_comprehend_s3olap-2.0.527-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7efdf6616904f0a52c053264a9205e86",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 13278255,
"upload_time": "2024-10-07T00:53:13",
"upload_time_iso_8601": "2024-10-07T00:53:13.270438Z",
"url": "https://files.pythonhosted.org/packages/3a/86/62efa3b5041188cb279c5f3a9ca4835f350ba4b33f580e923d4e23129139/cdk_comprehend_s3olap-2.0.527-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0dae9f994a35e9d0b7ec4e24c1c6e0dce808f979516b6438119daca771e40cb0",
"md5": "df97e6b1ab851e1cbb1ac7ed481bfe58",
"sha256": "f854c922f4f371354a171fc00104ad1e4b4ee9af5ea55deb9526236f3785f366"
},
"downloads": -1,
"filename": "cdk_comprehend_s3olap-2.0.527.tar.gz",
"has_sig": false,
"md5_digest": "df97e6b1ab851e1cbb1ac7ed481bfe58",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 13280236,
"upload_time": "2024-10-07T00:53:16",
"upload_time_iso_8601": "2024-10-07T00:53:16.323763Z",
"url": "https://files.pythonhosted.org/packages/0d/ae/9f994a35e9d0b7ec4e24c1c6e0dce808f979516b6438119daca771e40cb0/cdk_comprehend_s3olap-2.0.527.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-07 00:53:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "HsiehShuJeng",
"github_project": "cdk-comprehend-s3olap",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cdk-comprehend-s3olap"
}