Skip to content

Add CLI Samples#1265

Open
HardikThakkar94 wants to merge 136 commits intoawslabs:mainfrom
HardikThakkar94:main
Open

Add CLI Samples#1265
HardikThakkar94 wants to merge 136 commits intoawslabs:mainfrom
HardikThakkar94:main

Conversation

@HardikThakkar94
Copy link
Copy Markdown
Contributor

Amazon Bedrock AgentCore Samples Pull Request

Important

  1. We strictly follow a issue-first approach, please first open an issue relating to this Pull Request.
  2. Once this Pull Request is ready for review please attach review ready label to it. Only PRs with review ready will be reviewed.

Issue number:

Concise description of the PR

Added samples using Agentcore CLI for Identity sections.

User experience

Please share what the user experience looks like before and after this change

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • Add your name to CONTRIBUTORS.md
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you uploading a dataset?
  • Have you documented Introduction, Architecture Diagram, Prerequisites, Usage, Sample Prompts, and Clean Up steps in your example README?
  • I agree to resolve any issues created for this example in the future.
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

HardikThakkar94 and others added 30 commits September 4, 2025 15:19
cosmetic update

Signed-off-by: Hardik Thakkar <68253981+HardikThakkar94@users.noreply.github.com>
Signed-off-by: Hardik Thakkar <68253981+HardikThakkar94@users.noreply.github.com>
Signed-off-by: Hardik Thakkar <68253981+HardikThakkar94@users.noreply.github.com>
Modified
- Requirements.txt (added dependencies)
- chatbot_app_cognito.py (added get_streamlit_url, for sagemaker access)
- runtime_with_strands_and_egress_3lo.ipynb (streamlit piece for access url, cosmetic updates)
…ing Python best practices (PEP 8). The linting errors should now be resolved:

  - ✅ runtime.py:18:1: E402 - Fixed
  - ✅ runtime.py:19:1: E402 - Fixed
  - ✅ runtime.py:19:20: F811 - Fixed
  - ✅ runtime.py:25:1: E402 - Fixed
…ovements:

1. 05-Outbound_Auth_3lo notebook: Fixed credential provider name typo
2. 06-Outbound_Auth_Github notebook: Multiple improvements including:
    - Updated description text for GitHub-specific use case
    - Reorganized imports (moved to top of cell)
    - Added boto session and region setup
    - Reordered OAuth flow description
    - Restructured notebook sections (removed redundant policy section, added clearer status check and invoke sections)
    - Fixed credential provider name reference
HardikThakkar94 and others added 22 commits March 30, 2026 13:44
Replace fake weather calls with real Google Maps
Weather API. API key from AgentCore Identity is
now used for actual authentication.
CLI 0.4.0 changed agentcore status --json output
format, breaking ARN resolution in invoke.py and
streamlit apps. Reading deployed-state.json directly
works across all CLI versions.

- invoke.py (09, 10, 11): read runtimeArn from
  deployed-state.json instead of parsing status
- configure_inbound_auth.py (10, 11): read runtimeId
  from deployed-state.json
- streamlit_app.py (09, 10, 11): same fix for
  resolve_agent_arn and resolve_gateway_url
