From 26e7c3f848553647acbe11a52e927f1025c4ae63 Mon Sep 17 00:00:00 2001 From: Tejas Ganesh Naik <“tejasgn@amazon.com”> Date: Thu, 25 Sep 2025 16:17:37 -0700 Subject: [PATCH 1/5] configured actions workflow for syncing S3, KB and added premium-ex files for SDKs --- .github/workflows/sync-S3-KB.yml | 120 +++++++++++++++++++++++++++++++ cpp/premium-ex.md | 10 +++ dotnetv4/premium-ex.md | 11 +++ gov2/premium-ex.md | 11 +++ javascriptv3/premium-ex.md | 11 +++ javav2/premium-ex.md | 11 +++ kotlin/premium-ex.md | 11 +++ php/premium-ex.md | 11 +++ python/premium-ex.md | 11 +++ rustv1/premium-ex.md | 11 +++ swift/premium-ex.md | 11 +++ 11 files changed, 229 insertions(+) create mode 100644 .github/workflows/sync-S3-KB.yml create mode 100644 cpp/premium-ex.md create mode 100644 dotnetv4/premium-ex.md create mode 100644 gov2/premium-ex.md create mode 100644 javascriptv3/premium-ex.md create mode 100644 javav2/premium-ex.md create mode 100644 kotlin/premium-ex.md create mode 100644 php/premium-ex.md create mode 100644 python/premium-ex.md create mode 100644 rustv1/premium-ex.md create mode 100644 swift/premium-ex.md diff --git a/.github/workflows/sync-S3-KB.yml b/.github/workflows/sync-S3-KB.yml new file mode 100644 index 00000000000..56774b962d3 --- /dev/null +++ b/.github/workflows/sync-S3-KB.yml @@ -0,0 +1,120 @@ +name: syncS3andKB +on: + push: + branches: [ "sync-S3-KB" ] # Once merged into main, update branch name to 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@main # Or a specific version + with: + role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role + 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 diff --git a/cpp/premium-ex.md b/cpp/premium-ex.md new file mode 100644 index 00000000000..942cac40e28 --- /dev/null +++ b/cpp/premium-ex.md @@ -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 diff --git a/dotnetv4/premium-ex.md b/dotnetv4/premium-ex.md new file mode 100644 index 00000000000..0d26ae16854 --- /dev/null +++ b/dotnetv4/premium-ex.md @@ -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 diff --git a/gov2/premium-ex.md b/gov2/premium-ex.md new file mode 100644 index 00000000000..42a552bc35a --- /dev/null +++ b/gov2/premium-ex.md @@ -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 diff --git a/javascriptv3/premium-ex.md b/javascriptv3/premium-ex.md new file mode 100644 index 00000000000..78ff7a0ca6b --- /dev/null +++ b/javascriptv3/premium-ex.md @@ -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 diff --git a/javav2/premium-ex.md b/javav2/premium-ex.md new file mode 100644 index 00000000000..826faf47413 --- /dev/null +++ b/javav2/premium-ex.md @@ -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 diff --git a/kotlin/premium-ex.md b/kotlin/premium-ex.md new file mode 100644 index 00000000000..2c578d531cf --- /dev/null +++ b/kotlin/premium-ex.md @@ -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 diff --git a/php/premium-ex.md b/php/premium-ex.md new file mode 100644 index 00000000000..4ba65c38ca0 --- /dev/null +++ b/php/premium-ex.md @@ -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 diff --git a/python/premium-ex.md b/python/premium-ex.md new file mode 100644 index 00000000000..cc724b5316d --- /dev/null +++ b/python/premium-ex.md @@ -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 diff --git a/rustv1/premium-ex.md b/rustv1/premium-ex.md new file mode 100644 index 00000000000..cc724b5316d --- /dev/null +++ b/rustv1/premium-ex.md @@ -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 diff --git a/swift/premium-ex.md b/swift/premium-ex.md new file mode 100644 index 00000000000..6d8904d5f13 --- /dev/null +++ b/swift/premium-ex.md @@ -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 From 94d413309ca2dd674f36ac922056cbe6a7a87d3b Mon Sep 17 00:00:00 2001 From: Tejas Ganesh Naik <“tejasgn@amazon.com”> Date: Thu, 25 Sep 2025 16:22:42 -0700 Subject: [PATCH 2/5] adding imp comments --- .github/workflows/sync-S3-KB.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-S3-KB.yml b/.github/workflows/sync-S3-KB.yml index 56774b962d3..8a4f769aa05 100644 --- a/.github/workflows/sync-S3-KB.yml +++ b/.github/workflows/sync-S3-KB.yml @@ -1,7 +1,7 @@ name: syncS3andKB on: push: - branches: [ "sync-S3-KB" ] # Once merged into main, update branch name to main + branches: [ "sync-S3-KB" ] # Once merged, update branch name to main. workflow_dispatch: inputs: sdk_name: @@ -38,7 +38,7 @@ jobs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@main # Or a specific version with: - role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role + role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role #once merged, update trust policy of the role to point to main aws-region: us-west-2 - name: Set SDK and language mapping for S3 From 67b302c29912699a163c908f129d0e9f99dc523b Mon Sep 17 00:00:00 2001 From: Tejas Ganesh Naik <“tejasgn@amazon.com”> Date: Fri, 26 Sep 2025 10:48:30 -0700 Subject: [PATCH 3/5] testing for cpp --- .github/workflows/sync-S3-KB.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-S3-KB.yml b/.github/workflows/sync-S3-KB.yml index 8a4f769aa05..6d8a0d10ba4 100644 --- a/.github/workflows/sync-S3-KB.yml +++ b/.github/workflows/sync-S3-KB.yml @@ -29,7 +29,7 @@ jobs: run_job_with_aws: runs-on: ubuntu-latest env: - sdk_name: ${{ github.event.inputs.sdk_name || 'python' }} + sdk_name: ${{ github.event.inputs.sdk_name || 'cpp' }} steps: - name: Checkout From aab31518c49e6e40d1734be098491de895022d72 Mon Sep 17 00:00:00 2001 From: Tejas Ganesh Naik <“tejasgn@amazon.com”> Date: Fri, 26 Sep 2025 12:02:42 -0700 Subject: [PATCH 4/5] fixed linting yaml errors and adding rust prem-ex --- .github/workflows/sync-S3-KB.yml | 178 +++++++++++++++---------------- ruby/premium-ex.md | 11 ++ 2 files changed, 100 insertions(+), 89 deletions(-) create mode 100644 ruby/premium-ex.md diff --git a/.github/workflows/sync-S3-KB.yml b/.github/workflows/sync-S3-KB.yml index 6d8a0d10ba4..d06726f261d 100644 --- a/.github/workflows/sync-S3-KB.yml +++ b/.github/workflows/sync-S3-KB.yml @@ -1,7 +1,7 @@ name: syncS3andKB on: push: - branches: [ "sync-S3-KB" ] # Once merged, update branch name to main. + branches: ["sync-S3-KB"] # Once merged, update branch name to main. workflow_dispatch: inputs: sdk_name: @@ -10,17 +10,17 @@ on: default: 'python' type: choice options: - - javascriptv3 - - dotnetv4 - - javav2 - - rustv1 - - gov2 - - swift - - python - - ruby - - php - - cpp - - kotlin + - javascriptv3 + - dotnetv4 + - javav2 + - rustv1 + - gov2 + - swift + - python + - ruby + - php + - cpp + - kotlin permissions: id-token: write @@ -32,89 +32,89 @@ jobs: sdk_name: ${{ github.event.inputs.sdk_name || 'cpp' }} steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@main # Or a specific version - with: - role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role #once merged, update trust policy of the role to point to main - aws-region: us-west-2 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@main # Or a specific version + with: + role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_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 + - 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 - extract_paths() { - local level="$1" - local section_found=false + - name: Extract and copy premium examples in temp. dir. + run: | + MARKDOWN_FILE="./$sdk_name/premium-ex.md" - 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 [ ! -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" + } - if [ -n "$paths" ]; then - mkdir -p "./extracted_snippets/$level" + for level in "basics" "feature-scenario" "complex-feature-scenario"; do + paths=$(extract_paths "$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/" + 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 - fi - done <<< "$paths" - fi - done + 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: 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 + - 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 diff --git a/ruby/premium-ex.md b/ruby/premium-ex.md new file mode 100644 index 00000000000..e97eb3af62d --- /dev/null +++ b/ruby/premium-ex.md @@ -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: + From 04852c2247a69861cc7ac44009839ca4828ee5ba Mon Sep 17 00:00:00 2001 From: Tejas Ganesh Naik <“tejasgn@amazon.com”> Date: Mon, 29 Sep 2025 11:20:45 -0700 Subject: [PATCH 5/5] making cred flow fixes and updating rust exs --- .github/workflows/sync-S3-KB.yml | 8 ++++---- rustv1/premium-ex.md | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync-S3-KB.yml b/.github/workflows/sync-S3-KB.yml index d06726f261d..1642517cf69 100644 --- a/.github/workflows/sync-S3-KB.yml +++ b/.github/workflows/sync-S3-KB.yml @@ -1,7 +1,7 @@ name: syncS3andKB on: push: - branches: ["sync-S3-KB"] # Once merged, update branch name to main. + branches: ["main"] workflow_dispatch: inputs: sdk_name: @@ -29,16 +29,16 @@ jobs: run_job_with_aws: runs-on: ubuntu-latest env: - sdk_name: ${{ github.event.inputs.sdk_name || 'cpp' }} + 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@main # Or a specific version + uses: aws-actions/configure-aws-credentials@v5 with: - role-to-assume: arn:aws:iam::358157044386:role/AWS_GITOIDC_Role # once merged, update trust policy of the role to point to main branch + 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 diff --git a/rustv1/premium-ex.md b/rustv1/premium-ex.md index cc724b5316d..4a31da52195 100644 --- a/rustv1/premium-ex.md +++ b/rustv1/premium-ex.md @@ -2,10 +2,10 @@ //Don't forget to add new line at the end of this file ## basics: -/example_code/controltower +/examples/lambda ## feature-scenario: -/example_code/s3/scenarios/conditional_requests +/examples/ec2 ## complex-feature-scenario: -/example_code/medical-imaging/imaging_set_and_frames_workflow +