-
Notifications
You must be signed in to change notification settings - Fork 0
Demos 1197 UI path lambda #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dustbuster
wants to merge
45
commits into
main
Choose a base branch
from
DEMOS-1197-UI-PATH-lammy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 7008cb3
DEMOS-1197: some minor tweaks after node_mod added
dustbuster 7cc4b49
DEMOS-1197: basic TS UI Path configured
dustbuster a6e48dc
DEMOS-1197: got the SQS scripted and usage of it.
dustbuster cea8ada
DEMOS-1197: Minor clean up of some comments
dustbuster 007c1bb
DEMOS-1197: updated the env var to use better desc
dustbuster 2321b97
DEMOS-1197: fixed issue with import.meta
dustbuster 728c679
DEMOS-1197: Removed the UI path stack.
dustbuster 4628ddd
DEMOS-1197: added tests for stack/constructor
dustbuster 61acbe6
DEMOS-1197: updated bundle option
dustbuster 723ceca
DEMOS-1197: added an updated env var
dustbuster dc0061f
DEMOS-1197: updated ENV vars to start with UIPATH_
dustbuster 19ad6a4
DEMOS-1197: debugging changed env vars
dustbuster 8255eb1
DEMOS-1197: working locally version with URL fixed
dustbuster 7e978e7
DEMOS-1197: adding try catch back in place
dustbuster 4e2d801
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster 32835c1
DEMOS-1197: removed the error for after while loop
dustbuster 748a3b1
DEMOS-1197: added localstack lambda and sqs
dustbuster f5df9ff
DEMOS-1197: got this working,. but UI path is not
dustbuster 51a032b
DEMOS-1197: did some clean on a double try catch
dustbuster ccddd86
DEMOS-1197: added gitignore for generated lam zip
dustbuster d7d60c0
DEMOS-1197: test corrections
dustbuster e2509f2
DEMOS-1197: removed some items from the env example
dustbuster 370e42f
DEMOS-1197: removed a gitignore i used for dev
dustbuster 7a53fbb
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster 6107f73
DEMOS-1197: some minor clean up of variable names
dustbuster 54d5c0e
DEMOS-1197: some minor updates based on feedback
dustbuster f4cd6c5
DEMOS-1197: simplified the lambda setup
dustbuster 39b507d
DEMOS-1197: removing a dep that isn't used
dustbuster ed271ee
DEMOS-1197: fixing errors
dustbuster 2c1673b
DEMOS-1197: corrected bad package json path
dustbuster 44b4259
DEMOS-1197: copied same strat as fileupload
dustbuster 8323703
DEMOS-1197: added packages to deployemnt list
dustbuster 480389f
DEMOS-1197: removing deps path
dustbuster e1a5ec8
DEMOS-1197: trying this without deps
dustbuster 9db3351
DEMOS-1197: adding in ALL the thins to nodeModules
dustbuster d8c7fd5
DEMOS-1197: Updated some cjm stuff
dustbuster 0fe7f24
DEMOS-1197: pointimg the packages at its own lock file
dustbuster 443f722
DEMOS-1197: added console logs to find the paths
dustbuster 53e1934
DEMOS-1197: added KMS rules one by one.
dustbuster e1499f0
DEMOS-1197: couple adjustment to time outs
dustbuster ef2f6c4
DEMOS-1197: changed name to uipath
dustbuster ac47e3b
Merge branch 'main' into DEMOS-1197-UI-PATH-lammy
dustbuster 3af9ea6
DEMOS-1197: added S3 support
dustbuster d33e941
DEMOS-1222: adding the localstack lamda enw featrs
dustbuster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| version: "3.8" | ||
|
|
||
| services: | ||
| app: | ||
| build: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
dustbuster marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| **/dist/** | ||
| **/build/** | ||
| **/node_modules/** | ||
| **/tmp/** | ||
|
|
||
| cdk.out/ | ||
| cdk.context.json | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.