- Removed subprocess/re imports where no longer needed
Links pointed to samples that don't exist yet
(EntraID, Okta) or were circular references.
Switch from Google Weather to OpenWeatherMap.
Free tier, no billing required.
Use recursive JSON search for runtimeArn/runtimeId
in deployed-state.json. Works regardless of nesting
structure across CLI 0.3.x and 0.4.x.
Add optional Streamlit instructions to all 3
README files (samples 09, 10, 11).
Token field cleared on rerun because Streamlit
key overrides value param. Pre-fill via session
state on login instead.
MCP server is public, no OAuth needed. Remove
confusing outbound auth flags and outdated JSON
example from sample 10 README.
Replace fake internal API with real OpenWeatherMap
call in sample 11 M2M flow. Users can reuse the
same API key from sample 09.
Move project creation before credential setup
so CLI commands work. Renumber steps 3-10.
- Fetch OpenWeatherMap key via @requires_api_key
- M2M token + API key working together
- Fix invoke.py prompt to match new tool
- Tested end-to-end: real weather data returned
Add clear instructions for OpenWeatherMap key
with link to sample 09 for users who skip ahead.
Add detailed instructions for creating GitHub OAuth
App and Google OAuth credentials in sample 11 README.
Steps taken from existing samples 05 and 06 notebooks.
Copy github_details.png from sample 06 to show
the OAuth App creation form in sample 11 README.
Upstream added 09-Outbound_Auth_Self_Hosted to main.
Shift our CLI samples to avoid conflict:
  09 → 10-runtime-inbound-outbound-auth
  10 → 11-gateway-inbound-outbound-auth
  11 → 12-m2m-3lo-runtime
Update all internal cross-references.
Single table with all 12 samples. Method column shows
Notebook or CLI for each. No more legacy/recommended split.
Fix IDP examples type to Inbound + Outbound.
@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@HardikThakkar94 HardikThakkar94 self-assigned this Apr 7, 2026
@github-actions github-actions bot added 01-tutorials 01-tutorials 03-AgentCore-identity 01-tutorials/03-AgentCore-identity labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

Latest scan for commit: deb07b3 | Updated: 2026-04-07 20:12:41 UTC

Security Scan Results

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-04-07T20:12:25+00:00
  • ASH version: 3.0.0

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

Column Explanations:

Severity Levels (S/C/H/M/L/I):

  • Suppressed (S): Security findings that have been explicitly suppressed/ignored and don't affect the scanner's pass/fail status
  • Critical (C): The most severe security vulnerabilities requiring immediate remediation (e.g., SQL injection, remote code execution)
  • High (H): Serious security vulnerabilities that should be addressed promptly (e.g., authentication bypasses, privilege escalation)
  • Medium (M): Moderate security risks that should be addressed in normal development cycles (e.g., weak encryption, input validation issues)
  • Low (L): Minor security concerns with limited impact (e.g., information disclosure, weak recommendations)
  • Info (I): Informational findings for awareness with minimal security risk (e.g., code quality suggestions, best practice recommendations)

Other Columns:

  • Time: Duration taken by each scanner to complete its analysis
  • Action: Total number of actionable findings at or above the configured severity threshold that require attention

Scanner Results:

  • PASSED: Scanner found no security issues at or above the configured severity threshold - code is clean for this scanner
  • FAILED: Scanner found security vulnerabilities at or above the threshold that require attention and remediation
  • MISSING: Scanner could not run because required dependencies/tools are not installed or available
  • SKIPPED: Scanner was intentionally disabled or excluded from this scan
  • ERROR: Scanner encountered an execution error and could not complete successfully

Severity Thresholds (Thresh Column):

  • CRITICAL: Only Critical severity findings cause scanner to fail
  • HIGH: High and Critical severity findings cause scanner to fail
  • MEDIUM (MED): Medium, High, and Critical severity findings cause scanner to fail
  • LOW: Low, Medium, High, and Critical severity findings cause scanner to fail
  • ALL: Any finding of any severity level causes scanner to fail

Threshold Source: Values in parentheses indicate where the threshold is configured:

  • (g) = global: Set in the global_settings section of ASH configuration
  • (c) = config: Set in the individual scanner configuration section
  • (s) = scanner: Default threshold built into the scanner itself

Statistics calculation:

  • All statistics are calculated from the final aggregated SARIF report
  • Suppressed findings are counted separately and do not contribute to actionable findings
  • Scanner status is determined by comparing actionable findings to the threshold
