# TBI DevOps Agent Contexts - S3 Bucket

## Overview

This document describes the S3 bucket structure for storing documentation, configuration, and integration files for TBI DevOps repositories.

## Bucket Information

- **Bucket Name**: `tbi-devops-agent-contexts`
- **Region**: `ca-central-1`
- **AWS Profile**: `tbi-prod`
- **Purpose**: Centralized storage for DevOps documentation, AI agent configurations, and integration guides

## Structure

The bucket is organized by repository name, with each repository containing its documentation and configuration files:

```
s3://tbi-devops-agent-contexts/
└── tbi-devops-environments/
    ├── .kiro/                    # Kiro AI configurations
    ├── docs/                     # Documentation
    └── integration/              # Integration guides
```

## Current Contents

### tbi-devops-environments (26 files)

#### .kiro/ (2 files)
- `agents/circleci-pipeline-deployment-agent.json` - CircleCI pipeline deployment agent configuration
- `steering/circleci-pipeline-patterns.md` - Pipeline patterns and best practices

#### docs/ (8 files)
- `CLAUDE-CONTEXT.md` - Context for Claude AI
- `DEPLOYMENT-SCRIPT-GUIDE.md` - Guide for deployment scripts
- `DEVELOPER-GUIDE.md` - Developer guide for TBI DevOps
- `MIGRATION-CHECKLIST.md` - Migration checklist
- `MCP-DEPLOYMENT-FIX.md` - MCP deployment fixes
- `QUICK-REFERENCE.md` - Quick reference guide
- `SECRETS-PIPELINE-SETUP.md` - Secrets pipeline setup guide
- `SETUP-COMPLETE-tbi-acc-hotel-mapping-service.md` - Complete setup documentation
- `SHARED-IMAGE-MIGRATION.md` - Shared image migration guide

#### integration/ (15 files)
- `README.md` - Integration overview
- `tbi-agent-pipeline-integration/`
  - `README.md` - Pipeline integration overview
  - `QUICK-START.md` - 30-minute quick start guide
  - `IMPLEMENTATION-GUIDE.md` - Detailed implementation guide
  - `IMPLEMENTATION-CHECKLIST.md` - Step-by-step checklist
  - `INTEGRATION-SUMMARY.md` - Integration summary
  - `NEXT-STEPS-FOR-YOU.md` - Next steps guide
  - `pipeline-deployer.js` - Pipeline deployer module
  - `code-updates/`
    - `devops-agent-updates.js` - DevOps agent updates
    - `pipeline-deployer.js` - Pipeline deployer implementation
    - `package-json-updates.json` - Package.json updates
  - `k8s-configmaps/`
    - `system-prompt.txt` - AI system prompt
    - `templates/`
      - `circleci-config.yml` - CircleCI config template
      - `circleci-config-reference.yml` - CircleCI config reference
      - `deploy-script-reference.sh` - Deployment script reference

## Usage

### Uploading Files

To upload documentation for a repository:

```bash
# Upload .kiro directory
aws s3 sync .kiro/ s3://tbi-devops-agent-contexts/<repo-name>/.kiro/ --profile tbi-prod

# Upload docs directory
aws s3 sync docs/ s3://tbi-devops-agent-contexts/<repo-name>/docs/ --profile tbi-prod

# Upload integration directory
aws s3 sync integration/ s3://tbi-devops-agent-contexts/<repo-name>/integration/ --profile tbi-prod
```

### Downloading Files

To download documentation from a repository:

```bash
# Download all files for a repository
aws s3 sync s3://tbi-devops-agent-contexts/<repo-name>/ ./ --profile tbi-prod

# Download specific directory
aws s3 sync s3://tbi-devops-agent-contexts/<repo-name>/docs/ ./docs/ --profile tbi-prod
```

### Listing Files

```bash
# List all repositories
aws s3 ls s3://tbi-devops-agent-contexts/ --profile tbi-prod

# List files in a repository
aws s3 ls s3://tbi-devops-agent-contexts/<repo-name>/ --recursive --profile tbi-prod

# Count files
aws s3 ls s3://tbi-devops-agent-contexts/<repo-name>/ --recursive --profile tbi-prod | wc -l
```

