Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2cc326e
DEMOS-1197: the work begins on the UI path
dustbuster Nov 25, 2025
7008cb3
DEMOS-1197: some minor tweaks after node_mod added
dustbuster Nov 26, 2025
7cc4b49
DEMOS-1197: basic TS UI Path configured
dustbuster Nov 28, 2025
a6e48dc
DEMOS-1197: got the SQS scripted and usage of it.
dustbuster Dec 1, 2025
cea8ada
DEMOS-1197: Minor clean up of some comments
dustbuster Dec 1, 2025
007c1bb
DEMOS-1197: updated the env var to use better desc
dustbuster Dec 1, 2025
2321b97
DEMOS-1197: fixed issue with import.meta
dustbuster Dec 1, 2025
728c679
DEMOS-1197: Removed the UI path stack.
dustbuster Dec 2, 2025
4628ddd
DEMOS-1197: added tests for stack/constructor
dustbuster Dec 2, 2025
61acbe6
DEMOS-1197: updated bundle option
dustbuster Dec 3, 2025
723ceca
DEMOS-1197: added an updated env var
dustbuster Dec 3, 2025
dc0061f
DEMOS-1197: updated ENV vars to start with UIPATH_
dustbuster Dec 3, 2025
19ad6a4
DEMOS-1197: debugging changed env vars
dustbuster Dec 3, 2025
8255eb1
DEMOS-1197: working locally version with URL fixed
dustbuster Dec 4, 2025
7e978e7
DEMOS-1197: adding try catch back in place
dustbuster Dec 4, 2025
4e2d801
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster Dec 4, 2025
32835c1
DEMOS-1197: removed the error for after while loop
dustbuster Dec 4, 2025
748a3b1
DEMOS-1197: added localstack lambda and sqs
dustbuster Dec 4, 2025
f5df9ff
DEMOS-1197: got this working,. but UI path is not
dustbuster Dec 5, 2025
51a032b
DEMOS-1197: did some clean on a double try catch
dustbuster Dec 8, 2025
ccddd86
DEMOS-1197: added gitignore for generated lam zip
dustbuster Dec 8, 2025
d7d60c0
DEMOS-1197: test corrections
dustbuster Dec 8, 2025
e2509f2
DEMOS-1197: removed some items from the env example
dustbuster Dec 8, 2025
370e42f
DEMOS-1197: removed a gitignore i used for dev
dustbuster Dec 8, 2025
7a53fbb
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster Dec 9, 2025
6107f73
DEMOS-1197: some minor clean up of variable names
dustbuster Dec 9, 2025
54d5c0e
DEMOS-1197: some minor updates based on feedback
dustbuster Dec 9, 2025
f4cd6c5
DEMOS-1197: simplified the lambda setup
dustbuster Dec 9, 2025
39b507d
DEMOS-1197: removing a dep that isn't used
dustbuster Dec 9, 2025
ed271ee
DEMOS-1197: fixing errors
dustbuster Dec 9, 2025
2c1673b
DEMOS-1197: corrected bad package json path
dustbuster Dec 9, 2025
44b4259
DEMOS-1197: copied same strat as fileupload
dustbuster Dec 9, 2025
8323703
DEMOS-1197: added packages to deployemnt list
dustbuster Dec 9, 2025
480389f
DEMOS-1197: removing deps path
dustbuster Dec 9, 2025
e1a5ec8
DEMOS-1197: trying this without deps
dustbuster Dec 9, 2025
9db3351
DEMOS-1197: adding in ALL the thins to nodeModules
dustbuster Dec 9, 2025
d8c7fd5
DEMOS-1197: Updated some cjm stuff
dustbuster Dec 9, 2025
0fe7f24
DEMOS-1197: pointimg the packages at its own lock file
dustbuster Dec 10, 2025
443f722
DEMOS-1197: added console logs to find the paths
dustbuster Dec 10, 2025
53e1934
DEMOS-1197: added KMS rules one by one.
dustbuster Dec 10, 2025
e1499f0
DEMOS-1197: couple adjustment to time outs
dustbuster Dec 10, 2025
ef2f6c4
DEMOS-1197: changed name to uipath
dustbuster Dec 10, 2025
ac47e3b
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster Dec 11, 2025
3af9ea6
DEMOS-1197: added S3 support
dustbuster Dec 12, 2025
d33e941
DEMOS-1222: adding the localstack lamda enw featrs
dustbuster Dec 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
app:
build:
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/localstack/setup/setup_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CORS_CONFIG='{
]
}'

