Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
- RDS: configurable tmpfs size via RDS_TMPFS_SIZE env var (default 256m) (#150)
Nahuel Nucera6a2204a6339a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 19f89f62..4fe3c5ff 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,10 +7,19 @@ Versioning follows [Semantic Versioning](https://semver.org/).---+## [1.1.42] — 2026-04-06++### Added+- **RDS configurable tmpfs size** — `RDS_TMPFS_SIZE` env var (default `256m`). Set to `2g` or higher for large database testing+- **CloudFront tagging** — `TagResource`, `UntagResource`, `ListTagsForResource` for distributions. Enables Terraform CloudFront with tags++---+## [1.1.41] — 2026-04-06### Fixed- **ElastiCache persistence crash on restart** — `restore_state()` called `_get_docker()` before it was defined, causing `NameError` when `PERSIST_STATE=1`. Reported by @adamkirk (#145)+- **RDS persistence crash on restart** — same `_get_docker()` ordering issue in `restore_state()`---diff --git a/README.md b/README.mdindex ea1b0f76..ac0d9ebc 100644--- a/README.md+++ b/README.md@@ -483,6 +483,7 @@ ecs.stop_task(cluster="dev", task=task_arn)| `REDIS_HOST` | `redis` | Redis host for ElastiCache fallback || `REDIS_PORT` | `6379` | Redis port for ElastiCache fallback || `RDS_BASE_PORT` | `15432` | Starting host port for RDS containers |+| `RDS_TMPFS_SIZE` | `256m` | Tmpfs size for RDS database containers. Set to `2g` or higher for large databases || `ELASTICACHE_BASE_PORT` | `16379` | Starting host port for ElastiCache containers || `PERSIST_STATE` | `0` | Set `1` to persist service state across restarts || `STATE_DIR` | `/tmp/ministack-state` | Directory for persisted state files |diff --git a/ministack/services/cloudfront.py b/ministack/services/cloudfront.pyindex 492f7728..ae813bc3 100644--- a/ministack/services/cloudfront.py+++ b/ministack/services/cloudfront.py@@ -35,29 +35,34 @@ _DIST_CFG_RE = re.compile(r"^/2020-05-31/distribution/([^/]+)/config$")_DIST_ID_RE = re.compile(r"^/2020-05-31/distribution/([^/]+)/?$")_INV_RE = re.compile(r"^/2020-05-31/distribution/([^/]+)/invalidation/?$")_INV_ID_RE = re.compile(r"^/2020-05-31/distribution/([^/]+)/invalidation/([^/]+)$")+_TAG_RE = re.compile(r"^/2020-05-31/tagging/?$")# ---------------------------------------------------------------------------# In-memory state# ---------------------------------------------------------------------------_distributions: dict = {} # Id -> distribution record_invalidations: dict = {} # distribution_id -> [invalidation record, ...]+_tags: dict = {} # arn -> [{"Key": ..., "Value": ...}]def reset():_distributions.clear()_invalidations.clear()+ _tags.clear()def get_state():return copy.deepcopy({"distributions": _distributions,"invalidations": _invalidations,+ "tags": _tags,})def restore_state(data):_distributions.update(data.get("distributions", {}))_invalidations.update(data.get("invalidations", {}))+ _tags.update(data.get("tags", {}))_restored = load_state("cloudfront")@@ -210,6 +215,17 @@ async def handle_request(method, path, headers, body, query_params):if method == "GET":return _get_invalidation(dist_id, inv_id)+ m = _TAG_RE.match(path)+ if m:+ resource = query_params.get("Resource", [""])[0] if isinstance(query_params.get("Resource"), list) else query_params.get("Resource", "")+ operation = query_params.get("Operation", [""])[0] if isinstance(query_params.get("Operation"), list) else query_params.get("Operation", "")+ if method == "GET":+ return _list_tags(resource)+ if method == "POST" and operation == "Tag":+ return _tag_resource(resource, body)+ if method == "POST" and operation == "Untag":+ return _untag_resource(resource, body)+return _error("NoSuchResource", f"No route for {method} {path}", 404)@@ -434,3 +450,50 @@ def _get_invalidation(dist_id, inv_id):_build_invalidation_xml(root, inv)return _xml_response("Invalidation", build)+++# ---------------------------------------------------------------------------+# Tagging+# ---------------------------------------------------------------------------++def _list_tags(resource_arn):+ tags = _tags.get(resource_arn, [])+ root = Element("Tags", xmlns=NS)+ items = SubElement(root, "Items")+ for t in tags:+ tag_el = SubElement(items, "Tag")+ SubElement(tag_el, "Key").text = t["Key"]+ SubElement(tag_el, "Value").text = t["Value"]+ body = tostring(root, encoding="unicode")+ return 200, {"Content-Type": "application/xml"}, f'<?xml version="1.0" encoding="UTF-8"?>\n{body}'.encode()+++def _tag_resource(resource_arn, body):+ el = _parse_body(body)+ items_el = _find(el, "Items") or _find(el, "Tags")+ if items_el is None:+ items_el = el+ existing = {t["Key"]: t for t in _tags.get(resource_arn, [])}+ for tag_el in items_el:+ local = tag_el.tag.split("}")[-1] if "}" in tag_el.tag else tag_el.tag+ if local == "Tag":+ key = _text(tag_el, "Key")+ val = _text(tag_el, "Value")+ if key:+ existing[key] = {"Key": key, "Value": val}+ _tags[resource_arn] = list(existing.values())+ return 204, {}, b""+++def _untag_resource(resource_arn, body):+ el = _parse_body(body)+ items_el = _find(el, "Items") or _find(el, "Keys")+ if items_el is None:+ items_el = el+ remove_keys = set()+ for child in items_el:+ local = child.tag.split("}")[-1] if "}" in child.tag else child.tag+ if local == "Key":+ remove_keys.add(child.text or "")+ _tags[resource_arn] = [t for t in _tags.get(resource_arn, []) if t["Key"] not in remove_keys]+ return 204, {}, b""diff --git a/ministack/services/rds.py b/ministack/services/rds.pyindex b5818388..911c1c79 100644--- a/ministack/services/rds.py+++ b/ministack/services/rds.py@@ -37,6 +37,7 @@ logger = logging.getLogger("rds")ACCOUNT_ID = os.environ.get("MINISTACK_ACCOUNT_ID", "000000000000")REGION = os.environ.get("MINISTACK_REGION", "us-east-1")BASE_PORT = int(os.environ.get("RDS_BASE_PORT", "15432"))+RDS_TMPFS_SIZE = os.environ.get("RDS_TMPFS_SIZE", "256m")_instances: dict = {}_clusters: dict = {}@@ -182,8 +183,8 @@ def _create_db_instance(p):ports={f"{container_port}/tcp": host_port},name=f"ministack-rds-{db_id}",labels={"ministack": "rds", "db_id": db_id},- tmpfs={"/var/lib/postgresql/data": "rw,noexec,nosuid,size=256m",- "/var/lib/mysql": "rw,noexec,nosuid,size=256m"},+ tmpfs={"/var/lib/postgresql/data": f"rw,noexec,nosuid,size={RDS_TMPFS_SIZE}",+ "/var/lib/mysql": f"rw,noexec,nosuid,size={RDS_TMPFS_SIZE}"},)docker_container_id = container.idlogger.info("RDS: started %s container for %s on port %s", engine, db_id, host_port)diff --git a/pyproject.toml b/pyproject.tomlindex 47c454b4..3b9af88a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "ministack"-version = "1.1.41"+version = "1.1.42"description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"readme = "README.md"license = { file = "LICENSE" }diff --git a/tests/test_services.py b/tests/test_services.pyindex bf0800db..af350fc7 100644--- a/tests/test_services.py+++ b/tests/test_services.py@@ -19647,3 +19647,48 @@ def test_cfn_stack_with_s3_lambda_dynamodb(cfn, s3, lam, ddb):stacks = cfn.describe_stacks()["Stacks"]active = [st for st in stacks if st["StackName"] == stack_name and "DELETE" not in st["StackStatus"]]assert len(active) == 0+++# ---------------------------------------------------------------------------+# CloudFront v1.1.42 — tags+# ---------------------------------------------------------------------------++def test_cloudfront_tags(cloudfront):+ """TagResource / ListTagsForResource / UntagResource for CloudFront distributions."""+ resp = cloudfront.create_distribution(+ DistributionConfig={+ "CallerReference": "tag-test-v42",+ "Origins": {"Items": [{"Id": "o1", "DomainName": "example.com",+ "S3OriginConfig": {"OriginAccessIdentity": ""}}], "Quantity": 1},+ "DefaultCacheBehavior": {+ "TargetOriginId": "o1", "ViewerProtocolPolicy": "allow-all",+ "ForwardedValues": {"QueryString": False, "Cookies": {"Forward": "none"}},+ "MinTTL": 0,+ },+ "Comment": "tag test", "Enabled": True,+ }+ )+ dist_arn = resp["Distribution"]["ARN"]++ cloudfront.tag_resource(+ Resource=dist_arn,+ Tags={"Items": [+ {"Key": "env", "Value": "test"},+ {"Key": "team", "Value": "platform"},+ ]},+ )++ tags = cloudfront.list_tags_for_resource(Resource=dist_arn)+ tag_map = {t["Key"]: t["Value"] for t in tags["Tags"]["Items"]}+ assert tag_map["env"] == "test"+ assert tag_map["team"] == "platform"++ cloudfront.untag_resource(+ Resource=dist_arn,+ TagKeys={"Items": ["team"]},+ )++ tags = cloudfront.list_tags_for_resource(Resource=dist_arn)+ tag_keys = [t["Key"] for t in tags["Tags"]["Items"]]+ assert "env" in tag_keys+ assert "team" not in tag_keys