Event-driven image moderation and notification with AWS CDK
Project description
cdk-image-moderation
Event-driven image moderation and notification service with AWS CDK
Sample
This sample create a S3 bucket that will trigger image moderation check on object created and send notification to SNS when specific moderation labels are detected. The SNS2Telegram
creates a Lambda function as the SNS topic subscription which fires the notification to a private Telegram chatroom with the image preview and moderation result.
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
from cdk_image_moderation import Moderation, SNS2Telegram
app = cdk.App()
env = {
"region": process.env.CDK_DEFAULT_REGION,
"account": process.env.CDK_DEFAULT_ACCOUNT
}
stack = cdk.Stack(app, "moderation-demo", env=env)
# create the moderation
mod = Moderation(stack, "Mod",
moderation_labels=[ModerationLabels.EXPLICIT_NUDITY, ModerationLabels.DRUGS, ModerationLabels.TOBACCO, ModerationLabels.ALCOHOL, ModerationLabels.VIOLENCE, ModerationLabels.RUDE_GESTURES
]
)
# send notification via sns to telegram
SNS2Telegram(stack, "SNS2TG",
topic=mod.topic,
chatid="-547476398"
)
Deploy the CDK app
export TELEGRAM_TOKEN=<YOUR_TOKEN>
cdk diff
cdk deploy
Deploy from this repository
export TELEGRAM_TOKEN=<YOUR_TOKEN>
# run `yarn build` or `yarn watch` to generate the lib
cdk --app lib/integ.default.js diff
cdk --app lib/integ.default.js deploy
On deploy completed, you will get the S3 bucket in the Outputs
. Simply upload any images into this bucket and you should be able to get the notification from the Telegram chatroom.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cdk-image-moderation-0.1.141.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 878d31c36a17f307febd2aca2159b58a2f18d3343a0801715b6758c59cd23a12 |
|
MD5 | 3f0ed7bae282213796c7a28ca70884f0 |
|
BLAKE2b-256 | d1f6448c3c0857686615f39a7059ac1ec751f094d429d1da811fff24f260c4c4 |
Hashes for cdk_image_moderation-0.1.141-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9674b53f9ea8da3e2c965c683f27f7ded61f49122d4b00d9597e261ae710f467 |
|
MD5 | f2c7365aef8236f86ee3e062d767001a |
|
BLAKE2b-256 | e9baf941d2f4c63e79d34ea5e05c711c24852c160ae7cff18dfcf3098b46b447 |