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
release v1.3.50 (#718)
Nahuel Nucera09910acb627a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c6172eae..49e4252d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,13 +7,17 @@ Versioning follows [Semantic Versioning](https://semver.org/).----## [Unreleased]+## [1.3.50] — 2026-05-26-### Fixed-- **EC2 `CreateVpcEndpoint` and `CreateFlowLogs` now persist `TagSpecifications`** — tags passed at creation time were silently dropped. Tags are now stored, returned by `DescribeFlowLogs`, and cleaned up on `DeleteFlowLogs`. The `fl-` prefix is also registered in the resource-type guesser so flow-log IDs are correctly resolved by the Resource Groups Tagging API.### Added-- **IAM `UpdateAccessKey`** — enables toggling an access key between `Active` and `Inactive`, matching the two statuses the real AWS API accepts. Optional `UserName` is validated when provided.-- **IAM `GetAccessKeyLastUsed`** — returns the AWS "never used" shape (`Region`/`ServiceName` = `N/A`, no `LastUsedDate`) since MiniStack does not track per-key usage history.+- **S3 Tables (`s3tables`)** — new service emulator for the AWS S3 Tables API: table buckets, namespaces, and Iceberg-format tables. Control plane covers `CreateTableBucket`, `ListTableBuckets`, `GetTableBucket`, `DeleteTableBucket`, `CreateNamespace`, `ListNamespaces`, `GetNamespace`, `DeleteNamespace`, `CreateTable`, `ListTables`, `GetTable`, `DeleteTable`, `GetTableMetadataLocation`, `UpdateTableMetadataLocation`. Ships with an embedded **Iceberg REST catalog** at `/iceberg` so Spark jobs configured with `spark.sql.catalog.*.type=rest` and `spark.sql.catalog.*.uri=http://<ministack>/iceberg` can create, load, and commit Iceberg tables without an external catalog server. Data files land in MiniStack's S3 service; table metadata (schemas, snapshots, manifests) lives in memory.+- **Glue Spark jobs run on the official `amazon/aws-glue-libs` PySpark image** — `GlueVersion: 4.0` and `3.0` map to their canonical AWS Glue images (`glue_libs_4.0.0_image_01` / `glue_libs_3.0.0_image_01`); override the image via `GLUE_DOCKER_IMAGE`. Job containers run on MiniStack's Docker network so they reach S3, RDS, and other ministack services by container hostname.+- **IAM `UpdateAccessKey`** — enables toggling an access key between `Active` and `Inactive`, matching the two statuses the real AWS API accepts. Optional `UserName` is validated when provided. Contributed by @lahmish.+- **IAM `GetAccessKeyLastUsed`** — returns the AWS "never used" shape (`Region`/`ServiceName` = `N/A`, no `LastUsedDate`) since MiniStack does not track per-key usage history. Contributed by @lahmish.++### Fixed+- **Lambda invocation log includes user output alongside the traceback on error** — when a handler raised after printing, the response log dropped the user output and only returned the traceback. Both are now returned, newline-separated, matching real Lambda CloudWatch Logs output. Contributed by @Baptiste-Garcin.+- **EC2 `CreateVpcEndpoint` and `CreateFlowLogs` now persist `TagSpecifications`** — tags passed at creation time were silently dropped. Tags are now stored, returned by `DescribeFlowLogs`, and cleaned up on `DeleteFlowLogs`. The `fl-` prefix is also registered in the resource-type guesser so flow-log IDs are correctly resolved by the Resource Groups Tagging API. Contributed by @lahmish.---diff --git a/README.md b/README.mdindex e2c87379..24e7630b 100644--- a/README.md+++ b/README.md@@ -489,7 +489,8 @@ Unsupported resource types fail with `CREATE_FAILED` (or `ROLLBACK_COMPLETE` if| **ECS** | CreateCluster, DeleteCluster, DescribeClusters, ListClusters, UpdateCluster, UpdateClusterSettings, PutClusterCapacityProviders, RegisterTaskDefinition, DeregisterTaskDefinition, DescribeTaskDefinition, ListTaskDefinitions, ListTaskDefinitionFamilies, DeleteTaskDefinitions, CreateService, DeleteService, DescribeServices, UpdateService, ListServices, ListServicesByNamespace, RunTask, StopTask, DescribeTasks, ListTasks, ExecuteCommand, UpdateTaskProtection, GetTaskProtection, CreateCapacityProvider, UpdateCapacityProvider, DeleteCapacityProvider, DescribeCapacityProviders, TagResource, UntagResource, ListTagsForResource, ListAccountSettings, PutAccountSetting, PutAccountSettingDefault, DeleteAccountSetting, PutAttributes, DeleteAttributes, ListAttributes, DescribeServiceDeployments, ListServiceDeployments, DescribeServiceRevisions, SubmitTaskStateChange, SubmitContainerStateChange, SubmitAttachmentStateChanges, DiscoverPollEndpoint | 47 actions; `RunTask` starts real Docker containers via Docker socket; full Terraform ECS coverage || **RDS** | CreateDBInstance, DeleteDBInstance, DescribeDBInstances, ModifyDBInstance, StartDBInstance, StopDBInstance, RebootDBInstance, CreateDBInstanceReadReplica, RestoreDBInstanceFromDBSnapshot, CreateDBCluster, DeleteDBCluster, DescribeDBClusters, ModifyDBCluster, StartDBCluster, StopDBCluster, CreateDBSnapshot, DeleteDBSnapshot, DescribeDBSnapshots, CreateDBClusterSnapshot, DescribeDBClusterSnapshots, DeleteDBClusterSnapshot, CreateDBSubnetGroup, DeleteDBSubnetGroup, DescribeDBSubnetGroups, ModifyDBSubnetGroup, CreateDBParameterGroup, DeleteDBParameterGroup, DescribeDBParameterGroups, DescribeDBParameters, ModifyDBParameterGroup, CreateDBClusterParameterGroup, DescribeDBClusterParameterGroups, DeleteDBClusterParameterGroup, DescribeDBClusterParameters, ModifyDBClusterParameterGroup, CreateOptionGroup, DeleteOptionGroup, DescribeOptionGroups, DescribeOptionGroupOptions, ListTagsForResource, AddTagsToResource, RemoveTagsFromResource, DescribeDBEngineVersions, DescribeOrderableDBInstanceOptions, CreateGlobalCluster, DescribeGlobalClusters, DeleteGlobalCluster, RemoveFromGlobalCluster, ModifyGlobalCluster | `CreateDBInstance` spins up real Postgres/MySQL Docker container, returns actual `host:port` endpoint || **ElastiCache** | CreateCacheCluster, DeleteCacheCluster, DescribeCacheClusters, ModifyCacheCluster, RebootCacheCluster, CreateReplicationGroup, DeleteReplicationGroup, DescribeReplicationGroups, ModifyReplicationGroup, IncreaseReplicaCount, DecreaseReplicaCount, CreateCacheSubnetGroup, DescribeCacheSubnetGroups, ModifyCacheSubnetGroup, DeleteCacheSubnetGroup, CreateCacheParameterGroup, DescribeCacheParameterGroups, ModifyCacheParameterGroup, ResetCacheParameterGroup, DeleteCacheParameterGroup, DescribeCacheParameters, DescribeCacheEngineVersions, CreateUser, DescribeUsers, DeleteUser, ModifyUser, CreateUserGroup, DescribeUserGroups, DeleteUserGroup, ModifyUserGroup, ListTagsForResource, AddTagsToResource, RemoveTagsFromResource, CreateSnapshot, DeleteSnapshot, DescribeSnapshots, DescribeEvents | `CreateCacheCluster` spins up real Redis/Memcached Docker container |-| **Glue** | CreateDatabase, DeleteDatabase, GetDatabase, GetDatabases, UpdateDatabase, CreateTable, DeleteTable, GetTable, GetTables, UpdateTable, BatchDeleteTable, CreatePartition, DeletePartition, GetPartition, GetPartitions, BatchCreatePartition, BatchGetPartition, CreatePartitionIndex, GetPartitionIndexes, CreateConnection, DeleteConnection, GetConnection, GetConnections, CreateCrawler, DeleteCrawler, GetCrawler, GetCrawlers, UpdateCrawler, StartCrawler, StopCrawler, GetCrawlerMetrics, CreateJob, DeleteJob, GetJob, GetJobs, UpdateJob, StartJobRun, GetJobRun, GetJobRuns, BatchStopJobRun, CreateTrigger, GetTrigger, DeleteTrigger, UpdateTrigger, StartTrigger, StopTrigger, ListTriggers, BatchGetTriggers, GetTriggers, CreateWorkflow, GetWorkflow, DeleteWorkflow, UpdateWorkflow, StartWorkflowRun, CreateSecurityConfiguration, DeleteSecurityConfiguration, GetSecurityConfiguration, GetSecurityConfigurations, CreateClassifier, GetClassifier, GetClassifiers, DeleteClassifier, TagResource, UntagResource, GetTags | Python shell jobs actually execute via subprocess |+| **Glue** | CreateDatabase, DeleteDatabase, GetDatabase, GetDatabases, UpdateDatabase, CreateTable, DeleteTable, GetTable, GetTables, UpdateTable, BatchDeleteTable, CreatePartition, DeletePartition, GetPartition, GetPartitions, BatchCreatePartition, BatchGetPartition, CreatePartitionIndex, GetPartitionIndexes, CreateConnection, DeleteConnection, GetConnection, GetConnections, CreateCrawler, DeleteCrawler, GetCrawler, GetCrawlers, UpdateCrawler, StartCrawler, StopCrawler, GetCrawlerMetrics, CreateJob, DeleteJob, GetJob, GetJobs, UpdateJob, StartJobRun, GetJobRun, GetJobRuns, BatchStopJobRun, CreateTrigger, GetTrigger, DeleteTrigger, UpdateTrigger, StartTrigger, StopTrigger, ListTriggers, BatchGetTriggers, GetTriggers, CreateWorkflow, GetWorkflow, DeleteWorkflow, UpdateWorkflow, StartWorkflowRun, CreateSecurityConfiguration, DeleteSecurityConfiguration, GetSecurityConfiguration, GetSecurityConfigurations, CreateClassifier, GetClassifier, GetClassifiers, DeleteClassifier, TagResource, UntagResource, GetTags | Python shell jobs actually execute via subprocess; Spark jobs run on the official `amazon/aws-glue-libs` PySpark image (`GlueVersion: 4.0` / `3.0`) on MiniStack's Docker network |+| **S3 Tables** | CreateTableBucket, ListTableBuckets, GetTableBucket, DeleteTableBucket, CreateNamespace, ListNamespaces, GetNamespace, DeleteNamespace, CreateTable, ListTables, GetTable, DeleteTable, GetTableMetadataLocation, UpdateTableMetadataLocation | Iceberg-format tables; embedded Iceberg REST catalog at `/iceberg` so Spark jobs (`spark.sql.catalog.*.type=rest`) can create / load / commit without an external catalog; data files in S3, metadata in memory || **Athena** | StartQueryExecution, GetQueryExecution, GetQueryResults, StopQueryExecution, ListQueryExecutions, BatchGetQueryExecution, CreateWorkGroup, DeleteWorkGroup, GetWorkGroup, ListWorkGroups, UpdateWorkGroup, CreateNamedQuery, DeleteNamedQuery, GetNamedQuery, ListNamedQueries, BatchGetNamedQuery, CreateDataCatalog, GetDataCatalog, ListDataCatalogs, DeleteDataCatalog, UpdateDataCatalog, CreatePreparedStatement, GetPreparedStatement, DeletePreparedStatement, ListPreparedStatements, GetTableMetadata, ListTableMetadata, TagResource, UntagResource, ListTagsForResource | Real SQL via **DuckDB** when installed (`pip install duckdb`), otherwise returns mock results; result pagination; column type metadata || **Firehose** | CreateDeliveryStream, DeleteDeliveryStream, DescribeDeliveryStream, ListDeliveryStreams, PutRecord, PutRecordBatch, UpdateDestination, TagDeliveryStream, UntagDeliveryStream, ListTagsForDeliveryStream, StartDeliveryStreamEncryption, StopDeliveryStreamEncryption | S3 destinations write records to the local S3 emulator; all other destination types buffer in-memory; concurrency-safe `UpdateDestination` via `VersionId` || **Route53** | CreateHostedZone, GetHostedZone, DeleteHostedZone, ListHostedZones, ListHostedZonesByName, UpdateHostedZoneComment, ChangeResourceRecordSets (CREATE/UPSERT/DELETE), ListResourceRecordSets, GetChange, CreateHealthCheck, GetHealthCheck, DeleteHealthCheck, ListHealthChecks, UpdateHealthCheck, ChangeTagsForResource, ListTagsForResource | REST/XML protocol; SOA + NS records auto-created; CallerReference idempotency; alias records, weighted/failover/latency routing; marker-based pagination |@@ -670,6 +671,7 @@ end-to-end without any client config.| `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 (when `RDS_PERSIST=0`). Set to `2g` or higher for large databases |+| `GLUE_DOCKER_IMAGE` | (auto by `GlueVersion`) | Override the `amazon/aws-glue-libs` PySpark image used for Spark Glue jobs. Defaults: `glue_libs_4.0.0_image_01` (GlueVersion 4.0), `glue_libs_3.0.0_image_01` (GlueVersion 3.0) || `RDS_PERSIST` | `0` | Set `1` to use Docker named volumes for RDS containers instead of tmpfs. Storage grows dynamically with no fixed cap || `DOCKER_NETWORK` | _(unset)_ | Docker network for all container-backed services (RDS, EKS, ElastiCache, Lambda). Set to your Docker Compose network name so containers can reach each other. Replaces `LAMBDA_DOCKER_NETWORK` || `ELASTICACHE_BASE_PORT` | `16379` | Starting host port for ElastiCache containers |diff --git a/ministack/services/ec2.py b/ministack/services/ec2.pyindex 82f7dbb3..55c51510 100644--- a/ministack/services/ec2.py+++ b/ministack/services/ec2.py@@ -1516,6 +1516,7 @@ def _delete_vpc_endpoints(p):ids = _parse_member_list(p, "VpcEndpointId")for vpce_id in ids:_vpc_endpoints.pop(vpce_id, None)+ _tags.pop(vpce_id, None)return _xml(200, "DeleteVpcEndpointsResponse", "<unsuccessful/>")diff --git a/pyproject.toml b/pyproject.tomlindex 235e4d53..c0205226 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "ministack"-version = "1.3.49"+version = "1.3.50"description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"readme = "README.md"license = { file = "LICENSE" }diff --git a/tests/test_glue.py b/tests/test_glue.pyindex 52782068..9239e1e1 100644--- a/tests/test_glue.py+++ b/tests/test_glue.py@@ -939,3 +939,38 @@ def test_glue_partition_indexes(glue):# cleanupglue.delete_table(DatabaseName=db, Name=tbl)glue.delete_database(Name=db)+++# ── Spark job image selection (1.3.50) ─────────────────────++def test_glue_spark_image_for_version_maps_to_official_aws_image():+ """`GlueVersion: 4.0` and `3.0` map to the canonical `amazon/aws-glue-libs`+ images real AWS Glue uses for Spark. Override via `GLUE_DOCKER_IMAGE`."""+ from ministack.services import glue as _glue++ # Default mapping for supported Spark Glue versions+ assert _glue._glue_image_for_version("4.0") == "amazon/aws-glue-libs:glue_libs_4.0.0_image_01"+ assert _glue._glue_image_for_version("3.0") == "amazon/aws-glue-libs:glue_libs_3.0.0_image_01"++ # Unknown GlueVersion falls back to 4.0 (latest supported)+ assert _glue._glue_image_for_version("99.0") == "amazon/aws-glue-libs:glue_libs_4.0.0_image_01"+++def test_glue_spark_image_env_override(monkeypatch):+ """Setting GLUE_DOCKER_IMAGE bypasses the per-version map."""+ from ministack.services import glue as _glue++ monkeypatch.setattr(_glue, "GLUE_DOCKER_IMAGE_OVERRIDE", "my-org/custom-glue:latest")+ assert _glue._glue_image_for_version("4.0") == "my-org/custom-glue:latest"+ assert _glue._glue_image_for_version("3.0") == "my-org/custom-glue:latest"+++def test_glue_is_spark_job_classifies_by_command_name():+ """`glueetl` and `gluestreaming` are Spark; `pythonshell` is not."""+ from ministack.services import glue as _glue++ assert _glue._is_spark_job({"Command": {"Name": "glueetl"}}) is True+ assert _glue._is_spark_job({"Command": {"Name": "gluestreaming"}}) is True+ assert _glue._is_spark_job({"Command": {"Name": "pythonshell"}}) is False+ assert _glue._is_spark_job({"Command": {}}) is False+ assert _glue._is_spark_job({}) is Falsediff --git a/tests/test_lambda.py b/tests/test_lambda.pyindex b67548b8..fe8612be 100644--- a/tests/test_lambda.py+++ b/tests/test_lambda.py@@ -598,6 +598,45 @@ def test_lambda_warm_start(lam, apigw):apigw.delete_api(ApiId=api_id)lam.delete_function(FunctionName=fname)+def test_lambda_invoke_log_includes_user_output_and_traceback_on_error(lam):+ """When a handler prints then raises, the decoded LogResult tail must contain+ BOTH the user output AND the exception traceback. Regression for the+ error-path log drop where only the traceback was returned."""+ fname = f"lam-log-err-{_uuid_mod.uuid4().hex[:8]}"+ code = (+ "def handler(event, context):\n"+ " print('user-step-1')\n"+ " print('user-step-2')\n"+ " raise ValueError('boom-from-handler')\n"+ )++ lam.create_function(+ FunctionName=fname,+ Runtime="python3.12",+ Role=_LAMBDA_ROLE,+ Handler="index.handler",+ Code={"ZipFile": _make_zip(code)},+ )++ try:+ import base64 as _b64+ resp = lam.invoke(+ FunctionName=fname,+ Payload=json.dumps({}),+ LogType="Tail",+ )+ assert resp.get("FunctionError") == "Unhandled"+ log_b64 = resp.get("LogResult", "")+ assert log_b64, "LogResult should be present when LogType=Tail"+ decoded = _b64.b64decode(log_b64).decode("utf-8", errors="replace")+ assert "user-step-1" in decoded, f"user print missing from log: {decoded!r}"+ assert "user-step-2" in decoded, f"second user print missing from log: {decoded!r}"+ assert "ValueError" in decoded or "boom-from-handler" in decoded, \+ f"traceback missing from log: {decoded!r}"+ finally:+ lam.delete_function(FunctionName=fname)++def test_lambda_warm_invoke_with_stderr_logging(lam):"""Warm invoke should succeed repeatedly even when the worker writes to stderr."""fname = f"lam-warm-stderr-{_uuid_mod.uuid4().hex[:8]}"diff --git a/tests/test_s3tables.py b/tests/test_s3tables.pynew file mode 100644index 00000000..2a0b2c48--- /dev/null+++ b/tests/test_s3tables.py@@ -0,0 +1,228 @@+"""S3 Tables service tests — round-trip coverage for the 14 control-plane+operations the service ships in 1.3.50, plus a multi-tenancy isolation check.++Operations covered:+ CreateTableBucket, ListTableBuckets, GetTableBucket, DeleteTableBucket+ CreateNamespace, ListNamespaces, GetNamespace, DeleteNamespace+ CreateTable, ListTables, GetTable, DeleteTable+ GetTableMetadataLocation, UpdateTableMetadataLocation++Shapes verified against `botocore.data.s3tables.2024-12-01.service-2`.+"""++import uuid as _uuid_mod++import boto3+import pytest+from botocore.config import Config+from botocore.exceptions import ClientError+++_ENDPOINT = "http://localhost:4566"+++def _make_s3tables_client(access_key="test"):+ return boto3.client(+ "s3tables",+ endpoint_url=_ENDPOINT,+ aws_access_key_id=access_key,+ aws_secret_access_key="test",+ region_name="us-east-1",+ config=Config(retries={"mode": "standard"}),+ )++[email protected](scope="session")+def s3tables():+ return _make_s3tables_client()+++# ── Table bucket lifecycle ──────────────────────────────────++def test_s3tables_create_list_get_delete_bucket(s3tables):+ name = f"tb-bucket-{_uuid_mod.uuid4().hex[:8]}"++ created = s3tables.create_table_bucket(name=name)+ assert "arn" in created+ arn = created["arn"]+ assert name in arn+ assert arn.startswith("arn:aws:s3tables:")++ listed = s3tables.list_table_buckets()+ names = {b.get("name") for b in listed.get("tableBuckets", [])}+ assert name in names, f"created bucket {name!r} not in ListTableBuckets"++ got = s3tables.get_table_bucket(tableBucketARN=arn)+ assert got.get("name") == name+ assert got.get("arn") == arn++ s3tables.delete_table_bucket(tableBucketARN=arn)+ with pytest.raises(ClientError) as exc:+ s3tables.get_table_bucket(tableBucketARN=arn)+ assert exc.value.response["Error"]["Code"] in ("NotFoundException", "404")+++def test_s3tables_get_bucket_missing_returns_not_found(s3tables):+ fake_arn = "arn:aws:s3tables:us-east-1:000000000000:bucket/does-not-exist-xyz"+ with pytest.raises(ClientError) as exc:+ s3tables.get_table_bucket(tableBucketARN=fake_arn)+ assert exc.value.response["Error"]["Code"] in ("NotFoundException", "404")+++# ── Namespace lifecycle ─────────────────────────────────────++def test_s3tables_create_list_get_delete_namespace(s3tables):+ bucket_name = f"tb-ns-{_uuid_mod.uuid4().hex[:8]}"+ arn = s3tables.create_table_bucket(name=bucket_name)["arn"]+ try:+ ns = f"ns_{_uuid_mod.uuid4().hex[:6]}"+ created = s3tables.create_namespace(tableBucketARN=arn, namespace=[ns])+ assert created.get("namespace") == [ns] or created.get("namespace") == ns++ listed = s3tables.list_namespaces(tableBucketARN=arn)+ ns_values = []+ for entry in listed.get("namespaces", []):+ n = entry.get("namespace")+ ns_values.append(n[0] if isinstance(n, list) else n)+ assert ns in ns_values++ got = s3tables.get_namespace(tableBucketARN=arn, namespace=ns)+ got_ns = got.get("namespace")+ assert (got_ns[0] if isinstance(got_ns, list) else got_ns) == ns++ s3tables.delete_namespace(tableBucketARN=arn, namespace=ns)+ with pytest.raises(ClientError) as exc:+ s3tables.get_namespace(tableBucketARN=arn, namespace=ns)+ assert exc.value.response["Error"]["Code"] in ("NotFoundException", "404")+ finally:+ s3tables.delete_table_bucket(tableBucketARN=arn)+++# ── Table lifecycle ─────────────────────────────────────────++def test_s3tables_create_list_get_delete_table(s3tables):+ bucket_name = f"tb-tbl-{_uuid_mod.uuid4().hex[:8]}"+ arn = s3tables.create_table_bucket(name=bucket_name)["arn"]+ ns = f"ns_{_uuid_mod.uuid4().hex[:6]}"+ try:+ s3tables.create_namespace(tableBucketARN=arn, namespace=[ns])+ table = f"t_{_uuid_mod.uuid4().hex[:6]}"+ created = s3tables.create_table(+ tableBucketARN=arn, namespace=ns, name=table, format="ICEBERG",+ metadata={+ "iceberg": {+ "schema": {+ "fields": [+ {"name": "id", "type": "long", "required": True},+ {"name": "value", "type": "string"},+ ]+ }+ }+ },+ )+ assert "tableARN" in created+ table_arn = created["tableARN"]+ assert ns in table_arn and table in table_arn++ listed = s3tables.list_tables(tableBucketARN=arn)+ table_names = {t.get("name") for t in listed.get("tables", [])}+ assert table in table_names++ got = s3tables.get_table(tableBucketARN=arn, namespace=ns, name=table)+ assert got.get("name") == table+ assert got.get("format") == "ICEBERG"++ s3tables.delete_table(tableBucketARN=arn, namespace=ns, name=table)+ with pytest.raises(ClientError) as exc:+ s3tables.get_table(tableBucketARN=arn, namespace=ns, name=table)+ assert exc.value.response["Error"]["Code"] in ("NotFoundException", "404")+ finally:+ try:+ s3tables.delete_namespace(tableBucketARN=arn, namespace=ns)+ except Exception:+ pass+ s3tables.delete_table_bucket(tableBucketARN=arn)+++# ── Metadata location round-trip ────────────────────────────++def test_s3tables_get_update_table_metadata_location(s3tables):+ bucket_name = f"tb-md-{_uuid_mod.uuid4().hex[:8]}"+ arn = s3tables.create_table_bucket(name=bucket_name)["arn"]+ ns = f"ns_{_uuid_mod.uuid4().hex[:6]}"+ table = f"t_{_uuid_mod.uuid4().hex[:6]}"+ try:+ s3tables.create_namespace(tableBucketARN=arn, namespace=[ns])+ s3tables.create_table(+ tableBucketARN=arn, namespace=ns, name=table, format="ICEBERG",+ metadata={"iceberg": {"schema": {"fields": [{"name": "id", "type": "long"}]}}},+ )++ got = s3tables.get_table_metadata_location(+ tableBucketARN=arn, namespace=ns, name=table)+ assert "metadataLocation" in got+ token = got.get("versionToken", "")++ new_loc = f"s3://{bucket_name}/{ns}/{table}/metadata/v1.metadata.json"+ updated = s3tables.update_table_metadata_location(+ tableBucketARN=arn, namespace=ns, name=table,+ versionToken=token, metadataLocation=new_loc,+ )+ assert updated.get("metadataLocation") == new_loc++ got2 = s3tables.get_table_metadata_location(+ tableBucketARN=arn, namespace=ns, name=table)+ assert got2.get("metadataLocation") == new_loc+ finally:+ try:+ s3tables.delete_table(tableBucketARN=arn, namespace=ns, name=table)+ except Exception:+ pass+ try:+ s3tables.delete_namespace(tableBucketARN=arn, namespace=ns)+ except Exception:+ pass+ s3tables.delete_table_bucket(tableBucketARN=arn)+++# ── Multi-tenancy isolation ─────────────────────────────────++def test_s3tables_buckets_are_account_scoped(s3tables):+ """Same bucket name under two different account IDs must not collide.++ Multi-tenancy is enforced by the SigV4 access-key-derived account ID; we+ swap clients with 12-digit access keys and assert ListTableBuckets returns+ only the caller's buckets."""+ acct_a = "111111111111"+ acct_b = "222222222222"+ name = f"shared-{_uuid_mod.uuid4().hex[:6]}"++ client_a = _make_s3tables_client(access_key=acct_a)+ client_b = _make_s3tables_client(access_key=acct_b)++ arn_a = client_a.create_table_bucket(name=name)["arn"]+ arn_b = client_b.create_table_bucket(name=name)["arn"]+ try:+ assert acct_a in arn_a+ assert acct_b in arn_b+ assert arn_a != arn_b++ names_a = {b.get("name") for b in client_a.list_table_buckets().get("tableBuckets", [])}+ names_b = {b.get("name") for b in client_b.list_table_buckets().get("tableBuckets", [])}+ assert name in names_a+ assert name in names_b++ # Cross-account access must not see the other tenant's bucket.+ with pytest.raises(ClientError):+ client_a.get_table_bucket(tableBucketARN=arn_b)+ with pytest.raises(ClientError):+ client_b.get_table_bucket(tableBucketARN=arn_a)+ finally:+ try:+ client_a.delete_table_bucket(tableBucketARN=arn_a)+ except Exception:+ pass+ try:+ client_b.delete_table_bucket(tableBucketARN=arn_b)+ except Exception:+ pass