Commit Graph
4 Commits
Author SHA1 Message Date
Allen Sanborn a37c27516a feat(route53resolver): implement ListResolverEndpointIpAddresses (#5731)
* feat(route53resolver): implement ListResolverEndpointIpAddresses

The Terraform provider lists an endpoint's IP addresses right after
CreateResolverEndpoint, so the missing operation (UnknownOperationException)
failed every aws_route53_resolver_endpoint create.

Built from the IpAddresses recorded at create time: one ATTACHED entry per
request with a deterministic rni- IpId. Unknown endpoint ids raise
ResourceNotFoundException. Not paginated, like the sibling List operations.

* docs(route53resolver): update service matrix operation count

* refactor(route53resolver): add endpoint IP addresses with a single addAll

* fix(route53resolver): distinct IpIds for repeated entries; fail on missing IP record

ListResolverEndpointIpAddresses hashed only the endpoint id and the entry,
so two identical entries (two addresses in one subnet, both left for AWS to
pick, which IpAddressesRequest allows) shared an IpId. Include the entry's
position in the recorded list, which is normalised once at create and so
stable across reads.

An endpoint whose recorded IP requests are missing returned an empty list
beside a nonzero IpAddressCount. Throw the modeled
InternalServiceErrorException instead.

* test(route53resolver): import List/HashSet instead of fully qualifying (checkstyle NoFqcn)

* fix(route53resolver): return InternalServiceErrorException as HTTP 400

The Route 53 Resolver model gives InternalServiceErrorException no
httpStatusCode, so clients expect the awsJson default of 400, as with
every other Resolver error.
2026-10-15 16:44:58 -04:00
Simone Primarosa a8eedb1fd9 feat(route53resolver): apply resolver rules to DNS resolution (#4538)
* feat(route53resolver): apply resolver rules to DNS resolution

Resolver rules were stored and ignored. The embedded DNS server now consults them
before resolving a name itself, via two CDI SPIs so core.common.dns imports neither
Route 53 Resolver nor EKS: DnsForwardingRuleSource supplies the rules associated with
one VPC, DnsClientVpcSource maps a query's source address to the VPC it came from.

FORWARD rules forward the raw query to their TargetIps, each on its own port, in a
random order with the next target tried when one does not answer. SYSTEM and RECURSIVE
rules carry no targets and hand the query back to Floci, so a SYSTEM rule carves a
subdomain out of a broader FORWARD. Matching is exact-or-subdomain on label boundaries
and the most specific matching rule wins. A rule takes precedence over a private hosted
zone matching the same name, as AWS documents. Floci's own suffixes and ec2.internal
names resolve locally whatever the rules say, as AWS autodefines system rules for its
internal domains. A rule whose targets are all unreachable answers SERVFAIL for that
query only.

Route53ResolverDnsForwardingRules reads the rule and association stores through
Route53ResolverService across account partitions, since the packet path has no caller.
EksClusterManager claims its cluster node container addresses for the cluster's
resourcesVpcConfig.vpcId.

* fix(route53resolver): scope rule DNS lookups to the querying account

AssociateResolverRule stores whatever VPCId the caller names without proving
ownership of it, so joining associations across account partitions by VPC id let
one account redirect another account's cluster DNS by naming its VPC. The DNS
client VPC now carries the account alongside the VPC id, and the rule source
reads only that account's associations.

Rules are fetched by id instead of scanned for, so a query reads only the rules
an association named rather than the whole rule store, and registration warns
when a running cluster's container addresses cannot be determined instead of
leaving its rules silently inert.

Also stop setting the authoritative bit on the SERVFAIL answer for a forwarded
query: Floci is not the authority for a name a rule sends elsewhere.

* style(route53resolver): import Optional instead of qualifying it inline

* fix(route53resolver): scope rule DNS lookups to the querying region

Route 53 Resolver is regional, so a rule created in one region governs nothing in
another, but the DNS path matched on account and VPC alone. A rule created in
eu-west-1 therefore steered a query from a VPC in us-east-1. The DNS client origin
now carries the region, and a rule is only applied when its own region matches.

The stores carry no region in their keys, so a rule's region is read back from the
ARN the service minted for it rather than reshaping the stores. A stored rule with
no parseable ARN has no region to claim and is treated as belonging to the region
asking, which no create path can produce.

Associations are now read as rule ids rather than as nodes, so a query no longer
deep-copies a record per association when all it needs is which rules to look at.

* test(eks): pin the warning when a cluster's addresses cannot be determined

Inspecting the node container can fail, and when it does the cluster gets no VPC
mapping and its queries quietly ignore every associated resolver rule. Nothing
fails, so the warning is the only way a reader finds out, which makes it worth a
test rather than leaving it to inspection.

Levels are compared by severity rather than identity because JBoss LogManager
has its own Level constants, so its WARN is not java.util.logging's WARNING.
2026-09-28 09:44:28 -04:00
Allen Sanborn daecc6da17 fix(route53resolver): CreateResolverEndpoint reads IpAddresses, as AWS names it (#4180)
* fix(route53resolver): CreateResolverEndpoint reads IpAddresses, as AWS names it

CreateResolverEndpoint read its address list from a member called
IpAddressRequests. AWS names that member IpAddresses; the list's SHAPE is named
IpAddressRequest, which is where the wrong wire name came from.

The distinction is not cosmetic. Every AWS SDK, the CLI and the Terraform
provider serialise IpAddresses, and the CLI refuses to send IpAddressRequests at
all because no such member exists in its model. So the operation dispatched and
no real client could call it:

  {"Name":"ep","Direction":"INBOUND","SecurityGroupIds":["sg-1"],
   "IpAddresses":[{"SubnetId":"subnet-1"}]}
  -> 400 InvalidParameterException: IpAddressRequests is required

That is the worst shape a gap can take, because every cheap check says the
service works: it is in the service directory, /_floci/health lists it, an
operation-name grep finds it, and a does-it-route probe passes.

Reads IpAddresses, still accepting the old spelling so anything written against
the previous behaviour keeps working — the existing CustomResources tests use it
and are untouched. The error message names only the AWS member, since it is the
sole hint a caller gets. The idempotency record keeps its internal member name
deliberately: renaming it would make every endpoint stored by an earlier build
read as absent, which that code reports as a replay conflict.

Tests: the AWS member is accepted, the legacy one still is, a retry that switches
between the two spellings is not a conflict, and the missing-member error names
IpAddresses. 55 Route53Resolver tests pass.

Reported as #4108. Found while confirming that an earlier finding — Route53Resolver
absent entirely — had been fixed upstream: the probe written for it asserted only
that the call dispatches, which is what let this hide behind it.

* style: use -- rather than an em dash in added prose

AGENTS.md forbids em dashes in all content and the conformance check flags them.
Two in javadoc lines this branch added. Comments only, no behaviour change.

* docs(route53resolver): name the list shape correctly, and trim the member note

The list shape is `IpAddressesRequest`; `IpAddressRequest` is the shape of each
element, and that element name is where the wrong wire spelling came from. Both
the service doc and the Javadoc on ipAddressesOf had it as the list's own name.

The Javadoc also carried a paragraph on how the bug stayed hidden, which the PR
description already covers at length. What a reader of this method needs is the
member name and the legacy alias, so that is what is left.
2026-09-23 11:20:50 -04:00
Sam Fakhreddine d60bd6ead2 feat(route53resolver): add Route 53 Resolver with DNS Firewall domain lists (#2582)
* feat(route53resolver): AWS-managed DNS Firewall domain lists

New JSON 1.1 service exposing ListFirewallDomainLists with the four
AWS-managed domain lists, deterministic ids stable across restarts.
LZA's NetworkPrepStack Custom::ResolverManagedDomainList Lambda resolves
managed list ids by name and previously failed with UnknownOperation.

* feat(route53resolver): full-parity build-out (16 ops)

Adds firewall domain list CRUD, resolver endpoint CRUD, resolver rule
CRUD, and rule-association management, backed by four new
StorageBackend stores. The pre-existing deterministic AWS-managed
domain list logic (AWS_MANAGED_DOMAIN_LIST_NAMES, managedList(),
FirewallDomainList) is untouched -- LZA's bootstrap Lambda depends on
those ids being stable across calls.

Also fixes the JSON-1.1 dispatch case in AwsJson11Controller to pass
the account id through to the handler, matching every other service's
dispatch signature (route53resolver was the one holdout still calling
handle() with the old 3-arg signature).

* fix(config): declare route53resolver 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.

* docs(route53resolver): register the generated action table

* fix(route53resolver): declare storageKey and storageMode on the service descriptor

The service persists four stores through StorageFactory, but its catalog
descriptor left storageKey and storageMode null, so it was invisible to
PersistentPathValidator's boot check and to per-service storage config
resolution. Mirror the organizations descriptor.

* fix(route53resolver): make creates idempotent on CreatorRequestId

CreateFirewallDomainList, CreateResolverEndpoint and CreateResolverRule
allocated a new resource on every call, so an LZA/CloudFormation retry of
the same CreatorRequestId left duplicates behind. Real AWS returns the
resource the token originally created. Dedupe per store, after the
operation's own validation so a replayed token cannot excuse a malformed
body; a blank or absent token still allocates.

* fix(route53resolver): give outbound resolver endpoints rslvr-out ids

Every CreateResolverEndpoint allocated an inbound-style rslvr-in- id
regardless of Direction, so an outbound endpoint carried an id AWS would
never issue. Key the prefix off Direction (INBOUND/INBOUND_DELEGATION ->
rslvr-in, OUTBOUND -> rslvr-out) and reject values outside the
ResolverEndpointDirection enum instead of silently defaulting to inbound.

* test(route53resolver): assert managed domain lists by name, not by count

ListFirewallDomainLists returns the four managed lists plus whatever
custom lists other tests in the run have created, so size()==4 and the
[0] index extraction were both order-dependent. Assert the four managed
names are present and pick the id by name. Also drop the call-site counts
from the 404-convention comment, which would go stale on any refactor.

* docs(route53resolver): correct the scoping limitation

The limitation claimed resources are visible regardless of the caller's
account. They are not: all four stores are created through StorageFactory,
which wraps every backend in AccountAwareStorageBackend, so keys are
prefixed with the calling credential's account id and both scan() and
keys() filter on that prefix. Region and VPC are what go unenforced, and
the AWS-managed lists are region-derived and globally visible by design.

* fix(route53resolver): validate Direction before the CreatorRequestId replay check

endpointIdPrefix ran only on the allocation path, so replaying a known
CreatorRequestId with an unrecognised Direction returned 200 and the
original endpoint instead of InvalidParametersException. Bind the prefix
right after the Direction is read, so every request is validated whether
or not it turns out to be a replay.

* fix(route53resolver): enforce the RuleType and ResolverEndpointType enums

CreateResolverRule stored any RuleType string it was given and UpdateResolverEndpoint
copied any ResolverEndpointType through, so Get/ListResolverRules and
GetResolverEndpoint reported values outside botocore's RuleTypeOption
(FORWARD/SYSTEM/RECURSIVE/DELEGATE) and ResolverEndpointType (IPV6/IPV4/DUALSTACK).
Both now reject with the same InvalidParametersException the Direction check uses.

* fix(route53resolver): reject an empty TargetIps list

The model pins TargetIps to list min 1; a present-but-empty array was
stored verbatim. Absent stays allowed for SYSTEM rules. Found by the
botocore-grounded review pipeline; the hand audit missed it.

* fix(route53resolver): make the CreatorRequestId replay check atomic

Two overlapping create retries with the same token could both pass the
replay scan before either put, persisting two resources with different
ids. The three create methods are now synchronized, making the
scan-then-put pair atomic on this ApplicationScoped singleton.

* fix(route53resolver): scope the CreatorRequestId replay to the request's region

replayOf matched purely on CreatorRequestId content across the whole
account-partitioned store, which carries no region in its keys. The same
account replaying a token in a second region got the first region's
resource and ARN back instead of the regional resource it asked for.
Route 53 Resolver is regional, so a token identifies one resource per
region: match the candidate's region too, taken from the ARN this service
builds rather than a stored field, so nothing new reaches the wire.

Also folds the two stacked javadoc blocks above replayOf into one; the
second was shadowing the first, which left the idempotency contract out
of the generated docs.

* docs: correct service count to 79 after the #2579 merge

The upstream/main merge (ca772bc72) added two new services
(servicequotas, ram) on top of this branch's own route53resolver
addition. The merge-base count was 76; three disjoint new services
(1 ours + 2 upstream) makes 79, not 78 as the merge commit left it.

* fix(config): restore the controltower enabled toggle in both application.yml files

The route53resolver key was inserted between controltower: and the
enabled: true that belonged to it, so controltower: became a bare key
binding nothing and route53resolver adopted its child. Control Tower kept
running only because ControlTowerServiceConfig.enabled() carries
@WithDefault("true"), which masked the break; the explicit toggle was
gone. Caught by ServiceConfigYamlCoverageTest, which names controltower
rather than route53resolver and made the CI failure read as unrelated.

* fix(route53resolver): raise the error codes the model actually names

InvalidParametersException (plural) is a Service Catalog shape and does
not exist anywhere in route53resolver's model. Checked every throw site
against the per-operation error lists in botocore route53resolver
2018-04-01 rather than renaming globally, because the service carries two
vocabularies: the resolver endpoint, rule and association operations model
the singular InvalidParameterException, while the DNS Firewall operations
model ValidationException and do not list InvalidParameterException at all.

CreateFirewallDomainList therefore raises ValidationException; the other
eight sites raise InvalidParameterException. requireText and requireEnum
are shared across both families, so each caller now passes the code its
own operation models instead of the helper picking one. ResourceNotFound
usage was already correct and is untouched.

* fix(route53resolver): reject a CreatorRequestId replayed with different parameters

A replayed token was deduplicated on the token alone, so a retry carrying
different but individually valid parameters got a success response
describing the original resource rather than the one it asked for.

CreateResolverEndpoint and CreateResolverRule now compare the retry
against the stored resource and raise ResourceExistsException, which both
operations model. CreateFirewallDomainList is deliberately left lenient:
its modeled error list carries no conflict error at all, so reporting one
would mean inventing a shape real SDK clients cannot deserialize. That
divergence is pinned by a test and ledgered rather than guessed at.

* fix(route53resolver): compare IP request values, not just their count, on a replayed create

The conflict check compared IpAddressRequests by size, so a retry reusing
a CreatorRequestId with the same number of entries but a different subnet
or address was treated as an equivalent replay and returned the original
endpoint, dropping the configuration the caller actually asked for.

The modeled ResolverEndpoint shape carries IpAddressCount and no IP list,
and the handlers return the stored node verbatim, so the addresses are
recorded in a side store keyed by endpoint id rather than on the resource
itself; nothing new reaches the wire. Comparison is order-insensitive so a
reordered retry is still a replay, and endpoints created before this
record existed fall back to the count comparison instead of reporting a
conflict on every retry.

* fix(route53resolver): treat a missing IP-request record as a conflict, not a pass

The fallback for an endpoint with no recorded IpAddressRequests compared
IpAddressCount instead, which accepts a retry that keeps the count but
changes a subnet or address — exactly the case the record exists to catch.
That made it a silently wrong check rather than a lenient one.

With nothing to compare against, sameness cannot be established, so the
retry is now reported as ResourceExistsException. A spurious conflict is
loud and recoverable; a wrong success is neither. Nothing released can
reach this state: the endpoint store is new in the same change as the
record, so the only ways in are a write interrupted between the two stores
or state from an intermediate build of this branch.

Adds a package-private constructor so a hermetic test can create the
missing-record state the public API cannot, following the pattern in
Ec2IpamService. The cost of failing closed — an identical retry also
conflicting — is pinned as its own test rather than left implicit.

* fix(route53resolver): order IP requests by a member-order-independent key

The replay comparison sorted IpAddressRequests by JsonNode.toString, which
serialises members in insertion order. A retry carrying the same addresses
with the members written in a different order could sort the entries into a
different sequence, so an equivalent request was rejected as a conflict.

Sort by a canonical key that ignores member order instead. Both sides are
re-normalised at comparison time rather than trusting the stored order, so
a record written before this fix still compares as equal.
2026-08-27 14:16:38 -04:00