InfraHouse Core
Lightweight Python library with AWS and other general purpose classes.
Free software: Apache Software License 2.0
Documentation: https://infrahouse-core.readthedocs.io.
Requirements
Python 3.10+
Linux or macOS (Windows is not supported)
Installation
pip install infrahouse-core
Features
AWS Classes
EC2Instance - Manage EC2 instances with SSM command execution support
ASGInstance - EC2 instance within an AutoScaling Group (lifecycle state, protection, health)
ASG - AutoScaling Group lifecycle management (instance refresh, lifecycle hooks)
DynamoDBTable - DynamoDB operations with distributed locking support
Route53 Zone - DNS record management (add/delete A records)
Secret - AWS Secrets Manager operations (create, read, update, delete)
AWS Session Management - SSO login, role assumption, credential handling via get_session(), get_client(), get_resource() helpers
GitHub Integration
GitHubActions - Manage self-hosted GitHub Actions runners
GitHubActionsRunner - Query runner status, labels, and metadata
Token generation from GitHub App credentials stored in AWS Secrets Manager
Orchestrator
OrchestratorRaftCluster - Reconcile MySQL Orchestrator Raft membership against an ASG
OrchestratorRaftNode - Interact with a single Orchestrator node’s Raft API via SSM
Utilities
Input Validation - Validators for AWS resource identifiers (instance IDs, ARNs, regions, DNS names)
Timeout - Context manager for enforcing execution time limits (POSIX only)
Filesystem - Secure permission management (ensure_permissions())
Logging - Configurable logging setup with stdout/stderr separation
Usage Examples
EC2 Instance with SSM Command Execution
from infrahouse_core.aws.ec2_instance import EC2Instance
# Connect to an instance (optionally assume a role for cross-account access)
instance = EC2Instance(
instance_id="i-0123456789abcdef0",
region="us-east-1",
role_arn="arn:aws:iam::123456789012:role/MyRole" # optional
)
# Execute a command via SSM
exit_code, stdout, stderr = instance.execute_command("hostname")
# Access instance properties
print(instance.private_ip)
print(instance.hostname)
print(instance.tags)
DynamoDB Distributed Lock
from infrahouse_core.aws.dynamodb import DynamoDBTable
table = DynamoDBTable("my-lock-table", region="us-east-1")
with table.lock("my-resource", timeout=30):
# Critical section - only one process can hold this lock
do_exclusive_work()
Route53 DNS Management
from infrahouse_core.aws.route53.zone import Zone
zone = Zone(zone_name="example.com")
# Add an A record
zone.add_record("myhost", "10.0.0.1", ttl=300)
# Delete an A record
zone.delete_record("myhost", "10.0.0.1")
Secrets Manager
from infrahouse_core.aws.secretsmanager import Secret
# Read a secret
secret = Secret("my-app/api-key", region="us-east-1")
print(secret.value) # Returns dict if JSON, else string
# Create or update a secret
secret.ensure_present({"username": "admin", "password": "secret123"})
# Cross-account access
secret = Secret(
"prod/database-creds",
role_arn="arn:aws:iam::123456789012:role/SecretsReader"
)
Cross-Account AWS Access
from infrahouse_core.aws import get_client, get_session
# Get a client with assumed role
ec2 = get_client(
"ec2",
role_arn="arn:aws:iam::123456789012:role/CrossAccountRole",
region="us-west-2"
)
# Or get a session for multiple clients
session = get_session(role_arn="arn:aws:iam::123456789012:role/MyRole")
ec2 = session.client("ec2")
s3 = session.client("s3")
Orchestrator Raft Reconciliation
from infrahouse_core.orchestrator import OrchestratorRaftCluster
cluster = OrchestratorRaftCluster(
"my-orchestrator-asg",
region="us-east-1",
role_arn="arn:aws:iam::123456789012:role/OrchestratorRole", # optional
)
# Reconcile Raft peers with live ASG instances
# (removes stale peers, adds missing ones)
cluster.reconcile()
# Inspect current state
for node in cluster.nodes:
print(f"{node.hostname}: leader={node.is_leader}")
GitHub Actions Runner Management
from infrahouse_core.github import GitHubActions, GitHubAuth
github = GitHubAuth(token="ghp_...", org="my-org")
actions = GitHubActions(github)
# List all runners
for runner in actions.runners:
print(f"{runner.name}: {runner.status}")
# Find runners by label
runners = actions.find_runners_by_label("self-hosted")
Contributing
Contributions are welcome! Please see CONTRIBUTING.rst for guidelines.
License
Apache Software License 2.0. See LICENSE for details.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Metadata
Release files for infrahouse-core 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| infrahouse_core-1.3.0.tar.gz | 125.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| infrahouse_core-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 221.1 kB
Release files / infrahouse_core-1.3.0.tar.gz
| Download URL | infrahouse_core-1.3.0.tar.gz |
|---|---|
| Size | 125.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b27640118bb1b93a997e0ba9bab56aafa89bb5a9eb3b3b6266ee342d2e083376
|
|
BLAKE2b-256 checksum How to use checksums |
9163a2624043402df14dd4fb6364658d60e0f41a6fdad08de6cbdc3b404b76b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.11
|
Release files / infrahouse_core-1.3.0-py3-none-any.whl
| Download URL | infrahouse_core-1.3.0-py3-none-any.whl |
|---|---|
| Size | 95.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef64d64021ce190b021acb497571692f0a8941f6e932702ed590dc374d6ab683
|
|
BLAKE2b-256 checksum How to use checksums |
e99bce9f7eab7283101f047c63c974e85581d2d7fd8a4efc3990abfbeff6db90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.11
|
Security for infrahouse-core 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.