# Replace Lambda Deployment Script to Fix Pip Installation Errors

## Problem

The original `deploy_lambda.sh` script was failing with pip installation errors when trying to install dependencies from downloaded wheels:
```
ERROR: charset_normalizer-3.4.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl is not a supported wheel on this platform.
```

This error occurred because:
1. The script was using `--no-index` flag which prevented pip from accessing PyPI
2. The downloaded wheels were for Linux ARM64 (Lambda runtime) but the local macOS environment couldn't install them directly

## Solution

Replaced the original `deploy_lambda.sh` with an improved version that:

### 1. **Direct Package Installation**
- Removes the intermediate wheel download step
- Uses `pip install --target` to install packages directly to the lambda_package directory
- Adds platform-specific flags to ensure Linux ARM64 compatibility:
  ```bash
  pip install --platform manylinux2014_aarch64 --python-version 3.13 \
              --implementation cp --only-binary :all: \
              --target lambda_package -r requirements.in
  ```

### 2. **Better Error Handling**
- Maintains AWS SSO credential checking
- Preserves staging/prod deployment mode selection
- Adds clear error messages for invalid deployment types

### 3. **Simplified Workflow**
```
1. Check AWS credentials (auto-login if needed)
2. Create lambda_package directory
3. Install dependencies directly with platform flags
4. Copy Python source files
5. Create deployment ZIP
6. Deploy to Lambda
7. Clean up temporary files
```

## Changes

- **Modified**: `deploy_lambda.sh` - Replaced with improved version
- **Added**: `deploy_lambda.sh.backup` - Backup of original script for reference

## Usage

The updated script maintains the same interface as the original:
```bash
./deploy_lambda.sh [staging|prod]
```

## Benefits

- **No more pip errors**: Platform-specific installation works correctly
- **Faster deployment**: Skip the wheel download/install two-step process
- **Same package size**: ~19.8MB deployment package (verified in production)
- **Backward compatible**: Same command-line interface and behavior

## Testing

Successfully tested deployments to both environments:
- Staging: 19.8MB package deployed successfully
- Production: 19.8MB package deployed successfully

Both deployments completed without pip errors and the Lambda functions are running correctly.

## Migration

The original script is preserved as `deploy_lambda.sh.backup` in case we need to reference it or roll back.