Skip to main content

AWS Transactional Apps - A reusable Python CDKTF package for provisioning EC2-based Docker architectures with S3 script deployment

Project description

AWSTransactionalApps

A reusable Python CDKTF package that provisions the complete AWS Transactional Apps architecture, uploads all required runtime scripts to an S3 deployment bucket, and provides a sample project to validate the package.

Features

  • EC2 Instance Provisioning: Creates EC2 instances with proper IAM roles and instance profiles
  • S3 Script Deployment: Automatically uploads runtime scripts (setup, loader, bootstrap, update) to S3
  • ECR Integration: Conditional ECR repository creation for Docker images
  • RDS Support: Optional PostgreSQL RDS instance creation
  • Secrets Manager: Integrated secrets management for application configuration
  • SystemD Services: Includes systemd service and timer configurations

Architecture Components

  • setup.sh: Initial EC2 setup script downloaded via user data
  • loader.sh: Application loader script
  • bootstrap.sh: Runtime bootstrap script
  • update.sh: Application update script
  • docker-compose.yml: Docker Compose configuration template
  • SystemD services: awsec2-loader.service, awsec2-app.service, awsec2-app-update.timer

Installation

Prerequisites

  • Python 3.8+
  • Node.js 16+ (for CDKTF)
  • AWS CLI configured with appropriate credentials
  • Terraform 1.0+

Install the Package Locally

# Clone the repository
cd /Repos/AWSTransactionalApps

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install the package in editable mode
pip install -e AWSTransactionalApps/

Quick Start

Using the Sample Project

# Navigate to sample directory
cd /Repos/AWSTransactionalApps/sample

# Install sample project dependencies
pip install -r requirements.txt

# Generate CDKTF provider bindings (first time only)
cdktf get

# Synthesize Terraform configuration
cdktf synth

# Review the Terraform plan
cdktf diff

# Deploy the infrastructure
cdktf deploy

Usage

Basic Usage

from cdktf import App
from AWSTransactionalAppsStack import DockerEC2

app = App()

DockerEC2(
    app,
    "my-app-stack",
    project_name="my-project",
    region="us-east-1",
    ami_id="ami-0c2b8ca1dad447f8a",
    instance_type="t4g.medium",
    disk_size=100,
)

app.synth()

Configuration Options

Parameter Type Default Description
project_name str Required Unique project identifier
region str ca-central-1 AWS region
ami_id str ami-0c2b8ca1dad447f8a EC2 AMI ID
instance_type str t4g.medium EC2 instance type
disk_size int 100 Root volume size in GB
platform_name str None Platform name (defaults to project_name)
deployment_bucket str None S3 bucket for deployments
storage_bucket str None S3 bucket for storage
enable_rds bool False Enable RDS PostgreSQL
rds_name str None RDS instance identifier
private_ecr bool True Use private ECR

IAM Permissions

The EC2 instance is provisioned with the following IAM permissions:

  • ec2:DescribeTags
  • ec2:DescribeInstances
  • s3:GetObject
  • s3:ListBucket
  • ecr:GetAuthorizationToken
  • ecr:BatchGetImage
  • ecr:BatchCheckLayerAvailability
  • ecr:GetDownloadUrlForLayer
  • secretsmanager:GetSecretValue
  • secretsmanager:ListSecrets
  • secretsmanager:DescribeSecret
  • logs:CreateLogGroup
  • logs:CreateLogStream
  • logs:PutLogEvents

Project Structure

AWSTransactionalApps/
├── setup.py
├── pyproject.toml
├── README.md
├── requirements.txt
└── AWSTransactionalAppsStack/
    ├── __init__.py
    ├── config.py
    ├── DockerEC2.py
    ├── uploader.py
    ├── iam/
    │   └── ec2_policy.json
    └── scripts/
        ├── setup/
        │   └── setup.sh
        ├── loader/
        │   └── loader.sh
        ├── runtime/
        │   ├── bootstrap.sh
        │   └── update.sh
        ├── systemd/
        │   ├── awsec2-loader.service
        │   ├── awsec2-app.service
        │   └── awsec2-app-update.timer
        └── compose/
            └── docker-compose.yml

Development

Running Tests

# From the package directory
pip install pytest
pytest tests/

Building the Package

pip install build
python -m build

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and feature requests, please visit: https://dev.azure.com/buzzerboyinc/buzzerboy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awstransactionalapps-0.5.1.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awstransactionalapps-0.5.1-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file awstransactionalapps-0.5.1.tar.gz.

File metadata

  • Download URL: awstransactionalapps-0.5.1.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.14.2

File hashes

Hashes for awstransactionalapps-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3a26ea7cb2db694c2e2b4e945d65e46a04663886e7ccbd0041a51727583f18dc
MD5 997b28d7c360404b6041f052d14740c0
BLAKE2b-256 2f08bf575b3af8b695abacb8a04e6d2abe87a6cf00be769c3358a94ad50ef711

See more details on using hashes here.

File details

Details for the file awstransactionalapps-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for awstransactionalapps-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c96a99bc4382f35f501fe7f0286112d4df7556ebd375356a65df3af4f3ff2098
MD5 877c909f46a5baecbd4f1c70db019e8e
BLAKE2b-256 ae774dadf8821906a1c18cb2b6070c78294c672afad495c1d0a5c8bbc3b0202b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page