BUCKETS=("upload-bucket" "clean-bucket" "deleted-bucket" "infected-bucket")
BUCKETS=("upload-bucket" "clean-bucket" "deleted-bucket" "infected-bucket" "uipath-documents")

# Delete all existing buckets first
echo "🗑️ Removing existing buckets..."
Expand Down Expand Up @@ -164,6 +164,7 @@ echo " - upload-bucket: EventBridge → transforms to GuardDuty ($SCAN_RESULT_
echo " - infected-bucket: Manual expiration simulation → infected-file-expiration-queue → deleteinfectedfile Lambda"
echo " - clean-bucket: Storage for clean files"
echo " - deleted-bucket: Storage for deleted files"
echo " - uipath-documents: Storage for UiPath document understanding flows"
echo ""
echo "💡 To simulate lifecycle expiration in LocalStack:"
echo " .devcontainer/localstack/debug/delete-infected-file.sh <object-key>"
19 changes: 18 additions & 1 deletion .devcontainer/localstack/setup/setup_secrets_manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ AWS_REGION="us-east-1"
AWS_CMD="aws --endpoint-url=$LOCALSTACK_ENDPOINT --region $AWS_REGION"

DB_PASSWORD="postgres" # pragma: allowlist secret
UIPATH_SECRET_ID=${UIPATH_SECRET_ID:-"uipath-credentials"}
UIPATH_CLIENT_ID=${UIPATH_CLIENT_ID:-"local-uipath-client-id"}
UIPATH_CLIENT_SECRET=${UIPATH_CLIENT_SECRET:-"local-uipath-client-secret"} # pragma: allowlist secret

# Delete existing secret
$AWS_CMD secretsmanager delete-secret \
Expand All @@ -23,7 +26,21 @@ $AWS_CMD secretsmanager create-secret \
\"password\": \"$DB_PASSWORD\",
\"host\": \"db\",
\"port\": \"5432\",
\"dbname\": \"demos\"
\"dbname\": \"demos\",
}" >/dev/null

# Delete existing UiPath secret
$AWS_CMD secretsmanager delete-secret \
--secret-id "$UIPATH_SECRET_ID" \
--force-delete-without-recovery 2>/dev/null || true

# Create UiPath client credential secret for local development
$AWS_CMD secretsmanager create-secret \
--name "$UIPATH_SECRET_ID" \
--description "UiPath client credentials for local development" \
--secret-string "{
\"clientId\": \"$UIPATH_CLIENT_ID\",
\"clientSecret\": \"$UIPATH_CLIENT_SECRET\"
}" >/dev/null

echo "✅ Secrets Manager ready"
31 changes: 31 additions & 0 deletions .devcontainer/localstack/setup/setup_sqs_queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,36 @@ echo " Queue ARN: $INFECTED_QUEUE_ARN"
echo " DLQ ARN: $INFECTED_DLQ_ARN"
echo " Note: Messages sent manually via delete-infected-file.sh script"

# ============================================================================
# UiPath Queue (for document understanding pipeline)
# ============================================================================
echo "Creating UiPath queue..."

UIPATH_DLQ_URL=$($AWS_CMD sqs create-queue \
--queue-name uipath-dlq \
--attributes '{"MessageRetentionPeriod":"1209600"}' \
--output text --query 'QueueUrl')

UIPATH_DLQ_ARN=$($AWS_CMD sqs get-queue-attributes \
--queue-url $UIPATH_DLQ_URL \
--attribute-names QueueArn \
--output text --query 'Attributes.QueueArn')

