-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Syncing S3 and Knowledge Base with Premium Examples #7597
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26e7c3f
configured actions workflow for syncing S3, KB and added premium-ex f…
94d4133
adding imp comments
67b302c
testing for cpp
aab3151
fixed linting yaml errors and adding rust prem-ex
04852c2
making cred flow fixes and updating rust exs
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
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 |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| name: syncS3andKB | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
| inputs: | ||
| sdk_name: | ||
| description: 'SDK Name' | ||
| required: true | ||
| default: 'python' | ||
| type: choice | ||
| options: | ||
| - javascriptv3 | ||
| - dotnetv4 | ||
| - javav2 | ||
| - rustv1 | ||
| - gov2 | ||
| - swift | ||
| - python | ||
| - ruby | ||
| - php | ||
| - cpp | ||
| - kotlin | ||
|
|
||
| permissions: | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| run_job_with_aws: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| sdk_name: ${{ github.event.inputs.sdk_name || 'python' }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v5 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} # once merged, update trust policy of the role to point to main branch | ||
| aws-region: us-west-2 | ||
|
|
||
| - name: Set SDK and language mapping for S3 | ||
| run: | | ||
| if [ "$sdk_name" == "javascriptv3" ]; then | ||
| echo "S3_LANGUAGE=javascript" >> $GITHUB_ENV | ||
| elif [ "$sdk_name" == "dotnetv4" ]; then | ||
| echo "S3_LANGUAGE=dotnet" >> $GITHUB_ENV | ||
| elif [ "$sdk_name" == "javav2" ]; then | ||
| echo "S3_LANGUAGE=java" >> $GITHUB_ENV | ||
| elif [ "$sdk_name" == "rustv1" ]; then | ||
| echo "S3_LANGUAGE=rust" >> $GITHUB_ENV | ||
| elif [ "$sdk_name" == "gov2" ]; then | ||
| echo "S3_LANGUAGE=go" >> $GITHUB_ENV | ||
| else | ||
| echo "S3_LANGUAGE=$sdk_name" >> $GITHUB_ENV | ||
| fi | ||
|
|
||
| - name: Extract and copy premium examples in temp. dir. | ||
| run: | | ||
| MARKDOWN_FILE="./$sdk_name/premium-ex.md" | ||
|
|
||
| if [ ! -f "$MARKDOWN_FILE" ]; then | ||
| echo "Premium examples file not found: $MARKDOWN_FILE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| extract_paths() { | ||
| local level="$1" | ||
| local section_found=false | ||
|
|
||
| while IFS= read -r line; do | ||
| if [[ "$line" =~ ^##[[:space:]]*${level}:[[:space:]]*$ ]]; then | ||
| section_found=true | ||
| continue | ||
| elif [[ "$line" =~ ^##[[:space:]] ]] && [ "$section_found" = true ]; then | ||
| break | ||
| elif [ "$section_found" = true ] && [[ "$line" =~ ^/ ]]; then | ||
| echo "$line" | ||
| fi | ||
| done < "$MARKDOWN_FILE" | ||
| } | ||
|
|
||
| for level in "basics" "feature-scenario" "complex-feature-scenario"; do | ||
| paths=$(extract_paths "$level") | ||
|
|
||
| if [ -n "$paths" ]; then | ||
| mkdir -p "./extracted_snippets/$level" | ||
|
|
||
| while IFS= read -r path; do | ||
| if [ -n "$path" ]; then | ||
| source_path="./$sdk_name$path" | ||
| if [ -e "$source_path" ]; then | ||
| cp -r "$source_path" "./extracted_snippets/$level/" | ||
| fi | ||
| fi | ||
| done <<< "$paths" | ||
| fi | ||
| done | ||
|
|
||
| - name: Upload/Sync to S3 | ||
| run: | | ||
| for level in "basics" "feature-scenario" "complex-feature-scenario"; do | ||
| if [ -d "./extracted_snippets/$level" ]; then | ||
| aws s3 sync "./extracted_snippets/$level/" "s3://$S3_LANGUAGE-premium-bucket/$level/" --delete | ||
| echo "Uploaded $level examples to S3" | ||
| fi | ||
| done | ||
|
|
||
| - name: Sync Knowledge Base Data Source | ||
| run: | | ||
| aws lambda invoke \ | ||
| --function-name KB_Updater \ | ||
| --payload "{\"language\":\"$S3_LANGUAGE\",\"region\":\"us-west-2\"}" \ | ||
| --cli-binary-format raw-in-base64-out \ | ||
| response.json | ||
|
|
||
| echo "Knowledge Base sync initiated" | ||
| cat response.json |
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,10 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
|
|
||
| ## basics: | ||
| /example_code/s3/s3_getting_started_scenario.cpp | ||
|
|
||
| ## feature-scenario: | ||
| /example_code/medical-imaging/imaging_set_and_frames_workflow | ||
|
|
||
| ## complex-feature-scenario: | ||
| /example_code/s3/s3_object_integrity_workflow |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /ControlTower | ||
|
|
||
| ## feature-scenario: | ||
| /CloudWatch/Scenarios | ||
|
|
||
| ## complex-feature-scenario: | ||
| /S3/Scenarios/S3_CreatePresignedPost |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /s3/actions/bucket_basics.go | ||
|
|
||
| ## feature-scenario: | ||
| /s3/actions/bucket_basics.go | ||
|
|
||
| ## complex-feature-scenario: | ||
| /dynamodb/scenarios/scenario_movie_table.go |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/s3/scenarios/basic.js | ||
|
|
||
| ## feature-scenario: | ||
| /example_code/s3/scenarios/object-locking | ||
|
|
||
| ## complex-feature-scenario: | ||
| /example_code/bedrock-runtime/scenarios/converse_tool_scenario/converse-tool-scenario.js |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/iotsitewise/src/main/java/com/example/iotsitewise/HelloSitewise.java | ||
|
|
||
| ## feature-scenario: | ||
| /example_code/s3/src/main/java/com/example/s3/lockscenario | ||
|
|
||
| ## complex-feature-scenario: | ||
| /example_code/bedrock-runtime/src/main/java/com/example/bedrockruntime/scenario | ||
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /services/iotfleetwise | ||
|
|
||
| ## feature-scenario: | ||
| /services/dynamodb/src/main/kotlin/com/kotlin/dynamodb/scenario/ScenarioPartiQ.kt | ||
|
|
||
| ## complex-feature-scenario: | ||
| /services/dynamodb/src/main/kotlin/com/kotlin/dynamodb/scenario/ScenarioPartiQLBatch.kt |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/s3/GettingStartedWithS3.php | ||
|
|
||
| ## feature-scenario: | ||
|
|
||
|
|
||
| ## complex-feature-scenario: | ||
| /applications/photo_asset_manager |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/controltower | ||
|
|
||
| ## feature-scenario: | ||
| /example_code/s3/scenarios/conditional_requests | ||
|
|
||
| ## complex-feature-scenario: | ||
| /example_code/medical-imaging/imaging_set_and_frames_workflow |
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/s3/scenario_getting_started.rb | ||
|
|
||
| ## feature-scenario: | ||
|
|
||
|
|
||
| ## complex-feature-scenario: | ||
|
|
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /examples/lambda | ||
|
|
||
| ## feature-scenario: | ||
| /examples/ec2 | ||
|
|
||
| ## complex-feature-scenario: | ||
|
|
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,11 @@ | ||
| //Add paths for premium examples here which will be consumed by workflow to update KB with quality code | ||
| //Don't forget to add new line at the end of this file | ||
|
|
||
| ## basics: | ||
| /example_code/cognito-identity-provider/scenario | ||
|
|
||
| ## feature-scenario: | ||
| /example_code/bedrock-runtime/models/amazon-nova/amazon-nova-reel | ||
|
|
||
| ## complex-feature-scenario: | ||
| /example_code/sqs/scenario |
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.