## Access Control

The bucket uses AWS IAM policies for access control. Ensure you have the appropriate AWS profile configured:

```bash
# Configure AWS profile
aws configure --profile tbi-prod

# Test access
aws s3 ls s3://tbi-devops-agent-contexts/ --profile tbi-prod
```

## Use Cases

### 1. AI Agent Context
The tbi-agent can read documentation and configuration from this bucket to:
- Load system prompts for pipeline generation
- Access reference templates
- Read best practices and patterns
- Get integration guides

### 2. Documentation Hub
Centralized location for:
- Developer guides
- Deployment procedures
- Migration checklists
- Setup documentation

### 3. Integration Resources
Storage for:
- Integration code samples
- Configuration templates
- Implementation guides
- Kubernetes manifests

## Adding New Repositories

To add documentation for a new repository:

1. Navigate to the repository root
2. Run the upload commands with the repository name:

```bash
REPO_NAME=$(basename $(git rev-parse --show-toplevel))

aws s3 sync .kiro/ s3://tbi-devops-agent-contexts/${REPO_NAME}/.kiro/ --profile tbi-prod
aws s3 sync docs/ s3://tbi-devops-agent-contexts/${REPO_NAME}/docs/ --profile tbi-prod
aws s3 sync integration/ s3://tbi-devops-agent-contexts/${REPO_NAME}/integration/ --profile tbi-prod
```

## Maintenance

### Updating Files

Files are automatically synced when you run the upload commands. The `aws s3 sync` command only uploads changed files.

### Versioning

Consider enabling S3 versioning for important documentation:

```bash
aws s3api put-bucket-versioning \
  --bucket tbi-devops-agent-contexts \
  --versioning-configuration Status=Enabled \
  --profile tbi-prod
```

### Backup

The bucket serves as a backup for documentation. Ensure your local repositories are the source of truth.

## Integration with tbi-agent

The tbi-agent can access this bucket to:

1. **Load System Prompts**: Read AI system prompts from `.kiro/` directories
2. **Access Templates**: Use reference templates for pipeline generation
3. **Read Documentation**: Provide context-aware responses based on documentation
4. **Fetch Integration Guides**: Help users with implementation steps

Example tbi-agent integration:

```javascript
// In pipeline-deployer.js
const AWS = require('aws-sdk');
const s3 = new AWS.S3({ region: 'ca-central-1' });

async function loadSystemPrompt(repoName) {
  const params = {
    Bucket: 'tbi-devops-agent-contexts',
    Key: `${repoName}/.kiro/steering/circleci-pipeline-patterns.md`
  };
  
  const data = await s3.getObject(params).promise();
  return data.Body.toString('utf-8');
}
```

## Cost Optimization

- Use S3 Intelligent-Tiering for automatic cost optimization
- Enable lifecycle policies for old versions
- Monitor storage usage regularly

```bash
# Check bucket size
aws s3 ls s3://tbi-devops-agent-contexts/ --recursive --profile tbi-prod --summarize
```

## Security Best Practices

1. **Encryption**: Enable server-side encryption
2. **Access Logs**: Enable S3 access logging
3. **Bucket Policy**: Restrict access to authorized users/roles
4. **MFA Delete**: Enable MFA delete for production buckets

## Support

For issues or questions:
- Check AWS CloudWatch logs
- Review IAM policies
- Verify AWS profile configuration
- Contact DevOps team

## Related Resources

- AWS S3 Documentation: https://docs.aws.amazon.com/s3/
- TBI DevOps Environments: https://github.com/redlabelvacations/tbi-devops-environments
- tbi-agent Documentation: See `integration/tbi-agent-pipeline-integration/`

---

**Last Updated**: 2026-03-02
**Bucket Created**: 2026-03-02
**Total Files**: 26 (tbi-devops-environments)
**Total Repositories**: 1
