Overview
The ECR (Elastic Container Registry) Module manages container image repositories for the Artos platform. It creates separate repositories for environment-specific application components and shared third-party services, with configurable lifecycle policies, security scanning, encryption, and cross-account access controls.Key Features
- Environment Isolation: Separate repositories per environment (development, staging, production)
- Automatic Image Cleanup: Lifecycle policies to manage storage costs
- Security Scanning: Automatic vulnerability scanning on image push
- Encryption: Support for AES256 and KMS encryption
- Cross-Account Access: Enable image sharing across AWS accounts
- Third-Party Image Management: Centralized repositories for shared dependencies
Container Images
The module creates repositories for two types of container images: Environment-Specific images that are isolated per environment, and Third-Party/Shared images that are centralized across environments.Environment-Specific Images
These repositories are created for each environment (development, staging, production) and contain custom Artos application code.1. Backend API (artos-postgres-eks-backend)
Repository Name: {environment}/artos-postgres-eks-backend
The main application backend API server that handles HTTP requests, business logic, and database interactions.
Contains:
- FastAPI REST API server for core Artos platform logic and routes
- Database models and migrations
- Authentication and authorization logic
2. Celery Workers (artos-postgres-eks-celery)
Repository Name: {environment}/artos-postgres-eks-celery
Asynchronous task workers for background job processing, scheduled tasks, and long-running operations.
Contains:
- Celery worker processes
- Task definitions and handlers
- Background job processors
- Scheduled task runners
- Queue consumers
- Document generation workflows
- Document editing workflows
3. Frontend Application (frontend)
Repository Name: {environment}/frontend
The user-facing web application frontend built with modern JavaScript frameworks.
Contains:
- frontend UI and functionality for the Artos platform
Third-Party/Shared Images
These repositories are created once (typically in a shared or production account) and used across all environments to avoid duplication and ensure consistency.Important: Set
create_thirdparty_repos = true in only one environment (typically production or a shared services account) to avoid repository name conflicts. Other environments should reference these shared repositories.4. Redis Cache (thirdparty/redis)
Repository Name: thirdparty/redis
Redis container images used for caching, session storage, and message brokering.
Purpose:
- Application caching layer
- Celery message broker
- Rate limiting data store
5. OnlyOffice Document Server (thirdparty/onlyoffice)
Repository Name: thirdparty/onlyoffice
OnlyOffice Document Server for collaborative document editing and viewing.
Purpose:
- Word document editing (DOCX)
- Real-time collaboration
6. LiteLLM Proxy (thirdparty/litellm)
Repository Name: thirdparty/litellm
LiteLLM proxy server for unified LLM (Large Language Model) API access.
Purpose:
- Unified interface for multiple LLM providers (OpenAI, Anthropic, etc.)
- API key management and rotation
- Request rate limiting and cost tracking
- Load balancing across LLM endpoints
- Caching for improved performance
7. PropelAuth (thirdparty/propelauth)
Repository Name: thirdparty/propelauth
PropelAuth authentication and user management service.
Purpose:
- User authentication and authorization
- SSO (Single Sign-On) integration
- Multi-factor authentication (MFA)
- User management and organization features
- OAuth and SAML support
Image Management Policies
1. Lifecycle Policies
Lifecycle policies automatically delete older images to manage storage costs while retaining recent versions. Note: allmax_image_count values are set to 0 to ensure all versions are stored in ECR.
How It Works:
- Triggered when image count exceeds
max_image_count - Deletes oldest images first (by push timestamp)
- Applies to both tagged and untagged images
- Runs automatically (no manual intervention needed)
max_image_count | Behavior |
|---|---|
null or 0 | No lifecycle policy (keep all images indefinitely) |
1-1000 | Keep only the specified number of most recent images |
2. Cross-Account Access Policies
Cross-account policies enable other AWS accounts to pull images from your ECR repositories, useful for multi-account architectures or shared services. Note: default terraform has cross_account_ids set to an empty list. Cross account ids are usually added manually after the terraform is spun up. Policy Configuration:ecr:GetDownloadUrlForLayer- Download image layersecr:BatchGetImage- Retrieve image metadataecr:BatchCheckLayerAvailability- Check if layers exist
- Centralized Image Registry: Production account hosts all images, other accounts pull as needed
- Multi-Region Deployments: Share images across regions via cross-account replication
- Shared Services: Development account provides common third-party images to all environments
3. Image Scanning
Automatically scans container images for security vulnerabilities (CVEs) upon push. Configuration:- Image is pushed to ECR repository
- ECR triggers automatic vulnerability scan
- Results available in AWS Console or via API within minutes
- Findings categorized by severity: CRITICAL, HIGH, MEDIUM, LOW, INFORMATIONAL
5. Encryption
All images are encrypted at rest using either AWS-managed or customer-managed encryption keys. Configuration Options: AES256 (Default - AWS-Managed):Module Configuration
Basic Configuration
Production Configuration with KMS
Shared Services Configuration
Development Configuration
Repository Naming Convention
The module follows a consistent naming pattern for easy identification and organization: Environment-Specific Repositories:Pushing Images to ECR
Authenticate Docker to ECR
Build and Push Application Images
Pull Third-Party Images
Related Modules
- EKS Module - References ECR images for Kubernetes deployments
- Bastion Module - Uses kubectl binary stored in S3 or ECR
- Monitoring Module - Tracks ECR metrics and image scan results
Module Maintenance: This module is compatible with Terraform 1.0+ and AWS Provider 5.x. All repositories are automatically tagged with environment and component metadata for resource tracking and cost allocation.