Skip to content

AWS Bedrock Integration Guide

Overview

This guide provides detailed instructions for integrating and deploying models to AWS Bedrock using IdeaWeaver. AWS Bedrock is a fully managed service that makes it easy to build and scale generative AI applications with foundation models.

Table of Contents

Prerequisites

AWS Account Setup

  1. AWS Account with Bedrock access enabled
  2. IAM Role with necessary permissions
  3. S3 Bucket in us-east-1 region

Required Permissions

IAM Role Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "bedrock:*"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::aws-bedrock-ideaweaver-bucket-use1",
                "arn:aws:s3:::aws-bedrock-ideaweaver-bucket-use1/*"
            ]
        }
    ]
}

S3 Bucket Policy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowBedrockAccess",
            "Effect": "Allow",
            "Principal": {
                "Service": "bedrock.amazonaws.com"
            },
            "Action": [
                "s3:GetObject",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::aws-bedrock-ideaweaver-bucket-use1",
                "arn:aws:s3:::aws-bedrock-ideaweaver-bucket-use1/*"
            ]
        }
    ]
}

Setup

  1. Create S3 Bucket

    aws s3api create-bucket \
      --bucket aws-bedrock-ideaweaver-bucket-use1 \
      --region us-east-1
    

  2. Configure Bucket Settings

    # Disable ACLs
    aws s3api put-bucket-ownership-controls \
      --bucket aws-bedrock-ideaweaver-bucket-use1 \
      --ownership-controls Rules=[{ObjectOwnership=BucketOwnerEnforced}]
    

  3. Create IAM Role

    aws iam create-role \
      --role-name bedrock-admin-role \
      --assume-role-policy-document file://trust-policy.json
    

Model Requirements

Supported Architectures

  • llama
  • mistral
  • t5
  • mixtral
  • gpt_bigcode
  • mllama
  • qwen2_vl
  • qwen2
  • qwen2_5_vl

Model Structure

my-qwen2-model/
├── config.json
├── pytorch_model.bin
├── tokenizer.json
└── tokenizer_config.json

Deployment Process

1. Prepare Model

# Download supported model
git lfs install
git clone https://huggingface.co/Qwen/Qwen2-0.5B my-qwen2-model

2. Upload to S3

# Upload model files
aws s3 sync ./my-qwen2-model s3://aws-bedrock-ideaweaver-bucket-use1/bedrock-models/my-qwen2-model/

3. Deploy to Bedrock

# Deploy using IdeaWeaver
ideaweaver deploy bedrock \
  --model-path ./my-qwen2-model \
  --model-name my-qwen2-model \
  --s3-bucket aws-bedrock-ideaweaver-bucket-use1 \
  --region us-east-1

Troubleshooting

Common Issues

  1. Region Mismatch
  2. Error: "Amazon Bedrock does not have access to the S3 location"
  3. Solution: Ensure S3 bucket is in us-east-1

  4. Permission Issues

  5. Error: "Access Denied"
  6. Solution: Verify IAM role and bucket policies

  7. Model Architecture

  8. Error: "Amazon bedrock does not support the architecture"
  9. Solution: Use only supported architectures

  10. Import Job Quotas

  11. Error: "Your account does not have the quota limits"
  12. Solution: Request quota increase

Debugging Steps

  1. Verify S3 Access

    aws s3 ls s3://aws-bedrock-ideaweaver-bucket-use1/bedrock-models/my-qwen2-model/
    

  2. Check IAM Role

    aws iam get-role --role-name bedrock-admin-role
    

  3. Validate Model

    ideaweaver bedrock validate-model ./my-qwen2-model
    

Best Practices

  1. Model Selection
  2. Start with smaller models (e.g., Qwen2-0.5B)
  3. Verify architecture compatibility
  4. Test locally before deployment

  5. S3 Organization

  6. Use consistent naming conventions
  7. Organize models in subdirectories
  8. Enable versioning for important models

  9. Security

  10. Use IAM roles with minimal permissions
  11. Disable ACLs on S3 buckets
  12. Regularly audit access policies

  13. Monitoring

  14. Track import job status
  15. Monitor model performance
  16. Set up CloudWatch alarms

Additional Resources