Skip to content

aws-samples/sample-bedrock-inference-profile-mgmt-tool

AWS Bedrock Inference Profile Management Tool

Introduction

This tool provides a comprehensive solution for managing AWS Bedrock Application Inference Profiles. It allows you to create, list, and manage application inference profiles for Foundation Models or Cross-region Inference Profiles. The tool includes tagging capabilities and provides an interactive command line interface for easy management.

Features

  • Create Application Inference Profiles with:
    • Foundation Model support
    • Cross-region Inference Profile support
  • Batch create Application Inference Profiles from a yaml file
  • Batch tag existing Application Inference Profiles from a yaml file
  • Created profiles are exported to CSV automatically
  • Tag management for inference profiles
  • List existing Application inference profiles
  • Delete existing profiles
  • Interactive command-line interface
  • Only support On-Demand Models, do not support Provisioned Models.

Prerequisites

  • Python 3.9 and above
  • AWS Account with appropriate permissions
  • AWS credentials configured (either through AWS CLI profiles or access keys)

Workflow

┌─────────────────────────────────────────────────────────────────┐
│                    Installation & Setup                         │
│  1. Install dependencies                                        │
│  2. Configure AWS credentials                                   │
└────────────────────────┬────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────────────┐
│              Choose Your Approach                               │
└─────────────┬───────────────────────────────────┬───────────────┘
              │                                   │
              ▼                                   ▼
┌─────────────────────────────┐   ┌─────────────────────────────┐
│   Interactive Mode          │   │   Batch Mode                │
│   (Single Profile)          │   │   (Multiple Profiles)       │
└──────────┬──────────────────┘   └──────────┬──────────────────┘
           │                                  │
           │                                  ▼
           │                      ┌─────────────────────────────┐
           │                      │ Generate YAML Template      │
           │                      │ bedrock_batch_create_       │
           │                      │ profiles.py                 │
           │                      └──────────┬──────────────────┘
           │                                 │
           │                                 ▼
           │                      ┌─────────────────────────────┐
           │                      │ Review & Modify YAML        │
           │                      │ - Update profile names      │
           │                      │ - Adjust tags               │
           │                      │ - Add existing profiles     │
           │                      └──────────┬──────────────────┘
           │                                 │
           │                                 ▼
           │                      ┌─────────────────────────────┐
           │                      │ Batch Create Profiles       │
           │                      │ -f ./bedrock-profiles.yaml  │
           │                      └──────────┬──────────────────┘
           │                                 │
           └─────────────┬───────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────────────┐
│              Optional: Tag Existing Profiles                    │
│  -t ./bedrock-profiles.yaml                                     │
└────────────────────────┬────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────────────────┐
│              Manage Profiles                                    │
│  - List profiles (-l)                                           │
│  - Delete profiles                                              │
│  - Export to CSV (automatic)                                    │
└─────────────────────────────────────────────────────────────────┘

Installation

  1. Clone the repository:
git clone <repository-url>
cd sample-bedrock-inference-profile-mgmt-tool
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Required AWS Permissions

When using the Application Inference Profile, ensure you have the following IAM permissions (replace <region> and <account_id> with your values):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["bedrock:InvokeModel*"],
      "Resource": [
        "arn:aws:bedrock:<region>:<account_id>:inference-profile/*",
        "arn:aws:bedrock:<region>::foundation-model/*"
      ]
    }
  ]
}

Usage

Creating a New Inference Profile

Run the tool in interactive creation mode:

python bedrock_inference_profile_management_tool.py

The tool will guide you through:

  1. AWS credential configuration (profile selection or manual input)
  2. Tag configuration
  3. Profile creation with options for:
    • Foundation Models
    • Cross-region Inference Profiles

Creating Batch Inference Profile YAML Template File

Generate a YAML template file with available models and inference profiles:

python3 bedrock_batch_create_profiles.py

The tool will:

  1. Prompt you to select AWS profile and region
  2. Ask for a filter keyword (e.g., claude, titan, llama, mistral)
  3. List matching Foundation Models and System-Defined Inference Profiles
  4. Generate a timestamped YAML file (e.g., claude-bedrock-profiles-20260115011234567.yaml)

Important: Before using the generated YAML file, you must:

  • Review and modify profile names (especially for inference profiles that have "CHANGE ME-" prefix)
  • Adjust tags as needed
  • Optionally add existing profiles to tag under existing-profiles-to-tag section

Batch Creating Inference Profiles from a YAML File

Run the tool in batch creation mode:

python3 bedrock_inference_profile_management_tool.py -f ./bedrock-profiles.yaml

Batch Tagging Existing Inference Profiles from a yaml file

Run the tool in batch tagging mode:

python3 bedrock_inference_profile_management_tool.py -t ./bedrock-profiles.yaml

Listing and Managing Existing Profiles

To list and manage existing profiles:

python bedrock_inference_profile_management_tool.py -l

This command will:

  1. Display all existing Application inference profiles
  2. Allow you to delete selected profiles
  3. Show profile details including:
    • Profile Name
    • Region
    • Model ID
    • Status
    • ARN
    • Associated Tags

CSV Export

The tool automatically exports profile information to CSV files with timestamps for record-keeping. The CSV includes:

  • Profile Name
  • Profile ARN
  • Associated Tags

Error Handling

  • The tool includes comprehensive error handling for common scenarios
  • Provides clear error messages and retry options
  • Validates inputs to prevent invalid operations

Verification

Check Tags on Inference Profile

Verify that tags have been applied to your inference profile:

aws bedrock list-tags-for-resource \
  --resource-arn arn:aws:bedrock:us-west-2:123456789:application-inference-profile/aaabbbccc \
  --region us-west-2

Example output:

{
    "tags": [
        {
            "key": "map-migrated",
            "value": "mig123Bedrock"
        },
        {
            "key": "Environment",
            "value": "Development"
        }
    ]
}

Check Invocation Success

Monitor invocations to verify the profile is being used successfully:

aws cloudwatch get-metric-statistics \
  --namespace AWS/Bedrock \
  --metric-name Invocations \
  --dimensions Name=ModelId,Value=aaabbbccc \
  --start-time 2026-01-14T02:25:00Z \
  --end-time 2026-01-14T02:35:00Z \
  --period 300 \
  --statistics Sum \
  --region us-west-2

Example output:

{
    "Label": "Invocations",
    "Datapoints": [
        {
            "Timestamp": "2026-01-14T02:30:00+00:00",
            "Sum": 1.0,
            "Unit": "Count"
        }
    ]
}

Contributing

Contributions are welcome! Please feel free to submit pull requests or create issues for bugs and feature requests.

About

Bedrock Inference Profile Management Tool

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages