Under IAM enforcement a refused SNS request answered `AccessDenied`, the
code Floci gives every Query service. SNS models no such error. Every
one of its 42 operations lists `AuthorizationError`, HTTP 403, a sender
fault ("Indicates that the user has been denied access to the requested
resource"), which SDKs raise as `AuthorizationErrorException`; the SNS
Developer Guide's own sample reads that code as an IAM permission
failure ("Authorization error listing topics - check IAM permissions").
An SDK caller catching `AuthorizationErrorException` therefore missed
Floci's refusal, which surfaced as a bare `SnsException`.
A Query denial now takes its code from the service that serves the
request: `AuthorizationError` for SNS, whichever action is denied (a
role it is passed as much as its own action), and `AccessDenied` for
every other Query service, as before. The status, the `Sender` type and
the message are unchanged.
Not in this change: Floci's SNS JSON surface (`SNS_20100331.*`
targets), which botocore does not model, keeps `AccessDeniedException`.
Under IAM enforcement, SES published event-destination events and identity notifications to
whatever SNS topic it was configured with, through an internal call nothing checked, so a caller
refused sns:Publish could still put messages on a topic by pointing a configuration set at it. On
AWS, SES publishes as ses.amazonaws.com and the topic's policy decides: it has to allow SES, under
an aws:SourceArn naming the configuration set or identity whose configuration names the topic.
- ServiceCallAuthorizer decides a call one AWS service makes to another's resource on its own
behalf from the target's resource policy alone, read through the same providers the request
filter uses and picked by the target ARN's service. A target with no policy refuses, and with
enforcement off every call is allowed. ResourcePolicyProviders collects what the providers
supply, for the filter and the authorizer alike.
- IamConditionContextResolver.serviceCallContext builds that call's request context from the IAM
User Guide's global keys: aws:PrincipalIsAWSService, aws:PrincipalServiceName and
aws:PrincipalServiceNamesList, aws:SourceArn and aws:SourceAccount, aws:ResourceAccount and
aws:RequestedRegion, and none of the keys that describe an IAM principal. A publish to an SNS
topic from SES also carries aws:SourceOwner, which the SNS Developer Guide lists SES among the
services setting, and which the default topic policy checks.
- SnsResourcePolicyProvider supplies a topic's policy and the account in its ARN, also when the
topic does not exist. A topic with no Policy attribute gets the default a new topic has, for the
topic's own account. Topic policies so also take part in a JSON-protocol request that names a
topic, as any resource policy does.
- SesEventPublisher asks before publishing to SNS: for an event destination with the configuration
set's ARN, for an identity notification with the ARN of the identity that names the topic, the
sender's own or its domain's, both with the sending account. A refused event is dropped. A
notification SES cannot publish, because the topic is gone from its own account or its policy
refuses SES, also takes the topic out of the identity's bounce and complaint settings and turns
email feedback forwarding back on, as the SES Developer Guide describes; a delivery setting
stays. The identity's notification settings are written under the identity lock, so that
write and an API call changing them cannot lose each other.
- CreateReceiptRule and UpdateReceiptRule ask the same question of an action's TopicArn, with the
rule's ARN as aws:SourceArn, and answer InvalidSnsTopic when the topic's policy does not let SES
publish, which the SES API Reference lists as "could not publish to the topic, possibly due to
permissions issues". The rules still route no mail.
- A resource policy statement that names the caller only through its account, by its id, root ARN
or S3 canonical user ID, delegates to that account (IAM User Guide, "AWS account principals"):
across accounts it is still the owner's half of the grant, but within the account it no longer
grants on its own, and the caller's identity policies have to allow the request. Floci let such
a statement grant on its own, for bucket and function policies already, so a topic policy naming
its own account would have let every user of the account publish.
- A Deny's NotPrincipal follows the IAM User Guide ("AWS JSON policy elements: NotPrincipal"): it
spares an IAM caller only when it names the caller's account as well as the caller, since without
the account AWS "might deny access to the entire account", and never spares one with a permissions
boundary attached, which it "will always deny". CallerArns says whether a boundary is attached to
the user or to the role a session assumed. An Allow's NotPrincipal still grants everyone it does
not name, as Access Analyzer warns it can.
VerifySMSSandboxPhoneNumber's VerificationException declares two required
members, Message and Status, and Floci sent only the message, so status() came
back null in the SDKs.
AWS documents no values for Status, and no recorded response carries one, so
Floci picks one from what the API does publish: the number's own verification
status, which a wrong password leaves Pending. Pending and Verified are the only
statuses SNS defines for a sandbox number, and the developer guide reads a
number left Pending as an unsuccessful verification. docs/services/sns.md says
the value is Floci's choice.
JSON errors already write an exception's extra members into the body. Query
errors did not: SnsQueryHandler built them from the code, message and status
alone. AwsQueryResponse gains an error overload that writes the extra members
into <Error> after <Message>, where the SDKs read them, and every SNS catch site
now passes the exception through it.
Refs #5570
SNS's Query routing set listed ten names that neither SNS handler dispatched, so a
request for any of them was answered UnsupportedOperation. All ten are real SNS
operations, and both the Query and JSON protocols now serve them.
AddPermission and RemovePermission edit the topic's Policy attribute the way AWS
does, going by LocalStack's recordings of the same calls against a live account:
the label becomes the statement's Sid, each account its root principal, and a single
account or action is written as a string. A duplicate label, an action outside SNS
and a missing topic get AWS's errors. A label the policy does not hold leaves it
unchanged, since no source shows what AWS answers there. Floci stores topic policies
but does not evaluate them under enforcement, so the grant only shows in
GetTopicAttributes.
The default topic policy now matches what AWS returns for a new topic: Version
2008-10-17 with an AWS:SourceOwner condition, where Floci has had 2012-10-17 and
AWS:SourceAccount since the first commit. AddPermission builds on it.
GetSMSSandboxAccountStatus reports the account outside the sandbox, because Floci
delivers SMS to any number. The sandbox numbers still work per account and region,
without the limits AWS lifts outside the sandbox. CreateSMSSandboxPhoneNumber texts a
six-digit code through the same path as Publish, so a test reads it from /_aws/sns,
and VerifySMSSandboxPhoneNumber checks it.
No number is ever opted out. AWS opts a number out when its owner replies STOP, and
nothing reaches Floci that way, so CheckIfPhoneNumberIsOptedOut answers false,
ListPhoneNumbersOptedOut is empty, and OptInPhoneNumber checks only the E.164 format,
with AWS's error for a malformed number.
AddPermission takes only twelve-digit account IDs, so a malformed one cannot end up as
a principal in the stored policy.
Each of these edits reads a record, changes it and writes it back. AddPermission,
RemovePermission and SetTopicAttributes, which writes the same Policy attribute, are
synchronized, as are the sandbox's create, verify and delete, so overlapping requests
cannot lose a grant or bring back a deleted number. A number whose verification text
cannot be recorded is put back as it was. The tests park the first of two edits inside
that window and check the second waits. testing.ThreadStates holds the wait they use,
which several other test classes still carry their own copies of.
With SNS dispatching AddPermission and RemovePermission, the last two rows of the
Query routing gap file, SQS's two names reaching SNS without a Version, are gone,
leaving 171. The SNS row in docs/services/index.md now counts 39 operations, up
from a stale 17.
Refs #5549
* feat(sns): sign deliveries with a served RSA certificate like AWS
Replace the EXAMPLE Signature and SigningCertURL placeholders with real
signatures over the documented canonical string. Notifications and
subscription confirmations delivered to HTTP/HTTPS endpoints, Lambda
records and non-raw SQS envelopes are signed with SHA1withRSA, or
SHA256withRSA when the topic sets SignatureVersion to 2.
The RSA 2048 key and its self-signed certificate are kept in SNS storage
and the certificate is served at
/_aws/sns/SimpleNotificationService-<fingerprint>.pem, so a new key always
gets a new URL. The SQS envelope now carries UnsubscribeURL and the Lambda
record a real UnsubscribeUrl, as on AWS.
* fix(sns): drop a delivery when signing fails and regenerate the key on reset
A signing failure in the Lambda, SQS and HTTP builders was caught with the JSON
fallback and delivered an empty placeholder as if it had succeeded. Only a JSON
serialization error falls back now; a signing failure fails that delivery.
SnsMessageSigner is now Resettable: a reset drops the cached key instead of
writing it back to the cleared store, so the next delivery generates a new one.
* style(sns): sort SnsService imports
* refactor(sns): build the SQS envelope with the builder Firehose uses
buildSnsSqsEnvelope duplicated buildSnsEnvelope apart from the signature and UnsubscribeURL. buildSnsEnvelope now takes the subscription ARN and signature version and adds both only when a subscription is given, so SQS and Firehose share one builder again.
Subscribe checked only that an http/https endpoint carried a matching scheme, then Floci posted the SubscriptionConfirmation and every notification to it. An unauthenticated Subscribe therefore turned the emulator into a blind request forwarder against addresses only it can reach.
Resolve and screen the endpoint at Subscribe, which is where a name can be judged. At delivery, screen only an endpoint that names an address outright, which reaches a subscription stored before Subscribe began refusing them and costs no lookup. Deliberately no second resolution there: HttpClient resolves the name again when it connects and cannot be given the result of a check, so a lookup could never decide where the request goes.
Loopback and private ranges stay allowed, since delivering to a neighbouring container is the normal case, and a host that does not resolve yet is accepted as it is on AWS.
The SQS arm of the fan-out passed a literal 0 as the per-message
delaySeconds. On a standard queue a non-null value is an explicit
per-message delay and overrides the queue attribute, so a queue created
with DelaySeconds never withheld a published message, while a direct
SendMessage to the same queue did. SNS carries no per-message delay, so
the argument is now null and the queue default applies, as on AWS. FIFO
queues were unaffected: that branch ignores the argument.
Deliver published messages to Firehose delivery stream subscriptions (sns:Publish -> firehose:PutRecord). Support RawMessageDelivery attribute to switch between raw payload and JSON envelope. Tolerates subscriber delivery errors without failing publisher.
Closes#4068
* feat(sns): add the MaximumMessageSize topic attribute for 1 MiB payloads
AWS raised the SNS payload ceiling from 256 KiB to 1 MiB behind a new
per-topic MaximumMessageSize attribute. The default stays 262144, so an
unconfigured topic is unchanged.
CreateTopic and SetTopicAttributes validate the 1024-1048576 range, Publish
and PublishBatch size against the topic's value, and a topic above 262144 is
held to its subscription constraints: sqs, firehose or lambda only, and at
most 100 subscriptions. AWS::SNS::Topic forwards the property too.
Two things the same code path had wrong, both checked against the live API:
Subject was counted towards the publish limit when AWS does not count it, and
PublishBatch returned the SQS wording rather than the SNS one.
* fix(sns): ignore an out-of-range persisted MaximumMessageSize
Validation only guards new writes. A topic stored before the attribute was
known carries whatever the old generic setter accepted, so the read path
could hand back a value above 1 MiB and wave a publish past the AWS ceiling,
or one at zero and reject every publish. Out of range now falls back to the
default, exactly as a nonnumeric value already did.
Also covers the attribute end to end on both wire protocols -- create, set,
get, and the oversized Publish and PublishBatch errors on Query and JSON 1.1
-- since the existing suite drives SnsService directly and cannot catch a
regression in parameter extraction or error serialization.
* fix(sns): honor FifoThroughputScope=MessageGroup on FIFO topics
A FIFO topic accepted FifoThroughputScope and echoed it back from
GetTopicAttributes, but deduplication stayed topic-wide, so the same
MessageDeduplicationId published under two different MessageGroupIds
delivered only the first message. A fan-out that reuses one dedup id per
group silently lost every message after the first.
Scope the deduplication cache key to the message group when the topic
sets FifoThroughputScope=MessageGroup, on both Publish and PublishBatch,
mirroring how SQS handles DeduplicationScope=messageGroup. Topic remains
the default and keeps the existing topic-wide behavior.
* fix(cloudformation): forward SNS FifoThroughputScope from AWS::SNS::Topic
SnsCfnProvisioner only forwarded ContentBasedDeduplication, so a topic
provisioned from a template kept the default topic-wide deduplication
even with FifoThroughputScope set, and a FIFO topic left unnamed got a
generated name without the .fifo suffix SnsService recognizes.
Forward FifoThroughputScope, suffix a generated FIFO topic name with
.fifo as CloudFormation does, treat a prior name whose suffix no longer
matches the createOnly FifoTopic flag as a replacing update, and rewrite
the mutable attributes on UpdateStack, which createTopic leaves untouched
when the topic already exists.
* fix(cloudformation): reset dropped SNS topic attributes on update
An UpdateStack that dropped FifoThroughputScope or
ContentBasedDeduplication kept the old value while reporting success.
Write the create-time default instead, for FIFO topics only: real SNS
rejects both on a standard topic.
A FifoTopic flip now fails rather than replacing the topic under a new
generated name, which would orphan it and its subscriptions. An
explicitly named .fifo topic counts as FIFO without the flag.
* fix(sns): make the group-scoped FIFO dedup key unambiguous
Nothing validates the characters in either id, so the NUL delimiter
could arrive inside one and make two different group and dedup pairs
share a cache key. Length-prefix the group instead.
* fix(sns): keep FIFO dedup scopes in separate cache namespaces
A topic-scoped dedup id shaped like the group-scoped key, "1#ab" for
group "a" with id "b", hit the same cache entry once the scope changed
inside the deduplication window. Mark each key with its scope so the
two formats cannot collide.
* feat: controltower models + service (TDD)
Adds LandingZone/EnabledBaseline models and ControlTowerService with a
lazy-seeded landing zone, UpdateLandingZone reconciliation sink, static
baseline catalog, and IdentityCenter auto-enable derivation. Unblocks
LZA's Prepare stage (controlTower.enable: true) which otherwise fails
with UnknownOperationException on POST /list-landingzones.
Landing zone version is pinned to "4.0" to satisfy LZA's
validateLandingZoneVersion check, and the seeded manifest always
includes securityRoles (dereferenced unguarded by LZA's
makeManifestDocument). Empty ListLandingZones is never observable
since that is LZA's create-path trigger, which floci does not
implement (see issues/controltower/01-gap-analysis.md).
12/12 unit tests (U1-U12) pass.
* feat: controltower REST-JSON controller + catalog wiring (TDD)
Adds the 8 Control Tower routes (list/get/update landing zone, landing
zone operation polling, list baselines, list/enable enabled baselines,
baseline operation polling) and wires the service into EmulatorConfig
and ResolvedServiceCatalog so it's health-checked and routed like any
other emulated service. Integration tests I1-I6 exercise the same
sequence LZA's Prepare stage drives: seed read, manifest reconcile via
UpdateLandingZone, register-OU baseline enable/poll, and per-account
isolation.
* docs: controltower service
Documents the pre-seed/reconciliation-sink model, the pinned 4.0
landing-zone version, the IdentityCenter baseline auto-enable rule,
and the explicit non-goals (create-landing-zone path, sso-admin,
identitystore, IAM/KMS/Organizations create-path prerequisites).
* feat(controltower): baseline update/reset operation groundwork
Cherry-picked from the ControlTower-scoped slice of 919285e6, which
bundled this alongside an unrelated ConfigService delivery-channel fix
directly on integration/all-features and never made it to this branch.
Adds EnabledBaseline.lastOperationIdentifier, a getEnabledBaseline
lookup helper, and a recordOperation helper that also tracks insertion
order -- the plumbing ResetEnabledBaseline/UpdateEnabledBaseline (next
commit) build on top of.
* feat(controltower): add landing zone lifecycle and operation tracking
(cherry picked from commit 3ddea8f3afd1aebe065b504fe877f21851809438)
* fix(controltower): correct CreateLandingZone route typo
@Path("/create-landing-zone") didn't match botocore's real wire route
/create-landingzone (no hyphen, matching every sibling ControlTower
route's convention) -- confirmed against gate.py, which flipped from
MISSING to SUPPORTED after the fix. The existing test had been
silently exercising the wrong path all along.
* chore: drop local-only bug-ledger file before upstream
issues/0026 is this fork's internal tracking, not something upstream
has a convention for.
* fix(config): declare controltower enabled toggle in both application.yml files
Upstream's ServiceConfigYamlCoverageTest requires every service config with an
enabled() toggle to declare it explicitly in both files; this branch predates
that test and fails it without the declaration.
* fix: reconcile Control Tower OU guardrails
* fix: seed Control Tower SNS prerequisite
* docs(controltower): add the service matrix row
* fix(controltower): validate landingZoneIdentifier on Get/UpdateLandingZone
GetLandingZone and UpdateLandingZone accepted any request body and answered
with the stored landing zone regardless of which one the caller named, so an
unknown ARN still returned the seeded landing zone instead of an error.
Both now require landingZoneIdentifier and return ResourceNotFoundException
when it does not match the stored ARN, matching real Control Tower.
The check seeds before comparing, unlike Delete/ResetLandingZone which must
report a missing landing zone rather than re-seed one. That keeps the lazy
seed intact: LZA reads ListLandingZones first and passes back the ARN it
returns, so the reconciliation-sink path is unaffected.
* fix(controltower): scope the operation ledger per account and region
The ledger backing GetLandingZoneOperation, ListLandingZoneOperations and
GetBaselineOperation was a single process-global map, so any caller could
enumerate every other account's operation identifiers, and it grew for the
lifetime of the process.
There is now one ledger per account+region, holding the most recent 250
operations and evicting the oldest. Read paths look the ledger up rather
than creating it, so an unknown scope cannot grow the map.
An identifier from another scope still answers with the default operation
type and SUCCEEDED rather than an error: that is the same restart-safe
behaviour an identifier issued before a restart gets, and LZA depends on it
when it polls an operation whose ledger entry is gone.
* docs(controltower): correct the CreateLandingZone path and the scope section
The operation table gave CreateLandingZone a hyphenated /create-landing-zone
path. The controller and the AWS Control Tower service model both spell it
/create-landingzone, one word, like every other landing-zone URI — the docs
were what was wrong, and both review bots flagged the controller because of
them.
The "deliberately not implemented" list also contradicted itself, describing
ResetLandingZone and ResetEnabledBaseline as implemented sinks under a
not-implemented heading. It is now split into operations that answer without
the underlying effect and operations nothing serves at all.
Also documents the identifier validation and the ledger scoping and cap added
in the preceding two commits, adds the missing ListLandingZoneOperations row,
and replaces the controller javadoc's stale operation count with a
description of the surface.
* fix(controltower): pin remediationTypes to its single modeled value
The current botocore Control Tower model constrains remediationTypes on
both CreateLandingZone and UpdateLandingZone to a list of exactly one
element (min 1 / max 1) whose only valid value is INHERITANCE_DRIFT.
The shared reader now rejects anything else with ValidationException
instead of silently storing it.
* fix(controltower): enforce modeled ARN and version constraints on EnableBaseline
EnableBaseline read baselineIdentifier, targetIdentifier and baselineVersion
and stored them verbatim. The botocore model pins all three: the two
identifiers to min 20 / ^arn:aws[0-9a-zA-Z_\-:\/]+$, and baselineVersion to
^\d+(?:\.\d+){0,2}$ with max length 10. UpdateEnabledBaseline right next to it
already validated the same shapes, so the two operations disagreed about what
they would accept.
targetIdentifier is the enabled-baseline storage key and feeds the
organizationalUnitId() substring parse, so a non-ARN value persisted a record
that no subsequent GetEnabledBaseline (which does check isArn) could reach.
Reject with ValidationException, the error the model lists for the operation,
and extract the version check into requireBaselineVersion so both operations
share one rule.
* feat(sns): deliver topic broadcasts to application-protocol platform endpoints
Add an application-protocol case to deliverMessage so publishing to a
topic fans out to subscribed mobile push platform endpoints, matching
real SNS behavior. Thread messageStructure through the delivery boundary
so platform-specific payload keys (GCM/FCM/APNS) resolve per endpoint,
and factor the push-capture tail of publishToEndpoint into a shared
capturePushForEndpoint helper. Disabled endpoints are skipped in the
fan-out rather than failing the publish. Broadcast pushes surface in the
same retrospection API keyed by EndpointArn.
* fix(sns): validate MessageStructure synchronously before topic fan-out
Topic Publish with MessageStructure=json now validates that the message is
a JSON object with a top-level default entry up front, mirroring the real
SNS API. Previously a malformed envelope was only rejected lazily inside
per-subscriber delivery, where deliverMessage's catch swallowed the
InvalidParameter and logged a warning while publish still returned a
success messageId, so application subscribers silently received no push.
* fix(sns): validate MessageStructure per entry in PublishBatch
publish() validates a MessageStructure="json" envelope synchronously before
fan-out, but publishBatch() only threaded MessageStructure into deliverMessage.
A batch entry with a malformed or default-less envelope was therefore added to
Successful while deliverMessage's catch swallowed the resulting InvalidParameter,
dropping the push for every application subscriber.
Run the same validation per entry, reporting a bad envelope as that entry's
BatchResultErrorEntry (InvalidParameter, senderFault=true) instead of throwing,
so the rest of the batch still publishes as real PublishBatch does.
* fix(sns): resolve MessageStructure=json payload per protocol on fan-out
Under MessageStructure="json", only the application protocol consumed the
envelope: sqs, lambda, http/https, email, email-json and sms each delivered
the raw JSON structure. Real SNS resolves per-protocol for every subscriber,
picking the value under the protocol key and falling back to default.
deliverMessage now resolves the payload for each subscription through the
(renamed) resolveProtocolPayload, which already keyed off an arbitrary
string; application keeps resolving against the push platform inside
capturePushForEndpoint. validateTopicMessageStructure guarantees default
exists before fan-out, so the fallback cannot come up empty.
* fix(sns): ignore non-string MessageStructure=json keys, matching AWS
Under MessageStructure=json, real SNS ignores a protocol key whose value
is not a string ("Non-string values will cause the key to be ignored"),
falling back to default rather than stringifying it. resolveProtocolPayload
was calling protocolValue.toString(), so {"default":"hi","sqs":42} delivered
the literal "42" to an SQS subscriber instead of "hi".
Only textual values are now accepted for both the protocol key and the
default fallback; non-textual values fall through. validateTopicMessageStructure
is tightened to require a textual default so a non-string default is rejected
synchronously rather than throwing (and being swallowed) during fan-out.
Adds regression tests for a non-string protocol key falling back to default
and for rejection of a non-string default.
* chore: remove unnecessary file
CHANGELOG.md was empty for the 1.1.0-1.5.2 release cycle and service docs
had drifted from code behaviour. This sweep reconciles docs against the
current codebase on upstream/main.
- Backfill CHANGELOG.md for 1.1.0 through 1.5.2 from git history
- Correct exact operation counts in docs/services/index.md: S3 (~30 -> 58),
Lambda (~25 -> 30), API Gateway v1 (~24 -> 62). Counts now come from the
actual dispatch handlers rather than @Path annotation counts.
- Rewrite README "Supported Services" table to drop per-service op counts
(they drift too fast); point readers at docs/services/index.md
- Update 24 service docs for accuracy, add "Not Implemented" sections
where relevant (s3.md, lambda.md, api-gateway.md)
- Refresh configuration and getting-started docs
- Add EventBridge Scheduler and AppConfig to mkdocs nav
- Add AppConfig / AppConfigData rows to README and services index
following the 1.5.2 upstream release