Scanner S C H M L I Time Action Result Thresh
bandit 0 2 0 0 19 0 1.3s 2 FAILED MED (g)
cdk-nag 0 0 0 0 0 0 33.2s 0 PASSED MED (g)
cfn-nag 0 0 0 0 0 0 6ms 0 PASSED MED (g)
checkov 0 0 0 0 0 0 5.5s 0 PASSED MED (g)
detect-secrets 0 7 0 0 0 0 1.0s 7 FAILED MED (g)
grype 0 0 0 0 0 0 37.0s 0 PASSED MED (g)
npm-audit 0 0 0 0 0 0 167ms 0 PASSED MED (g)
opengrep 0 0 0 0 0 0 <1ms 0 SKIPPED MED (g)
semgrep 0 1 0 0 0 0 20.0s 1 FAILED MED (g)
syft 0 0 0 0 0 0 2.2s 0 PASSED MED (g)

Detailed Findings

Show 10 actionable findings

Finding 1: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/setup_cognito.py:17

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/setup_cognito.py' at line 17

Code Snippet:

Secret of type Secret Keyword detected

Finding 2: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/setup_cognito.py:18

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/setup_cognito.py' at line 18

Code Snippet:

Secret of type Secret Keyword detected

Finding 3: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/app/MyAgent/main.py:61

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/app/MyAgent/main.py' at line 61

Code Snippet:

Secret of type Secret Keyword detected

Finding 4: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/11-gateway-inbound-outbound-auth/setup_cognito.py:17

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/11-gateway-inbound-outbound-auth/setup_cognito.py' at line 17

Code Snippet:

Secret of type Secret Keyword detected

Finding 5: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/11-gateway-inbound-outbound-auth/setup_cognito.py:18

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/11-gateway-inbound-outbound-auth/setup_cognito.py' at line 18

Code Snippet:

Secret of type Secret Keyword detected

Finding 6: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/12-m2m-3lo-runtime/setup_cognito.py:19

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/12-m2m-3lo-runtime/setup_cognito.py' at line 19

Code Snippet:

Secret of type Secret Keyword detected

Finding 7: SECRET-SECRET-KEYWORD

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-SECRET-KEYWORD
  • Location: 01-tutorials/03-AgentCore-identity/12-m2m-3lo-runtime/setup_cognito.py:20

Description:
Secret of type 'Secret Keyword' detected in file '01-tutorials/03-AgentCore-identity/12-m2m-3lo-runtime/setup_cognito.py' at line 20

Code Snippet:

Secret of type Secret Keyword detected

Finding 8: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: 01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/app/MyAgent/main.py:74-76

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

try:
        result = eval(expression, {"__builtins__": {}})  # noqa: S307
        return f"{expression} = {result}"

Finding 9: B104

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B104
  • Location: 01-tutorials/03-AgentCore-identity/12-m2m-3lo-runtime/oauth2_callback_server.py:448-450

Description:
Possible binding to all interfaces.

Code Snippet:

# In local development, bind to 127.0.0.1 for security
    host = "0.0.0.0" if _is_workshop_studio() else "127.0.0.1"
    base_url = get_oauth2_callback_base_url()

Finding 10: python.lang.security.audit.eval-detected.eval-detected

  • Severity: HIGH
  • Scanner: semgrep
  • Rule ID: python.lang.security.audit.eval-detected.eval-detected
  • Location: 01-tutorials/03-AgentCore-identity/10-runtime-inbound-outbound-auth/app/MyAgent/main.py:75

Description:
Detected the use of eval(). eval() can be dangerous if used to evaluate dynamic content. If this content can be input from outside the program, this may be a code injection vulnerability. Ensure evaluated content is not definable by external sources.

Code Snippet:

result = eval(expression, {"__builtins__": {}})  # noqa: S307

Report generated by Automated Security Helper (ASH) at 2026-04-07T20:12:18+00:00

- Remove unused imports (asyncio, json, subprocess, time)
- Fix E402: move imports to top of file
- Fix F541: remove f-prefix from strings without placeholders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

01-tutorials 01-tutorials 03-AgentCore-identity 01-tutorials/03-AgentCore-identity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants