Skip to main content

Serverless radar for Amazon Bedrock — deploy a Lambda that logs prompt/latency to S3, then analyze it.

Project description

Prerequisites (do this before deploying)

0.1 Authenticate to AWS

The deploy needs valid AWS credentials in your shell. If your session has expired you'll see "Your session has expired ... Please reauthenticate".

  • AWS IAM Identity Center (SSO):
    aws sso login                      # or: aws sso login --profile <your-profile>
    
  • Legacy / custom login wrapper:
    aws login
    

Verify you're authenticated before continuing:

aws sts get-caller-identity

If you use a named profile, export it so radar.py picks it up:

export AWS_PROFILE=<your-profile>
export AWS_REGION=us-east-1

0.2 Python environment

radar.py needs boto3. On externally-managed Python (Homebrew/PEP 668) use a venv:

python3 -m venv .venv
.venv/bin/python -m pip install boto3 "botocore[crt]"

Then run radar with that interpreter, e.g. .venv/bin/python radar.py deploy --dry-run.

0.3 Enable Bedrock model access

The test step (and any real invocation) needs the model enabled in the Bedrock console for your region: Bedrock > Model access > enable anthropic.claude-sonnet-4-20250514-v1:0 in us-east-1. This is a one-time manual grant that the deploy does not perform.


Update Lambda runtime (IMPORTANT) When creating the lambda, use: Runtime: python3.11 Handler: lambda_function.lambda_handler

1.1 Before creating the lambda: create Create the IAM role aws iam create-role
--role-name bedrock-lambda-role
--assume-role-policy-document file://trust-policy.json 1.2. Attach Lambda basic logging aws iam attach-role-policy
--role-name bedrock-lambda-role
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole 1.3 Attach Bedrock access aws iam attach-role-policy
--role-name bedrock-lambda-role
--policy-arn arn:aws:iam::aws:policy/AmazonBedrockFullAccess 1.4 Attach S3 access (for logging) aws iam attach-role-policy
--role-name bedrock-lambda-role
--policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess 1.5 Get the role ARN (IMPORTANT) aws iam get-role
--role-name bedrock-lambda-role
--query 'Role.Arn'
--output text

you should get something like that arn:aws:iam::<ACCOUNT_ID>:role/bedrock-lambda-role

starting now let's chcek : aws iam get-role --role-name bedrock-lambda-role --query 'Role.Arn' --output text

When all seccusfully created:

  1. Create Lambda (again, clean)
  2. Fix handler issues
  3. Test invocation
  4. Add API Gateway

radar.py — these steps as flags

radar.py deploy automates every step above. Each maps to a named step you can run on its own with --steps or exclude with --skip (see --list-steps):

readme step radar step
1.1 create IAM role role
1.2-1.4 attach policies policies (or --least-privilege for scoped)
create S3 log bucket bucket
Create Lambda + fix handler function
Add API Gateway api
(write config.json) config
Test invocation test (--test-prompt "...")

Examples:

python3 radar.py deploy --dry-run               # preview every step, no AWS calls
python3 radar.py deploy --list-steps            # show steps and what is selected
python3 radar.py deploy --steps role,policies   # just the IAM steps
python3 radar.py deploy --skip test             # everything except the test
python3 radar.py deploy                         # full deploy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_bedrock_radar-0.1.1.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_bedrock_radar-0.1.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file aws_bedrock_radar-0.1.1.tar.gz.

File metadata

  • Download URL: aws_bedrock_radar-0.1.1.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for aws_bedrock_radar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 274049a9fbc67039b264b2406dafd20b97bd69cf075fd1ac1fe5b04082a7a851
MD5 997715e49b8040bf3cda95ac6056e04d
BLAKE2b-256 78ed9e0188e4038f261f64e990dc00cd75eaf8bf4de0004355cd2cb3dfd2c249

See more details on using hashes here.

File details

Details for the file aws_bedrock_radar-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_bedrock_radar-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22864d77644c7cc920063509510c29af63b4949669a0f8af2787b545079d79a5
MD5 7fd158cfbe622fdb60250c1672fa3ad6
BLAKE2b-256 a9044a3205f324813b9e61dd95aca0fc4abe21a12e8eed3162f6cbb01027a4df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page