UIPATH_REDRIVE_POLICY="{\"deadLetterTargetArn\":\"$UIPATH_DLQ_ARN\",\"maxReceiveCount\":\"5\"}"

UIPATH_QUEUE_URL=$($AWS_CMD sqs create-queue \
--queue-name uipath-queue \
--attributes "{\"RedrivePolicy\":\"$(echo $UIPATH_REDRIVE_POLICY | sed 's/"/\\"/g')\",\"MessageRetentionPeriod\":\"1209600\"}" \
--output text --query 'QueueUrl')

UIPATH_QUEUE_ARN=$($AWS_CMD sqs get-queue-attributes \
--queue-url $UIPATH_QUEUE_URL \
--attribute-names QueueArn \
--output text --query 'Attributes.QueueArn')

echo "✅ UiPath queue created"
echo " Queue ARN: $UIPATH_QUEUE_ARN"
echo " DLQ ARN: $UIPATH_DLQ_ARN"

echo ""
echo "✅ All SQS queues setup complete"
122 changes: 122 additions & 0 deletions .devcontainer/localstack/setup/setup_uipath_lambda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/bash
set -e

echo "🚀 Deploying UiPath Lambda function..."

LOCALSTACK_ENDPOINT="http://localstack:4566"

AWS_REGION="us-east-1"
AWS_CMD="aws --endpoint-url=$LOCALSTACK_ENDPOINT --region $AWS_REGION"

QUEUE_NAME="uipath-queue"
LAMBDA_NAME="uipath"

UIPATH_SECRET_ID=${UIPATH_SECRET_ID:-"uipath-credentials"}
UIPATH_PROJECT_ID=${UIPATH_PROJECT_ID:-"00000000-0000-0000-0000-000000000000"} # pragma: allowlist secret

UIPATH_EXTRACTOR_GUID=${UIPATH_EXTRACTOR_GUID:-""}
UIPATH_CLIENT_ID=${UIPATH_CLIENT_ID:-""}
UIPATH_DOCUMENT_BUCKET=${UIPATH_DOCUMENT_BUCKET:-"uipath-documents"}
DATABASE_SECRET_ARN=${DATABASE_SECRET_ARN:-"database-secret"}
UIPATH_QUESTIONS_QUERY=${UIPATH_QUESTIONS_QUERY:-"select question->>'id' as id, question->>'question' as question, question->>'fieldType' as field_type, (question->>'multiValued')::boolean as multi_valued from document_understanding_questions"}
LOG_LEVEL=${LOG_LEVEL:-"info"}

# Build Lambda package
cd /workspaces/demos/lambdas/UIPath

