Buzzerboy Architecture Standard for Buzzerboy Based Architectures
Project description
AWS Architecture Base
A comprehensive AWS infrastructure framework built with CDKTF (Cloud Development Kit for Terraform) and Python, providing standardized deployment patterns for AWS Lightsail container services with automated SSL certificate management and domain attachment.
๐๏ธ Overview
The AWS Architecture Base provides a standardized foundation for deploying containerized applications on AWS Lightsail with enterprise-grade features including:
- Infrastructure as Code: Built on CDKTF with Python for type-safe infrastructure definitions
- Container Deployment: Automated Docker image building, tagging, and deployment to AWS Lightsail
- SSL/TLS Management: Automated SSL certificate creation and domain attachment
- Secret Management: Integration with AWS Secrets Manager for secure configuration
- Architecture Flags: Configurable deployment options for different environments
- Post-Deployment Automation: Customizable scripts for additional setup tasks
๐ Features
Core Infrastructure
- Base Class Architecture: Extensible
AWSArchitectureBaseclass for common AWS patterns - Provider Management: Automatic setup of AWS, Random, and Null Terraform providers
- S3 Backend: Automated S3 bucket creation and Terraform state management
- Resource Registry: Centralized resource tracking and management
Container Deployment
- Lightsail Integration: Specialized
BBAWSLightsailMiniV1aDeployclass for container services - Docker Automation: Build, tag, and push workflows with caching support
- Environment Management: Configurable environment variables and secrets injection
- Health Checks: Automated health check configuration for container endpoints
Domain & SSL Management
- Custom Domains:
LightSailDomainAttachWrapperfor domain attachment automation - SSL Certificates: Automatic certificate creation and validation
- DNS Integration: Route53 integration for domain management
- Fallback Guidance: Manual command generation for troubleshooting
Configuration Management
- Architecture Flags: Feature toggles for optional components
SKIP_DATABASE: Skip database creationSKIP_DOMAIN: Skip domain and DNS configurationSKIP_SSL_CERT: Skip SSL certificate creationSKIP_DEFAULT_POST_APPLY_SCRIPTS: Skip default post-apply scripts
- Environment Profiles: Support for multiple AWS profiles and regions
- Archetype Integration: Integration with Buzzerboy archetype patterns
๐ฆ Installation
Prerequisites
- Python 3.8 or higher
- AWS CLI configured with appropriate credentials
- Docker (for container deployments)
- Node.js (for CDKTF)
Install from Package Registry
# Install from Buzzerboy's private registry
pip install AWSArchitectureBase
Development Installation
# Clone the repository
git clone <repository-url>
cd AWSArchitectureBase
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
๐ง Quick Start
Basic Container Service Deployment
from AWSArchitectureBase.AWSArchitectureBaseStack import AWSArchitectureBase, ArchitectureFlags
from cdktf import App
app = App()
# Get archetype configuration
archetype = AWSArchitectureBase.get_archetype(
product='myapp',
app='api',
tier='dev',
organization='myorg',
region='ca-central-1'
)
# Configuration flags
ArchitectureFlags = AWSArchitectureBase.get_architecture_flags()
flags = [
ArchitectureFlags.SKIP_DATABASE.value,
ArchitectureFlags.SKIP_SSL_CERT.value,
]
# Custom domains
domains = [
f"{archetype.get_tier()}.api.example.com"
]
# Post-deployment scripts
post_apply_scripts = [
"echo '๐ Deployment verification complete'",
"echo '๐ Container service is ready'",
]
# Create the stack
stack = AWSArchitectureBase(
app,
"my-lightsail-service",
project_name=archetype.get_project_name(),
environment=archetype.get_tier(),
region=archetype.get_region(),
secret_name=archetype.get_secret_name(),
profile="default",
flags=flags,
domains=domains,
state_bucket_name="my-tfstate-bucket",
postApplyScripts=post_apply_scripts,
)
archetype.set_stack(stack)
app.synth()
Container Deployment Automation
from AWSArchitectureBase.AWSArchitectureBaseStack import AWSArchitectureDeploy
# Initialize deployment helper
deployer = AWSArchitectureDeploy(
product='myapp',
app='api',
tier='dev',
organization='myorg',
region='ca-central-1',
debug=True,
version='1.0.0'
)
# Execute deployment pipeline
deployer.app_deploy()
Domain Attachment with SSL
from AWSArchitectureBase.AWSArchitectureBaseStack.LightSailDomainAttachWrapper import LightSailDomainAttachWrapper
# Initialize domain wrapper
domain_wrapper = LightSailDomainAttachWrapper(
domains=["api.example.com", "app.example.com"],
region="ca-central-1",
container_service_name="my-app-service"
)
# Get attachment script
attach_script = domain_wrapper.get_attach_command()
print(attach_script)
๐๏ธ Architecture
Project Structure
AWSArchitectureBase/
โโโ AWSArchitectureBaseStack/
โ โโโ __init__.py
โ โโโ AWSArchitectureBase.py # Main base class
โ โโโ ArchitectureFlags.py # Configuration flags
โ โโโ BBAWSLightsailMiniV1aDeploy.py # Container deployment
โ โโโ LightSailDomainAttachWrapper.py # Domain management
โโโ pyproject.toml # Package configuration
โโโ requirements.txt # Python dependencies
โโโ Makefile # Build automation
Key Components
AWSArchitectureBase Class
The core infrastructure class providing:
- Terraform provider initialization
- S3 backend configuration
- Resource registry management
- Architecture flag handling
- Utility methods for AWS naming conventions
BBAWSLightsailMiniV1aDeploy Class
Container deployment automation including:
- Docker image building and caching
- AWS Lightsail container service management
- Secret management integration
- Environment variable configuration
- Deployment pipeline orchestration
LightSailDomainAttachWrapper Class
Domain and SSL management featuring:
- SSL certificate creation and validation
- Custom domain attachment automation
- DNS integration support
- Manual fallback command generation
๐ Configuration
Environment Variables
export AWS_PROFILE=your-profile
export AWS_REGION=ca-central-1
export VERBOSE=true # Enable verbose logging
Architecture Flags
Control deployment features using architecture flags:
from AWSArchitectureBase.AWSArchitectureBaseStack import ArchitectureFlags
flags = [
ArchitectureFlags.SKIP_DATABASE.value, # Skip RDS/database setup
ArchitectureFlags.SKIP_SSL_CERT.value, # Skip SSL certificate creation
ArchitectureFlags.SKIP_DOMAIN.value, # Skip domain configuration
ArchitectureFlags.SKIP_DEFAULT_POST_APPLY_SCRIPTS.value, # Skip default scripts
]
AWS Secrets Manager
Store application secrets in AWS Secrets Manager:
{
"database_url": "postgresql://...",
"api_keys": "...",
"jwt_secret": "..."
}
Secret path format: {organization}/{tier}/{product}-{app}-{tier}
๐ Deployment
Using CDKTF
# Initialize and plan
cdktf init
cdktf plan
# Deploy infrastructure
cdktf deploy
# Destroy when needed
cdktf destroy
Using Make (for package development)
# Clean and build
make clean build
# Publish to registry
make publish TYPE=patch # or minor, major
๐ Examples
Multi-Environment Deployment
# Development environment
dev_stack = AWSArchitectureBase(
app, "my-app-dev",
environment="dev",
region="ca-central-1",
flags=[ArchitectureFlags.SKIP_SSL_CERT.value]
)
# Production environment
prod_stack = AWSArchitectureBase(
app, "my-app-prod",
environment="prod",
region="us-east-1",
flags=[] # All features enabled
)
Custom Post-Deploy Scripts
post_apply_scripts = [
"echo '๐ Running database migrations'",
"python manage.py migrate",
"echo '๐ Warming up application cache'",
"curl -X POST https://api.example.com/warmup",
"echo '๐ Notifying monitoring systems'",
"curl -X POST https://monitoring.example.com/deploy-complete"
]
๐งช Testing
Unit Tests
# Run all tests
python -m pytest
# Run with coverage
python -m pytest --cov=AWSArchitectureBase
Integration Tests
# Test infrastructure deployment
cdktf plan --var-file=test.tfvars
# Test container deployment
python test_deployment.py
๐ง Development
Setup Development Environment
# Clone repository
git clone <repository-url>
cd AWSArchitectureBase
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
venv\Scripts\activate # Windows
# Install development dependencies
pip install -r requirements.txt
pip install -e .
# Install pre-commit hooks
pre-commit install
Building and Publishing
# Version bump and build
make publish TYPE=patch
# Manual build
python -m build
twine upload dist/*
๐ API Reference
AWSArchitectureBase Methods
get_architecture_flags(): Get available configuration flagsget_archetype(): Get archetype configurationhas_flag(): Check if architecture flag is setget_extra_secret_env(): Parse extra secrets from environmentexecute_post_apply_scripts(): Run post-deployment scripts
Utils Module
properize_string(string): Convert string to valid AWS resource nameclean_hyphens(string): Convert string for database namingparse_secrets_from_env(env_var_name): Parse JSON secrets from environment
BBAWSLightsailMiniV1aDeploy Methods
app_deploy(): Execute complete deployment pipelinebuild_docker_image(): Build Docker image for deploymentpush_docker_image(): Push image to Lightsail registrydeploy_docker_image(): Deploy container serviceget_container_fqdn(): Get container service URL
LightSailDomainAttachWrapper Methods
get_attach_command(): Generate domain attachment scriptget_certificate_creation_command(): Generate SSL cert creation commandget_domain_attachment_command(): Generate domain attachment command
๐ Troubleshooting
Common Issues
SSL Certificate Validation Timeout
# Check certificate status
aws lightsail get-certificates --region ca-central-1 --include-certificate-details
# Manual domain attachment after validation
aws lightsail update-container-service \
--service-name my-service \
--region ca-central-1 \
--public-domain-names '{"example.com": ["example.com"]}'
Docker Build Failures
# Clear Docker cache
docker system prune -a
# Rebuild without cache
docker build --no-cache -t my-service .
Terraform State Issues
# Refresh state
cdktf refresh
# Import existing resources
cdktf import aws_lightsail_container_service.example my-service
๐ค Contributing
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
pytest) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Create a Pull Request
Code Standards
- Follow PEP 8 style guidelines
- Add type hints for all public methods
- Include docstrings for classes and methods
- Write unit tests for new functionality
- Update documentation for API changes
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ข About Buzzerboy
AWS Architecture Base is developed and maintained by Buzzerboy Inc. For enterprise support and consulting services, contact us at info@buzzerboy.com.
๐ Related Projects
- BuzzerboyArchetype - Enterprise archetype patterns
- CDKTF Documentation - Cloud Development Kit for Terraform
- AWS Lightsail - AWS Lightsail container services
Made with โค๏ธ by the Buzzerboy Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file awsarchitecturebase-0.15.0.tar.gz.
File metadata
- Download URL: awsarchitecturebase-0.15.0.tar.gz
- Upload date:
- Size: 80.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e551417c2dbfdcb2faf68cb21cbf014d9172470d3febe8c18b158863215a9f11
|
|
| MD5 |
3865014ec0292792fb5f9b3d5e0116a0
|
|
| BLAKE2b-256 |
3b0945f53d72b967bafbcadfed5a91af1746eae91700e42ef1d166967f07164e
|
File details
Details for the file awsarchitecturebase-0.15.0-py3-none-any.whl.
File metadata
- Download URL: awsarchitecturebase-0.15.0-py3-none-any.whl
- Upload date:
- Size: 109.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e17bc79962c3dd794f679391d188298750b98ee52b91e70e5d7413882846a07
|
|
| MD5 |
84fd87b222c1c093c50e7a5526df0b89
|
|
| BLAKE2b-256 |
1f0ee08408ff7411be64bbdcb4ea292c6516f2a18c28a6c5b93adc28435cacd9
|