Files
floci/tools
Alessandro Lattao 95bf6df474 feat(dsql): add Aurora DSQL's control plane and AWS::DSQL::Cluster (#6048)
* feat(dsql): add Aurora DSQL's control plane and AWS::DSQL::Cluster

The first half of #6014. Aurora DSQL's REST JSON control plane, with
the answers measured on AWS (eu-west-1): CreateCluster, GetCluster,
ListClusters, UpdateCluster, DeleteCluster, GetVpcEndpointServiceName,
the cluster policy calls and tagging on cluster ARNs. Identifiers are 26
characters of lowercase base32 as DSQL's are, and malformed or unknown
ones are refused with DSQL's messages; a cluster created without
deletionProtectionEnabled is protected, and deleting a protected one is
refused. CreateCluster answers CREATING and the cluster is ACTIVE right
after.

AWS::DSQL::Cluster waits for ACTIVE, returns the identifier from Ref
and Identifier, ResourceArn, Status, CreationTime, Endpoint, VpcEndpoint
and VpcEndpointServiceName through Fn::GetAtt, and a protected cluster
makes the stack's deletion fail, as on AWS.

A cluster has no database behind it here: its endpoint is named as on
AWS, <id>.dsql.<region>.localhost.floci.io, but not served. Serving it
is the second half of #6014, its own pull request.

* fix(dsql): answer the control plane's edge cases as DSQL does

Review of #6048, each answer measured on DSQL (eu-west-1) first:
- ListClusters carries on from a page token whose cluster was deleted
  in between, as AWS does: the token now holds the sort position of the
  next page's first cluster rather than its identifier.
- deletionProtectionEnabled is read as DSQL reads it: text is false
  when it spells false in any case and true otherwise; empty text, a
  number, an object and a list fail with SerializationException.
- The tag calls refuse another account's cluster ARN with 403
  AccessDeniedException instead of reading it in the caller's account.
- A client token reused with other parameters answers 409
  ConflictException; with the same ones, the earlier cluster.
- AWS_OWNED_KMS_KEY names AWS's own key on create and update.

AWS::DSQL::Cluster reads DeletionProtectionEnabled and PolicyDocument
with AWS::NoValue as left out, and an update that drops the
multi-Region properties clears them, as it already reset the key and
deletion protection. ListTagsForResource copies the tags under the
cluster's lock, and a cluster's lock goes with the cluster.

* fix(dsql): answer errors, policies, updates and multi-Region clusters as DSQL does

A review asked for the attribute coverage, the reason ValidationException
carries, a real untag assertion and tests of the stack-update path.
Measuring them on DSQL (eu-west-1, 2026-10-20) found more that did not
match, fixed here too.

- Attributes are written with resource.getAttributes().put, which the
  schema coverage test reads; EncryptionDetails, an object an output
  refuses on AWS, is recorded as a gap.
- DSQL leaves reason out of its model-validation errors. Only the page
  token's refusal carries it, with fieldList naming next-token and its
  own text. maxResults no longer quotes the value.
- Tag calls answer what DSQL answers: 403 for an ARN that is not a
  cluster ARN, 400 BadRequestException for another Region's, 404
  NotFoundException for no cluster. The 403s name the caller.
- Policy versions are epoch milliseconds, DeleteClusterPolicy answers
  the deleted version, and the missing-policy and stale-version errors
  carry DSQL's texts and resourceType.
- Policies are checked and kept as DSQL does: its three refusal texts,
  a service principal, a principal that names no one, a public grant,
  and the lockout check when both policy actions are denied to the
  caller, unless bypassPolicyLockoutSafetyCheck. The kept form is
  Jackson's pretty printer in DSQL's element order, with condition
  operators and keys in HashMap order, as measured.
- The public check shares its condition keys with Lambda web functions
  through PublicAccessConditions, and S3 now takes its fixed-value and
  SourceIp range tests from there. Sharing the whole rule was tried and
  dropped: DSQL was measured to treat some operators otherwise than
  LambdaWeb's and S3's rules do (ForAnyValue:, ArnLike "*",
  StringEquals "*"), so the operator rules stay per service. The
  lockout check is IamPolicyEvaluator's.
- A multi-Region cluster is PENDING_SETUP and lists itself until it and
  each peer name one another, then ACTIVE; its deletion answers
  PENDING_DELETE.
- AWS::DSQL::Cluster reads its properties through CfnPropertyTypes, so
  a PolicyDocument object or DeletionProtectionEnabled "yes" fails as
  on AWS, where Boolean.valueOf made "yes" false. An update leaves a
  property the template no longer sets as it was, deletion protection,
  KMS key and multi-Region alike, and removes only the tags and the
  policy; an earlier change put them back to their defaults, which was
  not measured and is not what CloudFormation does. A policy the
  template does not change keeps its version, and create settles on
  PENDING_SETUP too.

DsqlServiceTest, DsqlClusterPoliciesTest and DsqlCfnProvisionerTest
cover these in isolation, the integration tests over the wire.

* fix(dsql): keep the public access rule to DSQL and forget a deleted policy's version

A review asked to leave S3 and Lambda web functions out of this change,
and pointed at DSQL's own block public access page. The shared helper
is dropped and S3 and Lambda web functions are as on main; folding
their copies into one helper belongs to a separate change.

DSQL now has its own keys: the trusted ones its page lists, and
aws:SourceIp, aws:SourceVpcArn and the three aws:Vpce* keys, which the
page leaves out but DSQL accepts (measured, eu-west-1, 2026-10-20). As
the page says, a policy variable never restricts: StringEquals with
${aws:PrincipalArn}, ${aws:SourceVpc} or a role/${aws:username} ARN is
public on DSQL. ArnEquals reads like ArnLike, as IAM matches both the
same way, so a value that is no ARN, ${aws:SourceArn} among them,
matches nothing and restricts, as measured.

DeleteClusterPolicy left the deleted version on the cluster, so a put
naming it went through; it is now cleared, and a put that names a
version on a cluster with no policy is refused as not found.
2026-10-20 15:34:39 -04:00
..