npm ci --silent
npx esbuild index.ts \
--bundle \
--platform=node \
--target=node18 \
--format=esm \
--sourcemap \
--external:@aws-sdk/* \
--external:pg \
--external:pino \
--external:axios \
--external:form-data \
--external:axios-oauth-client \
--external:dotenv \
--outfile=index.js

zip -qr uipath.zip index.js node_modules/ package.json package-lock.json ak-behavioral-health-demo-pa.pdf

# Clean up build artifacts
rm index.js index.js.map

cd - > /dev/null

# Delete existing Lambda if exists
$AWS_CMD lambda delete-function --function-name $LAMBDA_NAME 2>/dev/null || true

# Create Lambda function
$AWS_CMD lambda create-function \
--function-name $LAMBDA_NAME \
--runtime nodejs18.x \
--role arn:aws:iam::000000000000:role/lambda-execution-role \
--handler index.handler \
--zip-file fileb:///workspaces/demos/lambdas/UIPath/uipath.zip \
--timeout 900 \
--environment "Variables={
AWS_REGION=$AWS_REGION,
AWS_ENDPOINT_URL=$LOCALSTACK_ENDPOINT,
UIPATH_SECRET_ID=$UIPATH_SECRET_ID,
UIPATH_CLIENT_ID=$UIPATH_CLIENT_ID,
UIPATH_PROJECT_ID=$UIPATH_PROJECT_ID,
UIPATH_EXTRACTOR_GUID=$UIPATH_EXTRACTOR_GUID,
UIPATH_DOCUMENT_BUCKET=$UIPATH_DOCUMENT_BUCKET,
DATABASE_SECRET_ARN=$DATABASE_SECRET_ARN,
UIPATH_QUESTIONS_QUERY=$UIPATH_QUESTIONS_QUERY,
LOG_LEVEL=$LOG_LEVEL
}" >/dev/null

# Wait for Lambda to be active
echo "⏳ Waiting for UiPath Lambda to be active..."
for i in {1..15}; do
STATUS=$($AWS_CMD lambda get-function \
--function-name $LAMBDA_NAME \
--query 'Configuration.State' \
--output text 2>/dev/null || echo "Pending")

if [ "$STATUS" = "Active" ]; then
echo "✅ UiPath Lambda function created"
break
elif [ "$STATUS" = "Failed" ]; then
echo "❌ UiPath Lambda function failed to initialize in 30 seconds"
exit 1
fi
sleep 2
done

# Get queue ARN
QUEUE_URL=$($AWS_CMD sqs get-queue-url --queue-name $QUEUE_NAME --output text --query 'QueueUrl')
QUEUE_ARN=$($AWS_CMD sqs get-queue-attributes \
--queue-url $QUEUE_URL \
--attribute-names QueueArn \
--output text --query 'Attributes.QueueArn')

echo "📬 Connecting UiPath Lambda to UiPath SQS queue..."

# Delete existing event source mappings
EXISTING_MAPPINGS=$($AWS_CMD lambda list-event-source-mappings \
--function-name $LAMBDA_NAME \
--query 'EventSourceMappings[].UUID' \
--output text 2>/dev/null || echo "")

if [ -n "$EXISTING_MAPPINGS" ]; then
for UUID in $EXISTING_MAPPINGS; do
$AWS_CMD lambda delete-event-source-mapping --uuid $UUID >/dev/null 2>&1 || true
done
fi

# Create event source mapping (SQS -> Lambda)
$AWS_CMD lambda create-event-source-mapping \
--function-name $LAMBDA_NAME \
--event-source-arn $QUEUE_ARN \
--batch-size 1 \
--enabled \
> /dev/null

echo "✅ UiPath Lambda connected to UiPath SQS queue"
echo " Queue ARN: $QUEUE_ARN"
12 changes: 8 additions & 4 deletions .devcontainer/localstack/setup_localstack.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ echo "4️⃣ Setting up fileprocess Lambda..."
bash /workspaces/demos/.devcontainer/localstack/setup/setup_fileprocess_lambda.sh

echo ""
echo "5️⃣ Setting up deleteinfectedfile Lambda..."
echo "5️⃣ Setting up UiPath Lambda..."
bash /workspaces/demos/.devcontainer/localstack/setup/setup_uipath_lambda.sh

echo ""
echo "6️⃣ Setting up deleteinfectedfile Lambda..."
bash /workspaces/demos/.devcontainer/localstack/setup/setup_deleteinfectedfile_lambda.sh

echo ""
echo "✅ LocalStack setup complete!"
echo ""
echo "📋 Resources created:"
echo " - Secrets Manager: database credentials"
echo " - SQS Queues: fileupload-queue, fileprocess-queue, infected-file-expiration-queue (+ DLQs)"
echo " - Secrets Manager: database credentials, UiPath credentials"
echo " - SQS Queues: fileupload-queue, fileprocess-queue, infected-file-expiration-queue, uipath-queue (+ DLQs)"
echo " - S3 Buckets: upload-bucket, clean-bucket, infected-bucket, deleted-bucket"
echo " - Lambda Functions: fileprocess, deleteinfectedfile"
echo " - Lambda Functions: fileprocess, uipath, deleteinfectedfile"
echo " - EventBridge Rules: s3-upload-to-guardduty"
echo ""
echo "🧪 Test the setup:"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/dist/**
**/build/**
**/node_modules/**
**/tmp/**

cdk.out/
cdk.context.json
Expand Down
Loading