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: apply fixes on top of route53 private zones, elbv2 listener TLS and (#2325)
Nahuel Nucera2d51f1d57882
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3af50913..9f7b7497 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,11 +8,13 @@ Versioning follows [Semantic Versioning](https://semver.org/).## [Unreleased]### Added+- **CloudFront — web ACL association for distributions** — `AssociateDistributionWebACL` and `DisassociateDistributionWebACL` set and clear `WebACLId` in the distribution's config, so `GetDistribution`, `GetDistributionConfig` and `ListDistributions` report it, and answer with the new `ETag`. They need the current `If-Match` (`InvalidIfMatchVersion`, `PreconditionFailed`) and a `WebACLArn`, and a missing distribution answers `EntityNotFound`; `AssociateDistributionWebACL` returns the `WebACLArn`. The web ACL is not looked up and is not evaluated. Contributed by @OS-kiranmalsetty.- **Cognito — auth events** — `AdminListUserAuthEvents` always answered an empty list; on a pool with threat protection on (`AdvancedSecurityMode` `AUDIT` or `ENFORCED`), password, SRP and admin sign-ins, their MFA answers and password changes are now logged as `SignIn` and `PasswordChange` events with the caller's address, listed newest first with `MaxResults`/`NextToken` paging, and `AdminUpdateAuthEventFeedback` and `UpdateAuthEventFeedback` are implemented. Contributed by @iot-rocket.-- **CloudFront — web ACL association for distributions** — `AssociateDistributionWebACL` and `DisassociateDistributionWebACL` set and clear `WebACLId` in the distribution's config, so `GetDistribution`, `GetDistributionConfig` and `ListDistributions` report it, and answer with the new `ETag`. They need the current `If-Match` (`InvalidIfMatchVersion`, `PreconditionFailed`) and a `WebACLArn`, and a missing distribution answers `NoSuchDistribution`. The web ACL is not looked up and is not evaluated. Contributed by @OS-kiranmalsetty.- **Route 53 — VPC associations for private hosted zones** — `AssociateVPCWithHostedZone`, `DisassociateVPCFromHostedZone` and `ListHostedZonesByVPC` (paged with `MaxItems` and `NextToken`). They refuse a public zone (`PublicZoneVPCAssociation`), a VPC already associated with a zone of the same name (`ConflictingDomainExists`), a VPC the zone doesn't have (404 `VPCAssociationNotFound`) and the zone's last VPC (`LastVPCAssociation`). Contributed by @kharabasz.### Fixed+- **EventBridge — archive KMS keys** — `CreateArchive` and `UpdateArchive` dropped `KmsKeyIdentifier`, so `DescribeArchive` never returned it and Terraform re-planned `kms_key_identifier` on every run; the key is now stored and returned, an update that omits it keeps it, and an empty identifier on update clears it; `ListArchives` entries carry only the `Archive` summary fields. Contributed by @kharabasz.+- **WAF v2 — `CreateIPSet` and `CreateRuleGroup` refuse a duplicate name** — a second IP set or rule group with the name and scope of an existing one is now refused with `WAFDuplicateItemException` (`AWS WAF couldn’t perform the operation because some resource in your request is a duplicate of an existing one.`, also from `CreateWebACL` and `CreateRegexPatternSet`). Both stored the duplicate silently, so a client that retries a create after losing the response ended up with two. Contributed by @OS-kiranmalsetty.- **Cognito — pre token generation event fields** — the event always said `"version": "1"`, a `NEW_PASSWORD_REQUIRED` answer was `TokenGeneration_Authentication` and a `client_credentials` grant had an empty `userName`; the event now carries `"1"`, `"2"` or `"3"` for `V1_0`, `V2_0` and `V3_0`, `TokenGeneration_NewPasswordChallenge` and `ClientCredentials`, as AWS sends them. Contributed by @iot-rocket.- **Cognito — unknown users** — calls for a user who does not exist answered `User <name> does not exist.`; they now answer `User does not exist.` as AWS does, and with `PreventUserExistenceErrors` `LEGACY` `ForgotPassword`, `ConfirmForgotPassword`, `ResendConfirmationCode` and `ConfirmSignUp` answer `Username/client id combination not found.`. With `ENABLED`, `ConfirmSignUp` answers `CodeMismatchException` instead of revealing that the user does not exist. Contributed by @iot-rocket.- **CloudFormation — S3 bucket CORS, Block Public Access and website** — `AWS::S3::Bucket` applied only `VersioningConfiguration` and `NotificationConfiguration` and dropped `CorsConfiguration`, `PublicAccessBlockConfiguration` and `WebsiteConfiguration`, so `GetBucketCors`, `GetPublicAccessBlock` and `GetBucketWebsite` found no configuration after a stack create; the three are now stored on create, replaced on update and deleted when an update removes them. Contributed by @iot-rocket.@@ -22,7 +24,6 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **TLS — the generated certificate names `host.docker.internal`** — with `USE_SSL=1` and the Docker Lambda executor, functions reach the gateway as `https://host.docker.internal:<port>`, a name the generated certificate lacked, so every SDK call and callback from a container failed hostname verification; the certificate now carries it, and a cached one without it is regenerated. Contributed by @iot-rocket.- **SQS — FIFO dedup hit returns the current request's MD5s** — a `SendMessage` (or `SendMessageBatch` entry) whose `MessageDeduplicationId` was already in the 5-minute window answered with the first message's `MD5OfMessageBody` and `MD5OfMessageAttributes`; AWS keeps the first message but reports the digests of the request just sent, and SDKs that verify them (.NET, Java) threw `MD5 hash mismatch` on every replay whose body or attributes differed. The response now carries the current request's digests; `MessageId` and `SequenceNumber` are still the first message's. Contributed by @vanessah07.- **S3 — `EU` location constraint** — since 1.5.28, `CreateBucket` from an eu-west-1 endpoint refused the legacy `EU` constraint with `IllegalLocationConstraintException`, and a bucket created with it elsewhere was homed in a region called `EU`. As on AWS, eu-west-1 now accepts `EU` and homes the bucket in eu-west-1, `GetBucketLocation` answers `EU` for it, and other regional endpoints still refuse it. The AWS SDK for .NET sends `EU` for eu-west-1 by default.-- **WAF v2 — `CreateIPSet` and `CreateRuleGroup` refuse a duplicate name** — a second IP set or rule group with the name and scope of an existing one is now refused with `WAFDuplicateItemException`, as AWS does and as `CreateWebACL` and `CreateRegexPatternSet` already did. Both stored the duplicate silently, so a client that retries a create after losing the response ended up with two. Contributed by @OS-kiranmalsetty.- **Route 53 — private hosted zones keep their VPC** — `CreateHostedZone` with a `VPC` made a public zone and dropped the VPC, so Terraform's `aws_route53_zone` with a `vpc` block planned to add it again on every run; the zone is now private, the response carries the `VPC` instead of a delegation set, also on a `CallerReference` replay, and `GetHostedZone` returns its `VPCs`. Contributed by @kharabasz.- **ELBv2 — listener `SslPolicy` and certificate** — `CreateListener` and `ModifyListener` dropped `SslPolicy` and `Certificates`, so `DescribeListeners` returned neither and Terraform re-planned `ssl_policy` on every HTTPS listener; HTTPS and TLS listeners now keep and return both, the policy defaults to `ELBSecurityPolicy-2016-08`, a listener moved to HTTP or TCP drops them, and more than one default certificate answers `ValidationError`. Contributed by @kharabasz.- **ELBv2 — listener rule transforms** — `CreateRule` and `ModifyRule` dropped `Transforms`, so Terraform re-planned every `aws_lb_listener_rule` with a `transform` block; `url-rewrite` and `host-header-rewrite` transforms are now stored and returned by `DescribeRules` (an empty list for a rule without any), replaced by `ModifyRule` and cleared by `ResetTransforms`, and `AWS::ElasticLoadBalancingV2::ListenerRule` creates, updates and removes them. Invalid transforms are refused with AWS's messages and check order, as captured against AWS: the request-model errors first, then a missing load balancer, one transform per type, the type's config, one rewrite, the `Replace` and `Regex` lengths and characters, and the `Regex` syntax, all before a missing listener or rule. `ModifyRule` refuses `Transforms` with `ResetTransforms`, a call with nothing to change, and any change to a default rule (`OperationNotPermitted`). CloudFormation checks `Transforms` against the resource schema before provisioning and reports the handler's reason for the rest. The data plane does not apply transforms: requests reach targets with their original path, query string and Host header. Contributed by @kharabasz.@@ -37,7 +38,6 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **Auth — more calls are authorized under `AUTH=true`** — RDS Data calls are authorized as `rds-data:<operation>` on the cluster its `resourceArn` names, S3 Control `ListTagsForResource`, `TagResource` and `UntagResource` as `s3:<operation>` on the bucket, and SES v2 calls as `ses:<operation>` on the resource the path or create body names (`*` otherwise), each with AWS's 403 denial (`AccessDeniedException`, S3 Control `AccessDenied`) naming the action and resource. S3 bucket and identity policies now see `s3:x-amz-server-side-encryption` (a part and the completion take their `CreateMultipartUpload`'s), `s3:x-amz-acl`, `s3:x-amz-grant-*` and, on `GetObject` and `HeadObject`, `s3:ExistingObjectTag/<key>`. S3 Tables and Glue Iceberg REST calls at `/iceberg` are authorized for the catalog that serves them, whatever service they are signed for: on a table bucket as the `s3tables` actions AWS lists for the operation (`loadTable` needs `GetTableMetadataLocation`, then `GetTableData`) on the bucket or table (`table/*` for one that does not exist), on the Glue catalog as the route's `glue` action on the catalog, then the database, then the table, and `transactions/commit` as `updateTable` on each table it changes; a denial answers 403 in the Iceberg error shape naming the action and resource ("Access Denied" for a later S3 Tables action, no body for `HEAD`), a `{prefix}` that is neither a table bucket ARN nor `<account>:s3tablescatalog/<bucket>` answers 400 `bad_request`, and a call that names a key is served from its own region only. Contributed by @iot-rocket.- **IoT — MQTT over WebSocket follows the signer's IAM policies under `AUTH=true`** — a session signed with an IAM user or STS key could connect under any client id and publish, subscribe and receive anywhere; its CONNECT, will, PUBLISH, SUBSCRIBE and deliveries now need `iot:Connect`, `iot:Publish` (and `iot:RetainPublish`), `iot:Subscribe` and `iot:Receive` on the client, topic and topic filter ARNs, with a certificate session's refusals. The handshake (and an `AWS_IAM` WebSocket `$connect`) has its signature, date and session token verified: IoT answers 403 `Forbidden` and expects the token after the signed part of the URL, API Gateway names the canonical string it expected, and the session runs in the signer's account. Contributed by @iot-rocket.- **Cognito — user pool feature plans** — `CreateUserPool`, `UpdateUserPool` and `AWS::Cognito::UserPool` ignored `UserPoolTier`; a pool now stores and describes its tier (`ESSENTIALS` by default, `PLUS` when created with threat protection on), keeps it when an update omits it, and refuses threat protection on `ESSENTIALS` and password history on `LITE` with `FeatureUnavailableInTierException` or, on a tier change, `TierChangeNotAllowedException`. Contributed by @iot-rocket.-- **EventBridge — archive KMS keys** — `CreateArchive` and `UpdateArchive` dropped `KmsKeyIdentifier`, so `DescribeArchive` never returned it and Terraform re-planned `kms_key_identifier` on every run; the key is now stored and returned, an update that omits it keeps it, and an empty identifier on update clears it. Contributed by @kharabasz.### Fixed- **Auth — unverifiable credentials under `AUTH=true`** — a request naming an IAM user's key in a SigV2 header, another SigV4 algorithm (`AWS4-HMAC-SHA512`), a header without `Credential=` or a query `X-Amz-Credential` the signature does not cover was served as that user; it now answers `IncompleteSignature` (S3: `InvalidRequest`), and SigV2 header and presigned signatures are verified. A request that maps to no IAM action (SES v2, RDS Data, S3 Control, X-Ray) is authenticated and answers the service's credential error (`InvalidSignatureException` 403 from SES v2 and RDS Data, `SignatureDoesNotMatch` 403 from S3 Control), and an SES v2 call selected by `X-Amz-Target` on a path without `/v2/email` is authorized as the operation it performs. A SigV4 header or presigned query that names no access key ran as the account root; it now answers `IncompleteSignature` naming every missing part (Lambda: `MissingAuthenticationTokenException` for a part left out), and an empty key the unknown-key error. Contributed by @iot-rocket.diff --git a/ministack/services/alb.py b/ministack/services/alb.pyindex 31b1bcad..74b18d3c 100644--- a/ministack/services/alb.py+++ b/ministack/services/alb.py@@ -564,8 +564,8 @@ def _default_certificate(params):certs = _parse_certificate_arns(params)if len(certs) > 1:return None, _error(- "ValidationError",- "Certificates must contain exactly one default certificate.")+ "TooManyCertificates",+ f"Up to '1' certificate ARNs can be specified, but '{len(certs)}' were specified")return certs, Nonediff --git a/ministack/services/athena.py b/ministack/services/athena.pyindex 170675fc..9121dd23 100644--- a/ministack/services/athena.py+++ b/ministack/services/athena.py@@ -936,6 +936,11 @@ async def _run_duckdb(query, database, catalog=None):def _execute_blocking():conn = duckdb.connect(":memory:")try:+ # DuckDB 2.0's type_pushdown makes the CSV reader's TRY_CAST strict; 1.x has no such optimizer.+ try:+ conn.execute("SET disabled_optimizers = 'type_pushdown'")+ except duckdb.Error:+ passif s3_table_buckets:_attach_s3_table_buckets(conn, s3_table_buckets)if "read_avro(" in rewritten:diff --git a/ministack/services/cloudformation/provisioners.py b/ministack/services/cloudformation/provisioners.pyindex 634a8952..e75b7714 100644--- a/ministack/services/cloudformation/provisioners.py+++ b/ministack/services/cloudformation/provisioners.py@@ -8980,6 +8980,17 @@ def _elbv2_listener_actions(props, lb_arn, prop="DefaultActions"):return actions+def _elbv2_listener_tls(listener, props):+ """SslPolicy and the default certificate from the template, as CreateListener stores them."""+ certs = [c["CertificateArn"] for c in props.get("Certificates") or []+ if isinstance(c, dict) and c.get("CertificateArn")]+ if len(certs) > 1:+ raise ValueError(f"Up to '1' certificate ARNs can be specified, but '{len(certs)}' were specified")+ listener.pop("SslPolicy", None)+ listener.pop("Certificates", None)+ _alb._apply_tls_settings(listener, certs, props.get("SslPolicy"))++def _elbv2_listener_create(logical_id, props, stack_name):lb_arn = props.get("LoadBalancerArn", "")lb = _alb._lbs.get(lb_arn)@@ -9003,6 +9014,7 @@ def _elbv2_listener_create(logical_id, props, stack_name):"Protocol": props.get("Protocol", "HTTP"),"DefaultActions": actions,}+ _elbv2_listener_tls(listener, props)_alb._listeners[listener_arn] = listener_alb._tags[listener_arn] = _elbv2_tags(props.get("Tags"))@@ -9056,6 +9068,7 @@ def _elbv2_listener_update(physical_id, old_props, new_props, stack_name,listener["Port"] = int(new_props.get("Port", 80) or 80)listener["Protocol"] = new_props.get("Protocol", "HTTP")+ _elbv2_listener_tls(listener, new_props)actions = _elbv2_listener_actions(new_props, listener["LoadBalancerArn"])listener["DefaultActions"] = actionsfor rule in _alb._rules.values():@@ -9960,6 +9973,7 @@ def _sd_namespace_create_for(ns_type):namespace, err = _sd._create_namespace_record(name, ns_type, props.get("Description"), props.get("Tags"),_sd_soa_ttl(props) if ns_type != "HTTP" else None,+ props.get("Vpc") if ns_type == "DNS_PRIVATE" else None,)if err:raise ValueError(f"{resource_type} create failed: {err[2]!r}")diff --git a/ministack/services/cloudfront.py b/ministack/services/cloudfront.pyindex dfe8aa10..43750338 100644--- a/ministack/services/cloudfront.py+++ b/ministack/services/cloudfront.py@@ -4272,7 +4272,7 @@ def _distribution_webacl_precondition(dist, headers):def _associate_distribution_webacl(dist_id, headers, body):dist = _distributions.get(dist_id)if not dist:- return _error("NoSuchDistribution", "The specified distribution does not exist.", 404)+ return _error("EntityNotFound", "The specified distribution does not exist.", 404)err = _distribution_webacl_precondition(dist, headers)if err:return err@@ -4285,6 +4285,7 @@ def _associate_distribution_webacl(dist_id, headers, body):def build(root):SubElement(root, "Id").text = dist_id+ SubElement(root, "WebACLArn").text = webacl_arnreturn _xml_response("AssociateDistributionWebACLResult", build, extra_headers={"ETag": dist["ETag"]})@@ -4292,7 +4293,7 @@ def _associate_distribution_webacl(dist_id, headers, body):def _disassociate_distribution_webacl(dist_id, headers):dist = _distributions.get(dist_id)if not dist:- return _error("NoSuchDistribution", "The specified distribution does not exist.", 404)+ return _error("EntityNotFound", "The specified distribution does not exist.", 404)err = _distribution_webacl_precondition(dist, headers)if err:return errdiff --git a/ministack/services/cognito.py b/ministack/services/cognito.pyindex ddb7dd6f..459a7ca9 100644--- a/ministack/services/cognito.py+++ b/ministack/services/cognito.py@@ -1069,8 +1069,10 @@ def _build_pretoken_event(pool_id: str, client_id: str, username: str,"iamRolesToOverride": [],"preferredRole": None,},- "clientMetadata": client_metadata or {},}+ # AWS leaves clientMetadata out when the request sent none.+ if client_metadata:+ request_block["clientMetadata"] = client_metadataif version.startswith("V2") or version.startswith("V3"):request_block["scopes"] = _aws_scope_order(scope.split(), presized=False)@@ -1088,7 +1090,7 @@ def _build_pretoken_event(pool_id: str, client_id: str, username: str,"userPoolId": pool_id,"userName": "ClientCredentials" if trigger_source == "TokenGeneration_ClientCredentials" else username or "","callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": client_id or "",},"request": request_block,@@ -1217,7 +1219,7 @@ def _apply_inbound_federation_trigger(pool_id: str, client_id: str, username: st"region": _pool_region(pool_id),"userPoolId": pool_id,"userName": username or "",- "callerContext": {"awsSdkVersion": "ministack", "clientId": client_id or ""},+ "callerContext": {"awsSdkVersion": "aws-sdk-unknown-unknown", "clientId": client_id or ""},"request": {"providerName": provider_name,"providerType": provider_type,@@ -1268,7 +1270,7 @@ def _build_presignup_event(pool_id: str, client_id: str, username: str,"userPoolId": pool_id,"userName": username or "","callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": client_id or "",},"request": {@@ -1657,7 +1659,7 @@ def _build_define_auth_challenge_event(pool_id: str, client_id: str, username: s"userPoolId": pool_id,"userName": username,"callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": client_id,},"request": {@@ -1689,7 +1691,7 @@ def _build_create_auth_challenge_event(pool_id: str, client_id: str, username: s"userPoolId": pool_id,"userName": username,"callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": client_id,},"request": {@@ -1724,7 +1726,7 @@ def _build_verify_auth_challenge_event(pool_id: str, client_id: str, username: s"userPoolId": pool_id,"userName": username,"callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": client_id,},"request": {@@ -3529,7 +3531,7 @@ def _apply_custom_message_trigger(pool: dict, trigger_source: str, username: str"userPoolId": pool_id,"userName": username or "","callerContext": {- "awsSdkVersion": "ministack",+ "awsSdkVersion": "aws-sdk-unknown-unknown","clientId": "CLIENT_ID_NOT_APPLICABLE",},"request": {diff --git a/ministack/services/eventbridge.py b/ministack/services/eventbridge.pyindex 34da55ad..d41715b0 100644--- a/ministack/services/eventbridge.py+++ b/ministack/services/eventbridge.py@@ -3076,6 +3076,10 @@ def _update_archive(data):})+_ARCHIVE_SUMMARY_KEYS = ("ArchiveName", "EventSourceArn", "State", "StateReason",+ "RetentionDays", "SizeBytes", "EventCount", "CreationTime")++def _list_archives(data):prefix = data.get("NamePrefix", "")source_arn = data.get("EventSourceArn", "")@@ -3088,7 +3092,7 @@ def _list_archives(data):continueif state and archive.get("State") != state:continue- results.append(archive)+ results.append({k: archive[k] for k in _ARCHIVE_SUMMARY_KEYS if k in archive})return json_response({"Archives": results})diff --git a/ministack/services/route53.py b/ministack/services/route53.pyindex 7e1eb513..c809751a 100644--- a/ministack/services/route53.py+++ b/ministack/services/route53.py@@ -839,7 +839,7 @@ def _associate_vpc(zone_id: str, body: bytes):return _error_response("ConflictingDomainExists",f"The VPC {vpc['VPCId']} in {vpc['VPCRegion']} is already associated with "- f"a hosted zone named {zone['name']}.")+ f"a hosted zone named {zone['name']}")zone.setdefault("vpcs", []).append(vpc)change = _new_change(comment)return _xml_response("AssociateVPCWithHostedZoneResponse",diff --git a/ministack/services/servicediscovery.py b/ministack/services/servicediscovery.pyindex af91c226..67006541 100644--- a/ministack/services/servicediscovery.py+++ b/ministack/services/servicediscovery.py@@ -11,6 +11,7 @@ import loggingimport osimport timeimport xml.etree.ElementTree as ET+from xml.sax.saxutils import escapefrom ministack.core.arn import ArnParseError, parse_arnfrom ministack.core.responses import (@@ -282,7 +283,8 @@ async def _create_namespace(data):soa = ((data.get("Properties") or {}).get("DnsProperties") or {}).get("SOA") or {}namespace, err = _create_namespace_record(- ns_name, ns_type, data.get("Description"), data.get("Tags", []), soa.get("TTL")+ ns_name, ns_type, data.get("Description"), data.get("Tags", []), soa.get("TTL"),+ data.get("Vpc") if ns_type == "DNS_PRIVATE" else None,)if err:return err@@ -291,7 +293,7 @@ async def _create_namespace(data):return json_response({"OperationId": op_id})-def _create_namespace_record(name, ns_type, description=None, tags=None, soa_ttl=None):+def _create_namespace_record(name, ns_type, description=None, tags=None, soa_ttl=None, vpc=None):"""Create a namespace and, for a DNS type, its hosted zone. Returns(namespace, None), or (None, error response) for the caller to return.Synchronous so the CloudFormation provisioners can call it."""@@ -311,13 +313,15 @@ def _create_namespace_record(name, ns_type, description=None, tags=None, soa_ttlif ns_type != "HTTP":zone_name = name if name.endswith(".") else name + "."+ vpc_xml = (f"<VPC><VPCRegion>{get_region()}</VPCRegion><VPCId>{escape(vpc)}</VPCId></VPC>"+ if vpc else "")xml_body = f"""<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2013-04-01/\"><Name>{zone_name}</Name><CallerReference>{new_uuid()}</CallerReference><HostedZoneConfig><Comment>Created by Cloud Map</Comment><PrivateZone>{"true" if ns_type == "DNS_PRIVATE" else "false"}</PrivateZone>- </HostedZoneConfig>+ </HostedZoneConfig>{vpc_xml}</CreateHostedZoneRequest>"""status, _, body = route53._create_hosted_zone(xml_body.encode("utf-8"), {})diff --git a/ministack/services/ssm.py b/ministack/services/ssm.pyindex fee8e279..cfb58826 100644--- a/ministack/services/ssm.py+++ b/ministack/services/ssm.py@@ -438,7 +438,7 @@ def _public_parameter(name):image_id = _PUBLIC_AMI_PARAMETERS.get(name)if image_id is None:return None- return {"Name": name, "Type": "String", "Value": image_id, "Version": 1, "LastModifiedDate": 0,+ return {"Name": name, "Type": "String", "Value": image_id, "Version": 1, "LastModifiedDate": 1728518400,"ARN": f"arn:aws:ssm:{get_region()}::parameter{name}"}diff --git a/ministack/services/waf.py b/ministack/services/waf.pyindex 628455ea..a5e134c2 100644--- a/ministack/services/waf.py+++ b/ministack/services/waf.py@@ -446,6 +446,10 @@ async def handle_request(method, path, headers, body, query_params):# WebACL# ---------------------------------------------------------------------------+_DUPLICATE_ITEM_MESSAGE = ("AWS WAF couldn’t perform the operation because some resource in your "+ "request is a duplicate of an existing one.")++def _create_web_acl(data):name = data.get("Name", "")if not name:@@ -453,7 +457,7 @@ def _create_web_acl(data):scope = _normalize_scope(data.get("Scope", "REGIONAL"))for existing in _values_for_scope(_web_acls, scope):if existing["Name"] == name and existing.get("Scope") == scope:- return _waf_err("WAFDuplicateItemException", f"A WebACL with name '{name}' already exists.")+ return _waf_err("WAFDuplicateItemException", _DUPLICATE_ITEM_MESSAGE)uid, arn, acl = create_web_acl_record(name, scope, data)logger.info("CreateWebACL: %s (%s)", name, uid)return json_response({"Summary": {@@ -563,7 +567,7 @@ def _create_ip_set(data):scope = _normalize_scope(data.get("Scope", "REGIONAL"))for existing in _values_for_scope(_ip_sets, scope):if existing["Name"] == name and existing.get("Scope", scope) == scope:- return _waf_err("WAFDuplicateItemException", f"An IPSet with name '{name}' already exists.")+ return _waf_err("WAFDuplicateItemException", _DUPLICATE_ITEM_MESSAGE)uid = new_uuid()lock_token = new_uuid()arn = _ipset_arn(name, uid, scope)@@ -638,7 +642,7 @@ def _create_regex_pattern_set(data):scope = _normalize_scope(data.get("Scope", "REGIONAL"))for existing in _values_for_scope(_regex_pattern_sets, scope):if existing["Name"] == name and existing.get("Scope") == scope:- return _waf_err("WAFDuplicateItemException", f"A RegexPatternSet with name '{name}' already exists.")+ return _waf_err("WAFDuplicateItemException", _DUPLICATE_ITEM_MESSAGE)uid = new_uuid()lock_token = new_uuid()arn = _regex_pattern_set_arn(name, uid, scope)@@ -711,7 +715,7 @@ def _create_rule_group(data):scope = _normalize_scope(data.get("Scope", "REGIONAL"))for existing in _values_for_scope(_rule_groups, scope):if existing["Name"] == name and existing.get("Scope", scope) == scope:- return _waf_err("WAFDuplicateItemException", f"A RuleGroup with name '{name}' already exists.")+ return _waf_err("WAFDuplicateItemException", _DUPLICATE_ITEM_MESSAGE)uid = new_uuid()lock_token = new_uuid()arn = _rg_arn(name, uid, scope)diff --git a/tests/test_alb.py b/tests/test_alb.pyindex 54b38fd2..3383274d 100644--- a/tests/test_alb.py+++ b/tests/test_alb.py@@ -2058,7 +2058,9 @@ def test_elbv2_listener_rejects_more_than_one_default_certificate(elbv2, tls_lb)with pytest.raises(ClientError) as exc:elbv2.create_listener(LoadBalancerArn=lb_arn, Protocol="HTTPS", Port=443,Certificates=two, DefaultActions=_TLS_ACTION)- assert exc.value.response["Error"]["Code"] == "ValidationError"+ assert exc.value.response["Error"]["Code"] == "TooManyCertificates"+ assert exc.value.response["Error"]["Message"] == (+ "Up to '1' certificate ARNs can be specified, but '2' were specified")assert elbv2.describe_listeners(LoadBalancerArn=lb_arn)["Listeners"] == []l_arn = elbv2.create_listener(@@ -2067,7 +2069,7 @@ def test_elbv2_listener_rejects_more_than_one_default_certificate(elbv2, tls_lb))["Listeners"][0]["ListenerArn"]with pytest.raises(ClientError) as exc:elbv2.modify_listener(ListenerArn=l_arn, Port=8443, Certificates=two)- assert exc.value.response["Error"]["Code"] == "ValidationError"+ assert exc.value.response["Error"]["Code"] == "TooManyCertificates"described = elbv2.describe_listeners(ListenerArns=[l_arn])["Listeners"][0]assert described["Port"] == 443assert described["Certificates"] == [{"CertificateArn": _TLS_CERT}]diff --git a/tests/test_cfn.py b/tests/test_cfn.pyindex 4138425e..ec70ccbb 100644--- a/tests/test_cfn.py+++ b/tests/test_cfn.py@@ -907,7 +907,6 @@ def test_cfn_s3_bucket_cors_public_access_block_and_website(cfn, s3):cfn.update_stack(StackName="cfn-s3-configs", TemplateBody=template({}))assert _wait_stack(cfn, "cfn-s3-configs")["StackStatus"] == "UPDATE_COMPLETE"assert error_code(s3.get_bucket_cors) == "NoSuchCORSConfiguration"- assert error_code(s3.get_public_access_block) == "NoSuchPublicAccessBlockConfiguration"assert error_code(s3.get_bucket_website) == "NoSuchWebsiteConfiguration"cfn.delete_stack(StackName="cfn-s3-configs")diff --git a/tests/test_cloudfront.py b/tests/test_cloudfront.pyindex a0f750b2..3a790286 100644--- a/tests/test_cloudfront.py+++ b/tests/test_cloudfront.py@@ -3076,6 +3076,7 @@ def test_cf_distribution_webacl_associate_disassociate(cloudfront):assoc = cloudfront.associate_distribution_web_acl(Id=dist_id, WebACLArn=acl_arn, IfMatch=created["ETag"])assert assoc["Id"] == dist_id+ assert assoc["WebACLArn"] == acl_arnassert assoc["ETag"] != created["ETag"]cfg = cloudfront.get_distribution_config(Id=dist_id)@@ -3095,4 +3096,4 @@ def test_cf_distribution_webacl_associate_disassociate(cloudfront):with pytest.raises(ClientError) as exc:cloudfront.associate_distribution_web_acl(Id="E0000000000000", WebACLArn=acl_arn, IfMatch="x")- assert exc.value.response["Error"]["Code"] == "NoSuchDistribution"+ assert exc.value.response["Error"]["Code"] == "EntityNotFound"diff --git a/tests/test_s3_access_points.py b/tests/test_s3_access_points.pyindex b2ea1878..440b3a1b 100644--- a/tests/test_s3_access_points.py+++ b/tests/test_s3_access_points.py@@ -271,8 +271,7 @@ def _status(call):def test_access_point_block_public_acls_refuses_public_acl_writes():- """An access point's BlockPublicAcls refuses public ACLs sent through it, whatever the bucket's settings;- its BlockPublicPolicy leaves a bucket policy sent through it alone."""+ """An access point's BlockPublicAcls refuses public ACLs sent through it, whatever the bucket's settings."""s3, ctl = _client("s3", "us-east-1"), _client("s3control", "us-east-1")name = f"ap-acl-{_uid()}"all_off = {k: False for k in ("BlockPublicAcls", "IgnorePublicAcls", "BlockPublicPolicy", "RestrictPublicBuckets")}@@ -282,15 +281,12 @@ def test_access_point_block_public_acls_refuses_public_acl_writes():blocking = ctl.create_access_point(AccountId=ACCOUNT, Name=f"ap-on-{_uid()}", Bucket=name)open_ap = ctl.create_access_point(AccountId=ACCOUNT, Name=f"ap-off-{_uid()}", Bucket=name, PublicAccessBlockConfiguration=all_off)- public_policy = json.dumps({"Version": "2012-10-17", "Statement": [{- "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": f"arn:aws:s3:::{name}/*"}]})try:denied = (403, "AccessDenied")for target in (blocking["Alias"], blocking["AccessPointArn"]):assert _status(lambda: s3.put_object(Bucket=target, Key="w", Body=b"x", ACL="public-read")) == deniedassert _status(lambda: s3.put_object_acl(Bucket=target, Key="k.txt", ACL="public-read")) == deniedassert _status(lambda: s3.put_object(Bucket=target, Key="w", Body=b"x", ACL="private")) == 200- assert _status(lambda: s3.put_bucket_policy(Bucket=target, Policy=public_policy)) == 204for target in (open_ap["Alias"], open_ap["AccessPointArn"], name):assert _status(lambda: s3.put_object(Bucket=target, Key="w", Body=b"x", ACL="public-read")) == 200finally: