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
fix(sqs): queue URL hostname resolution and FIFO dedup on delete (#192)
Nahuel Nucera16fdb38cf9fa
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex fc69d357..e10f8061 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,19 @@ Versioning follows [Semantic Versioning](https://semver.org/).---+## [1.1.52] — 2026-04-08++### Fixed+- **SQS queue URL hostname resolution** — `QueueUrl` with a different hostname (e.g. `http://ministack:4566/...` in docker-compose) now resolves correctly. The queue lookup extracts the queue name from the URL and falls back to name-based resolution when the exact URL doesn't match.+- **SQS FIFO dedup cache not cleared on message delete** — Deleting a FIFO message now clears its deduplication cache entry, so the same `MessageDeduplicationId` can be reused immediately. Previously, the 5-minute dedup window blocked re-sends even after the message was consumed and deleted, breaking test reruns with fixed dedup IDs. Reported by @mspiller+- **API Gateway deadlock when Lambda calls back to MiniStack** — Lambda invocations from API Gateway (both v1 REST and v2 HTTP) now run in a thread pool (`asyncio.to_thread`), preventing deadlock when the Lambda handler makes HTTP requests back to MiniStack. Contributed by @rankinjl (#191)++### Changed+- **Tests split into per-service files** — The monolithic `test_services.py` (21K lines) has been split into ~45 focused test files (`test_s3.py`, `test_sqs.py`, `test_ec2.py`, etc.). Contributed by @jgrumboe (#189)+- **Lambda runtime env vars set before handler load** — `LAMBDA_TASK_ROOT`, `AWS_LAMBDA_FUNCTION_NAME`, `AWS_LAMBDA_FUNCTION_MEMORY_SIZE`, and `_LAMBDA_FUNCTION_ARN` are now available at import time (cold start), matching real AWS Lambda behavior. Contributed by @lubond (#190)++---+## [1.1.51] — 2026-04-08### Addeddiff --git a/README.md b/README.mdindex 861cb8cd..f44046f0 100644--- a/README.md+++ b/README.md@@ -321,6 +321,46 @@ subnet = ec2.create_subnet(| `AWS::SSM::Parameter` | Parameter name | Type, Value || `AWS::Logs::LogGroup` | Log group name | Arn || `AWS::Events::Rule` | Rule name | Arn |+| `AWS::Lambda::Permission` | Statement ID | — |+| `AWS::Lambda::Version` | Version ARN | Version |+| `AWS::Lambda::Alias` | Alias ARN | — |+| `AWS::Lambda::EventSourceMapping` | UUID | — |+| `AWS::S3::BucketPolicy` | Bucket name | — |+| `AWS::SQS::QueuePolicy` | Policy ID | — |+| `AWS::SNS::TopicPolicy` | Policy ID | — |+| `AWS::ApiGateway::RestApi` | API ID | RootResourceId |+| `AWS::ApiGateway::Resource` | Resource ID | — |+| `AWS::ApiGateway::Method` | Method ID | — |+| `AWS::ApiGateway::Deployment` | Deployment ID | — |+| `AWS::ApiGateway::Stage` | Stage name | — |+| `AWS::AppSync::GraphQLApi` | API ID | Arn, GraphQLUrl, ApiId |+| `AWS::AppSync::DataSource` | DataSource name | DataSourceArn |+| `AWS::AppSync::Resolver` | Resolver ARN | ResolverArn |+| `AWS::AppSync::GraphQLSchema` | Schema ID | — |+| `AWS::AppSync::ApiKey` | API key ID | ApiKey, Arn |+| `AWS::SecretsManager::Secret` | Secret ARN | — |+| `AWS::Cognito::UserPool` | Pool ID | Arn, ProviderName |+| `AWS::Cognito::UserPoolClient` | Client ID | — |+| `AWS::Cognito::IdentityPool` | Pool ID | — |+| `AWS::Cognito::UserPoolDomain` | Domain | — |+| `AWS::ECR::Repository` | Repo name | Arn, RepositoryUri |+| `AWS::IAM::ManagedPolicy` | Policy ARN | — |+| `AWS::KMS::Key` | Key ID | Arn, KeyId |+| `AWS::KMS::Alias` | Alias name | — |+| `AWS::EC2::VPC` | VPC ID | VpcId, DefaultSecurityGroup, DefaultNetworkAcl |+| `AWS::EC2::Subnet` | Subnet ID | SubnetId, AvailabilityZone |+| `AWS::EC2::SecurityGroup` | SG ID | GroupId, VpcId |+| `AWS::EC2::InternetGateway` | IGW ID | InternetGatewayId |+| `AWS::EC2::VPCGatewayAttachment` | Attachment ID | — |+| `AWS::EC2::RouteTable` | RTB ID | RouteTableId |+| `AWS::EC2::Route` | Route ID | — |+| `AWS::EC2::SubnetRouteTableAssociation` | Association ID | — |+| `AWS::EC2::LaunchTemplate` | LT ID | LaunchTemplateId, LaunchTemplateName, DefaultVersionNumber, LatestVersionNumber |+| `AWS::ECS::Cluster` | Cluster name | Arn, ClusterName |+| `AWS::ECS::TaskDefinition` | Task def ARN | TaskDefinitionArn |+| `AWS::ECS::Service` | Service ARN | ServiceArn, Name |+| `AWS::CloudFormation::WaitCondition` | Condition ID | — |+| `AWS::CloudFormation::WaitConditionHandle` | Handle URL | — |Unsupported resource types fail with `CREATE_FAILED` (or `ROLLBACK_COMPLETE` if rollback is enabled), so templates with unsupported types won't silently succeed.@@ -335,7 +375,7 @@ Unsupported resource types fail with `CREATE_FAILED` (or `ROLLBACK_COMPLETE` if| **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 |-| **EC2** | RunInstances, DescribeInstances, DescribeInstanceAttribute, DescribeInstanceTypes, DescribeVpcAttribute, TerminateInstances, StopInstances, StartInstances, RebootInstances, DescribeImages, CreateSecurityGroup, DeleteSecurityGroup, DescribeSecurityGroups, AuthorizeSecurityGroupIngress, RevokeSecurityGroupIngress, AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress, DescribeSecurityGroupRules, CreateKeyPair, DeleteKeyPair, DescribeKeyPairs, ImportKeyPair, CreateVpc, DeleteVpc, DescribeVpcs, ModifyVpcAttribute, CreateSubnet, DeleteSubnet, DescribeSubnets, ModifySubnetAttribute, CreateInternetGateway, DeleteInternetGateway, DescribeInternetGateways, AttachInternetGateway, DetachInternetGateway, CreateRouteTable, DeleteRouteTable, DescribeRouteTables, AssociateRouteTable, DisassociateRouteTable, ReplaceRouteTableAssociation, CreateRoute, ReplaceRoute, DeleteRoute, CreateNetworkInterface, DeleteNetworkInterface, DescribeNetworkInterfaces, AttachNetworkInterface, DetachNetworkInterface, CreateVpcEndpoint, DeleteVpcEndpoints, DescribeVpcEndpoints, ModifyVpcEndpoint, DescribePrefixLists, DescribeAvailabilityZones, AllocateAddress, ReleaseAddress, AssociateAddress, DisassociateAddress, DescribeAddresses, DescribeAddressesAttribute, CreateTags, DeleteTags, DescribeTags, CreateNatGateway, DescribeNatGateways, DeleteNatGateway, CreateNetworkAcl, DescribeNetworkAcls, DeleteNetworkAcl, CreateNetworkAclEntry, DeleteNetworkAclEntry, ReplaceNetworkAclEntry, ReplaceNetworkAclAssociation, CreateFlowLogs, DescribeFlowLogs, DeleteFlowLogs, CreateVpcPeeringConnection, AcceptVpcPeeringConnection, DescribeVpcPeeringConnections, DeleteVpcPeeringConnection, CreateDhcpOptions, AssociateDhcpOptions, DescribeDhcpOptions, DeleteDhcpOptions, CreateEgressOnlyInternetGateway, DescribeEgressOnlyInternetGateways, DeleteEgressOnlyInternetGateway, CreateManagedPrefixList, DescribeManagedPrefixLists, GetManagedPrefixListEntries, ModifyManagedPrefixList, DeleteManagedPrefixList, CreateVpnGateway, DescribeVpnGateways, AttachVpnGateway, DetachVpnGateway, DeleteVpnGateway, EnableVgwRoutePropagation, DisableVgwRoutePropagation, CreateCustomerGateway, DescribeCustomerGateways, DeleteCustomerGateway, DescribeInstanceCreditSpecifications, DescribeInstanceMaintenanceOptions, DescribeInstanceAutoRecoveryAttribute, ModifyInstanceMaintenanceOptions, DescribeInstanceTopology, DescribeSpotInstanceRequests, DescribeCapacityReservations | 127 actions; in-memory state only — no real VMs; CreateVpc provisions per-VPC default route table, network ACL, and security group; full Terraform VPC module v6.6.0 compatible; VPN/Customer gateways, managed prefix lists, VPC endpoints with modify support |+| **EC2** | RunInstances, DescribeInstances, DescribeInstanceAttribute, DescribeInstanceTypes, DescribeVpcAttribute, TerminateInstances, StopInstances, StartInstances, RebootInstances, DescribeImages, CreateSecurityGroup, DeleteSecurityGroup, DescribeSecurityGroups, AuthorizeSecurityGroupIngress, RevokeSecurityGroupIngress, AuthorizeSecurityGroupEgress, RevokeSecurityGroupEgress, DescribeSecurityGroupRules, CreateKeyPair, DeleteKeyPair, DescribeKeyPairs, ImportKeyPair, CreateVpc, DeleteVpc, DescribeVpcs, ModifyVpcAttribute, CreateSubnet, DeleteSubnet, DescribeSubnets, ModifySubnetAttribute, CreateInternetGateway, DeleteInternetGateway, DescribeInternetGateways, AttachInternetGateway, DetachInternetGateway, CreateRouteTable, DeleteRouteTable, DescribeRouteTables, AssociateRouteTable, DisassociateRouteTable, ReplaceRouteTableAssociation, CreateRoute, ReplaceRoute, DeleteRoute, CreateNetworkInterface, DeleteNetworkInterface, DescribeNetworkInterfaces, AttachNetworkInterface, DetachNetworkInterface, CreateVpcEndpoint, DeleteVpcEndpoints, DescribeVpcEndpoints, ModifyVpcEndpoint, DescribePrefixLists, DescribeAvailabilityZones, AllocateAddress, ReleaseAddress, AssociateAddress, DisassociateAddress, DescribeAddresses, DescribeAddressesAttribute, CreateTags, DeleteTags, DescribeTags, CreateNatGateway, DescribeNatGateways, DeleteNatGateway, CreateNetworkAcl, DescribeNetworkAcls, DeleteNetworkAcl, CreateNetworkAclEntry, DeleteNetworkAclEntry, ReplaceNetworkAclEntry, ReplaceNetworkAclAssociation, CreateFlowLogs, DescribeFlowLogs, DeleteFlowLogs, CreateVpcPeeringConnection, AcceptVpcPeeringConnection, DescribeVpcPeeringConnections, DeleteVpcPeeringConnection, CreateDhcpOptions, AssociateDhcpOptions, DescribeDhcpOptions, DeleteDhcpOptions, CreateEgressOnlyInternetGateway, DescribeEgressOnlyInternetGateways, DeleteEgressOnlyInternetGateway, CreateManagedPrefixList, DescribeManagedPrefixLists, GetManagedPrefixListEntries, ModifyManagedPrefixList, DeleteManagedPrefixList, CreateVpnGateway, DescribeVpnGateways, AttachVpnGateway, DetachVpnGateway, DeleteVpnGateway, EnableVgwRoutePropagation, DisableVgwRoutePropagation, CreateCustomerGateway, DescribeCustomerGateways, DeleteCustomerGateway, DescribeInstanceCreditSpecifications, DescribeInstanceMaintenanceOptions, DescribeInstanceAutoRecoveryAttribute, ModifyInstanceMaintenanceOptions, DescribeInstanceTopology, DescribeSpotInstanceRequests, DescribeCapacityReservations, CreateLaunchTemplate, CreateLaunchTemplateVersion, DescribeLaunchTemplates, DescribeLaunchTemplateVersions, ModifyLaunchTemplate, DeleteLaunchTemplate | 133 actions; in-memory state only — no real VMs; CreateVpc provisions per-VPC default route table, network ACL, and security group; full Terraform VPC module v6.6.0 compatible; VPN/Customer gateways, managed prefix lists, VPC endpoints with modify support; launch templates with versioning ($Latest/$Default) || **EBS** | CreateVolume, DeleteVolume, DescribeVolumes, DescribeVolumeStatus, AttachVolume, DetachVolume, ModifyVolume, DescribeVolumesModifications, EnableVolumeIO, ModifyVolumeAttribute, DescribeVolumeAttribute, CreateSnapshot, DeleteSnapshot, DescribeSnapshots, CopySnapshot, ModifySnapshotAttribute, DescribeSnapshotAttribute | Part of EC2 Query/XML service; attach/detach updates volume state; snapshots stored as completed immediately; Pro-only on LocalStack — free here || **EFS** | CreateFileSystem, DescribeFileSystems, DeleteFileSystem, UpdateFileSystem, CreateMountTarget, DescribeMountTargets, DeleteMountTarget, DescribeMountTargetSecurityGroups, ModifyMountTargetSecurityGroups, CreateAccessPoint, DescribeAccessPoints, DeleteAccessPoint, TagResource, UntagResource, ListTagsForResource, PutLifecycleConfiguration, DescribeLifecycleConfiguration, PutBackupPolicy, DescribeBackupPolicy, DescribeAccountPreferences, PutAccountPreferences | REST/JSON `/2015-02-01/*`; CreationToken idempotency; FileSystem deletion blocked when mount targets exist; Pro-only on LocalStack — free here || **EMR** | RunJobFlow, DescribeCluster, ListClusters, TerminateJobFlows, ModifyCluster, SetTerminationProtection, SetVisibleToAllUsers, AddJobFlowSteps, DescribeStep, ListSteps, CancelSteps, AddInstanceFleet, ListInstanceFleets, ModifyInstanceFleet, AddInstanceGroups, ListInstanceGroups, ModifyInstanceGroups, ListBootstrapActions, AddTags, RemoveTags, GetBlockPublicAccessConfiguration, PutBlockPublicAccessConfiguration | Control plane only — no real Spark/Hadoop; clusters start in WAITING (KeepAlive=true) or TERMINATED (KeepAlive=false); steps stored as COMPLETED immediately; all three instance modes (simple, InstanceGroups, InstanceFleets); TerminationProtected enforced; Pro-only on LocalStack — free here |diff --git a/ministack/services/sqs.py b/ministack/services/sqs.pyindex c97660f4..fd2638fd 100644--- a/ministack/services/sqs.py+++ b/ministack/services/sqs.py@@ -378,10 +378,18 @@ def _act_delete_message(data: dict, qurl: str) -> dict:# Only remove messages whose receipt_handle is set and matches.# Messages that have never been received (receipt_handle is None) are never# accidentally removed by an empty or unrelated receipt handle.- q["messages"] = [- m for m in q["messages"]- if not (m["receipt_handle"] is not None and m["receipt_handle"] == rh)- ]+ kept = []+ for m in q["messages"]:+ if m["receipt_handle"] is not None and m["receipt_handle"] == rh:+ # Clear the FIFO dedup cache entry so the same dedup ID can be+ # reused immediately after deletion. Real AWS keeps a strict+ # 5-minute window, but clearing on delete is more practical for+ # local development where tests re-run with fixed dedup IDs.+ if q["is_fifo"] and m.get("dedup_id"):+ q["dedup_cache"].pop(m["dedup_id"], None)+ else:+ kept.append(m)+ q["messages"] = keptreturn {}@@ -504,10 +512,14 @@ def _act_delete_message_batch(data: dict, qurl: str) -> dict:eid = e.get("Id", "")rh = e.get("ReceiptHandle", "")before = len(q["messages"])- q["messages"] = [- m for m in q["messages"]- if not (m["receipt_handle"] is not None and m["receipt_handle"] == rh)- ]+ kept = []+ for m in q["messages"]:+ if m["receipt_handle"] is not None and m["receipt_handle"] == rh:+ if q["is_fifo"] and m.get("dedup_id"):+ q["dedup_cache"].pop(m["dedup_id"], None)+ else:+ kept.append(m)+ q["messages"] = keptif len(q["messages"]) < before:ok.append({"Id": eid})else:@@ -572,6 +584,16 @@ _HANDLERS.update({def _get_q(url: str) -> dict:q = _queues.get(url)+ if q is None:+ # Fallback: extract queue name from URL and look up by name.+ # This handles cases where the hostname differs (e.g. docker-compose+ # service name "ministack" vs "localhost").+ parts = url.rstrip("/").split("/")+ if len(parts) >= 2:+ name = parts[-1]+ canonical_url = _queue_name_to_url.get(name)+ if canonical_url:+ q = _queues.get(canonical_url)if q is None:raise _Err("QueueDoesNotExist","The specified queue does not exist for this wsdl version.")@@ -1283,7 +1305,11 @@ def _delete_messages_for_esm(queue_url: str, receipt_handles: set[str]) -> None:returnwith _queues_lock:q = _get_q(queue_url)- q["messages"] = [- m for m in q["messages"]- if not (m.get("receipt_handle") is not None and m.get("receipt_handle") in receipt_handles)- ]+ kept = []+ for m in q["messages"]:+ if m.get("receipt_handle") is not None and m.get("receipt_handle") in receipt_handles:+ if q["is_fifo"] and m.get("dedup_id"):+ q["dedup_cache"].pop(m["dedup_id"], None)+ else:+ kept.append(m)+ q["messages"] = keptdiff --git a/pyproject.toml b/pyproject.tomlindex a8031b39..2223a0e5 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "ministack"-version = "1.1.51"+version = "1.1.52"description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"readme = "README.md"license = { file = "LICENSE" }