Commit Graph
3197 Commits
Author SHA1 Message Date
Robin BaeckmanandRobin Baeckman aeb798939b fix(eks): replace a surviving k3s container left on another Docker network (#6063)
When Floci runs in a container and restarts on a different Docker network
(FLOCI_SERVICES_DOCKER_NETWORK changed, or Floci moved from host networking to a
bridge), restoreCluster adopted the surviving k3s container where it was. Docker
isolates bridge networks from each other, so Floci could not reach the API
server, the readiness poller never marked the cluster ACTIVE, and every add-on,
access entry and access policy call kept failing with "Cluster must be ACTIVE".

A survivor that is not on the network Floci now starts clusters on is replaced,
the way a survivor whose node capacity changed already is: the data volume is
kept, so the workloads come back. Floci on the host reaches k3s through the
published port, so there a survivor is kept wherever it is.

Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
2026-10-20 07:10:09 -04:00
Alessandro Lattaoandoutof-place 47f570a821 feat(cognito): hand email codes to the CustomEmailSender trigger (#6031)
* feat(cognito): hand email codes to the CustomEmailSender trigger

* test(cognito): decrypt CustomEmailSender codes with the AWS Encryption SDK

* docs(cognito): document the CustomEmailSender trigger

* fix(cognito): fail a CustomEmailSender delivery as Cognito does

Measured on Cognito (eu-west-1, 2026-10-16), with the events a real sender
received:
- CreateUserPool and UpdateUserPool refuse a custom sender trigger without
  a KMSKeyID ("KMSKeyId parameter is required when Custom SMS/Email Lambda
  trigger is used."), and CreateUserPool a key that does not exist
  ("Encountered error when CreateGrant was attempted on the input KMS key -
  Key '<id>' does not exist"), both InvalidParameterException.
- A disabled key fails the request with CodeDeliveryFailureException
  "Caller needs to enable the configured KMS Key", a key pending deletion
  with "Unable to encrypt CustomEmailSender/CustomSMSSender code using the
  configured KMS Key". The sign-up is kept, unlike a failed SES delivery,
  and InitiateAuth answers the same error rather than InternalErrorException.
- A function that is gone, or that Cognito may not invoke, answers
  UnexpectedLambdaException "CustomEmailSender invocation failed due to
  error AccessDeniedException."
- request.clientMetadata is null for every source, InitiateAuth's
  ClientMetadata included, so the parameter that carried it is gone.

The branch also follows main since it was written: CognitoService takes
enforceTokenValidityLimits, and signUp ValidationData and ClientMetadata.

* fix(cognito): withdraw a code the CustomEmailSender could not take

Review of #6031: when the handover failed, the code issued for it stayed
live in SignUp, ForgotPassword and both attribute flows, so asking for a
code again within 30 seconds answered LimitExceededException. Measured
on Cognito (eu-west-1): it hands out a code again at once, on a healthy
pool and once a key that could not encrypt is enabled again, for
ResendConfirmationCode and ForgotPassword alike.

sendThroughCustomEmailSender now withdraws the code before it fails, for
every flow, and the two catches that withdrew it by hand (resend and the
sign-in OTP) leave that to it.

* fix(cognito): hand the CustomEmailSender the request's ClientMetadata

Review of #6031: the developer guide lists ClientMetadata for the
sign-up, forgot-password and sign-in sources, and the branch passed null
for every one on the strength of InitiateAuth alone. Measured on Cognito
(eu-west-1): SignUp, ResendConfirmationCode, ForgotPassword,
GetUserAttributeVerificationCode and UpdateUserAttributes each hand the
function the request's ClientMetadata; only the sign-in code's event has
none, even when InitiateAuth sends one. A request without ClientMetadata
gives null, as measured before.

ResendConfirmationCode, ForgotPassword and the two attribute calls now
take the request's ClientMetadata through the service, with overloads
that keep their previous signatures. resolveTriggerArn's custom sender
branch gets its braces.

---------

Co-authored-by: outof-place <contact@outofplace.space>
2026-10-20 06:44:20 -04:00
Andre Kurait 0e6db1f2b3 fix(route53): serve stored public TXT and delegation records (#6034)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-20 00:05:29 -04:00
Andre Kurait be2cb677d0 feat(resourcegroups): support EC2 capacity reservation pools (#6011)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-20 00:04:50 -04:00
lex00 691499d335 feat(sqs): opt-in AWS QueueUrl form via endpoint strategy (#5517)
* feat(sqs): opt-in AWS QueueUrl form via endpoint strategy

FLOCI_SERVICES_SQS_ENDPOINT_STRATEGY=standard returns queue URLs in the AWS
form, https://sqs.<region>.<dnsSuffix>/<account>/<name>. The default, path,
keeps the current form. Every input form resolves under either setting.

* fix(sqs): endpoint strategy accepts path or standard

* refactor(sqs): queue URL forms are floci and aws, with shared round-trip tests

* test(sqs): strategy names in tests and config comments read floci and aws

* docs(sqs): list endpoint-strategy on the application.yml page

The yml block and the env var table both list the setting, and the base-url comment names the aws strategy.
2026-10-19 23:51:18 -04:00
Allen Sanborn 88b0522168 fix(config): answer ResourceNotFoundException for tags on a missing resource (#6047)
TagResource, UntagResource and ListTagsForResource were plain map
operations keyed by ARN. Tagging a deleted conformance pack's ARN
returned 200 and re-created an orphan tag entry, and listing it
returned an empty list. The Config model lists ResourceNotFoundException
for all three operations.

For the kinds Floci stores (config rules, conformance packs, aggregation
authorizations) the ARN must now match an existing resource in the
caller's account and request Region, so a deleted resource, or an ARN
from another account, Region or partition, is not found. The check and
the write run under the lock the resource's delete takes, so a delete
cannot land between them and leave tags for a resource that is gone.
ARNs of kinds Floci does not model are still accepted unchecked.
2026-10-19 23:42:17 -04:00
David Phillips 0da0c80824 feat(elbv2): terminate HTTPS with ACM and IAM certificates (#5959)
* feat(elbv2): serve HTTPS listeners with ACM and IAM certificates

Route HTTPS traffic with SNI and refresh certificates when they change.

* fix(elbv2): preserve attached ACM certificates

Refuse revocation while a listener uses the certificate and keep
certificate listings responsive when many listeners are configured.
2026-10-19 23:40:17 -04:00
Hector Ventura 73da37b90e fix(ec2): reject tag writes on missing, malformed or absent resources (#5996)
* fix(ec2): reject tag writes on missing, malformed or absent resources

CreateTags and DeleteTags stored tags for any id. Both now answer
MissingParameter when no resource is named and InvalidID for an id that is
not a known EC2 prefix followed by hex digits. CreateTags also checks each
resource exists in the request region and answers with that type's own
NotFound error, as moto does; a well-formed id of a type Floci does not
model is still tagged.

CreateTags enforces the documented limits: at most 50 user tags per
resource (aws: tags do not count) with TagLimitExceeded, and keys up to 128
and values up to 256 Unicode characters with InvalidParameterValue. Every
resource and limit is checked before any tag is written.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(ec2): match tag targets in full and resolve them by their prefix

A tag target id is now matched in full with an 8 or 17 hex suffix, and an id Floci seeds without hex digits (a default VPC resource, a catalog AMI alias) passes only when the region holds it. The resource type comes from the matched prefix, so eni-attach-, vpce-svc- and the cidr-assoc ids reach the unmodelled arm, and an AMI is checked against the catalog and the region's registered images instead of DescribeImages, which answers an unknown id with a launchable fallback.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(ec2): accept fleet and IPAM tag targets and check the tag limit under the write's locks

EC2 Fleet and Spot Fleet request ids are UUIDs and an IPAM pool allocation id has 33 hex digits, so a tag target id now takes 8 or more hex digits or a UUID, and the ipam, ipam-scope, ipam-pool and ipam-pool-alloc prefixes are known. The 50-tag check ran before the write took its resource locks, so concurrent CreateTags requests at 49 tags could all pass it; the check and the write now run holding every named resource's lock, taken in stripe order after the topology lock.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-19 23:39:29 -04:00
Jackson Price 7504d71e76 fix(ec2): require IMDSv2 tokens when HttpTokens is required (#5966)
* fix(ec2): probe IMDS proxy readiness with an IMDSv2 token

The proxy start script checked readiness with a tokenless read of the
instance ID. Once IMDS enforces HttpTokens=required, that read gets 401
and the proxy reports a failed start after twelve attempts. The probe
now fetches a 60-second token and reads with it; a refused or empty
token fails the attempt rather than falling back to a tokenless read.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse tokenless metadata reads when HttpTokens is required

IMDS answered every request without a token through IMDSv1, whatever
the instance's HttpTokens said. On AWS, when token usage is required,
requests without a valid token get 401 Unauthorized. Floci now does the
same for every metadata endpoint, before it looks up the data, using
the options the instance was launched with or last modified to.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): clear application library paths in IMDS helper shells

docker exec gives the proxy's install and start shells the image's
environment. An application image that sets LD_LIBRARY_PATH, PYTHONPATH
or PYTHONHOME can then make the package manager, socat and curl load
its libraries or Python instead of the system's. Both shells now unset
those three first; only the helper shell changes, so the container's
configuration and the application's processes keep them.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse metadata option changes on EKS cluster nodes

IMDS serves a cluster node from the instance its EKS cluster registered,
while EC2 hands out a copy of it. ModifyInstanceMetadataOptions changed
and stored that copy, so DescribeInstances reported HttpTokens=required
while the node's IMDS kept answering tokenless reads, and the stored
copy no longer counted as a cluster node. The action now answers
OperationNotPermitted for cluster nodes, as their stop, start, reboot
and terminate actions do.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): publish metadata option changes to the IMDS event loop

IMDS now reads an instance's metadata options on its Vert.x event loop,
while ModifyInstanceMetadataOptions replaces them from a request thread.
Without a happens-before edge the event loop could keep serving the old
options, or see the new object before its fields. The field is now
volatile, as the instance's state already is.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep the IMDS readiness probe off HTTP proxies

The probe's curl calls honored an image's http_proxy or ALL_PROXY, so a
proxy configured for the application received the link-local requests,
every attempt failed and the start reported a failure although socat
was running. Both calls now pass --noproxy '*'.

The helper-shell test support moves to a shared HelperShellFixture, and
a new test runs the real token probe inside the generated start script,
whose set -eu loop must retry after a refused token.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): clear application library paths in the sshd install probe

The sshd install probe runs dnf, yum or apt-get through docker exec with
the image's environment, the failure the IMDS helper shells now avoid:
with an application's PYTHONHOME or LD_LIBRARY_PATH, dnf could not
start, so sshd was never installed. The probe now unsets the same three
variables first, through the IMDS proxy's shared constant.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep refusing cluster nodes once EC2 has stored a copy

The cluster-node check counted an instance as a node only while EC2's
own store had no record of it, but ModifyInstanceAttribute, monitoring
and other actions store EC2's copy of a node. After one of them,
ModifyInstanceMetadataOptions was accepted without reaching the node's
IMDS, and TerminateInstances and StopInstances were no longer refused.
A node is now recognized by its cluster's provider alone.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep the pod identity relay probe off HTTP proxies

The EKS pod identity relay's readiness probe shares the IMDS proxy's
start script and environment, but its curl still honored the image's
http_proxy: a proxy that answered passed the probe whether or not socat
relayed, and an unreachable one failed the start. It now passes
--noproxy '*' like the IMDS probe, from a podIdentityProbeCommand the
test runs. The shared unset's Javadoc now names the shells that run it.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): refuse tokenless reads of every path when tokens are required

The HttpTokens=required check ran inside the handlers of the paths IMDS
serves, so a tokenless read of any other path, such as the
/latest/meta-data/ listing that IMDSv1 detection probes, answered 404
where AWS answers 401. The check now runs ahead of every GET route;
with a token, or on an instance that allows IMDSv1, such a path is
still 404.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep IMDS answers for methods it does not serve

The required-token check was registered as a GET route for every path,
and Vert.x answers 405 to any other method on a path some route matches,
so POST /latest/meta-data/ began to answer 405 instead of 404, and a
tokenless HEAD on a required-token instance got 405 instead of 401. The
check is now a route for every method that acts on GET and HEAD only.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): check that the pod identity probe reaches its relay

The probe treats any answer but 000 as ready, so the test passed even
when curl was missing and nothing reached the relay. It now counts the
relay's requests, and both stand-in servers start inside its try.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(ec2): say that IMDS refuses a tokenless HEAD but serves none

The required-token check's Javadoc called HEAD a read, but no IMDS route
serves HEAD, so one with a token still gets the router's 405.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(ec2): say what IMDS answers a HEAD that has a token

No route serves HEAD, so the router answers 405 on a path a GET route
serves and 404 elsewhere. A test pins both.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): check IMDS refuses tokenless reads on Fleet and Auto Scaling launches

Since #5964, Auto Scaling launches carry a launch template's
MetadataOptions and CreateFleet forwards them. The test of template
options on Fleet and Auto Scaling launches now also checks that IMDS
refuses the launched instance a tokenless read and serves it with a
token.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(ec2): say where HttpTokens comes from and what IMDS refuses

The IMDS notes said HttpTokens could be set "at launch". They now name
its sources: RunInstances, directly or through a launch template, EC2
Fleet and Auto Scaling launches, and ModifyInstanceMetadataOptions.
They say that a tokenless GET or HEAD is refused on every path, and
that EKS cluster nodes refuse the change, in the notes, the EKS
lifecycle-protection list and the action table. They also say that the
readiness probe bypasses the image's HTTP proxy, that the helper shells
keep an application's library search path and Python installation from
the system tools rather than promising more, and that the sshd install
shell clears them too.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 22:50:50 -04:00
Allen Sanborn 2f6f3a8f86 feat(route53resolver): add TagResource, UntagResource and ListTagsForResource (#6035)
* feat(route53resolver): add TagResource, UntagResource and ListTagsForResource

The Terraform provider lists tags after creating any aws_route53_resolver_*
resource, and Route 53 Resolver had no tagging operations, so the apply failed
right after the create succeeded.

Tags are kept per ARN in their own store, because none of the modelled
resource shapes carries a Tags member. Resolver endpoints, resolver rules and
custom firewall domain lists are taggable; tags passed to their Create calls
are stored, and validated before anything is allocated. Lookup resolves the id
in the caller's account and requires the stored ARN to match exactly, so an
ARN naming another account, region or partition is ResourceNotFoundException.
ListTagsForResource pages with MaxResults (1-100, default 100) and NextToken.

* fix(route53resolver): scope tagging lookups to the caller and type-check tag input

TagResource, UntagResource and ListTagsForResource now require the ARN to
name the caller's own partition, region and account before reading any
store, and fetch the resource with getForAccountMigratingLegacy, so an
unprefixed pre-multi-account entry is migrated only into the account its
stored ARN names. Before, a plain get() moved such an entry into whichever
account looked it up first, and that account could then tag it by naming
its original ARN.

Tag Key and Value, and each UntagResource TagKeys entry, must be JSON
strings (TagKey/TagValue are string shapes) instead of being coerced with
asText(). MaxResults must be an integral number before its 1-100 range is
checked, so 1.5 or true is InvalidParameterException rather than 1.

ListTagsForResource copies the stored tag node under the monitor that
TagResource and UntagResource mutate it under, so a concurrent tag change
can no longer break the iteration or show a half-applied page.

* fix(route53resolver): page tags through Pagination and cap tag lists at 200

ListTagsForResource now pages through the shared Pagination.paginate with
an opaque, namespaced cursor on the tag key instead of a raw offset, so a
forged or stale offset token is InvalidNextTokenException. MaxResults stays
type-checked against the JSON value (integer 1-100, InvalidParameterException).

TagResource Tags, UntagResource TagKeys and the Tags on CreateResolverEndpoint,
CreateResolverRule and CreateFirewallDomainList are capped at the modelled 200
entries per request (TagList/TagKeyList max 200). Over the cap is the
operation's parameter error: InvalidParameterException, or ValidationException
on CreateFirewallDomainList. No per-resource total is enforced; the model does
not state one.
2026-10-19 22:45:48 -04:00
Priamo Germosen 37717537a4 fix(iam): record a denied browser PostObject in CloudTrail (#6030)
Under IAM enforcement a denied S3 request is recorded in CloudTrail as
the operation that was refused, but a browser POST upload left no
record. Its credential is only in the form fields, so S3Controller
authorizes it through IamEnforcementFilter.authorizeAdditionalResource,
which threw AccessDenied without going through the denial emitter.

The POST path now calls a new authorizePostObject, which checks
s3:PutObject as before and, when IAM refuses it, records the denial as
PostObject before refusing. AWS's S3 developer guide lists PostObject
among the object-level API actions logged as CloudTrail events; the
current user guide's data events table no longer names it. The
emitter's recording half is split out so both paths share it, and a
record it cannot write is logged as a warning.

The denial is recorded in the Region the form's credential names, as a
presigned URL's is in the one its query credential names, so a trail
that logs only that Region gets it.
2026-10-19 21:32:47 -05:00
Priamo Germosen 24a960a599 fix(iam): check the API Gateway and Lambda routes the action map names, and test them (#6036)
Under IAM enforcement a REST request is checked as the action its route
maps to, and a route no rule maps is let through unchecked. On #5604 the
S3 and API Gateway entries of iam-authorized-actions.json were noted as
never read, since those requests are authorized by route, with a test
comparing them with the route table asked for. This adds that test,
against each operation's real route, and fixes what it found.

- IamRestRouteCoverageTest builds a request on each operation's route,
  as botocore's model gives it, and checks that the registry resolves
  every S3, API Gateway and Lambda entry of iam-authorized-actions.json
  to the action the entry names. The routes are vendored, one operation
  to a line, in src/test/resources/aws/rest-routes.json by the new
  tools/aws/regen_rest_routes.py, which make aws-data-sync and
  aws-data-check now run.
- API Gateway: only /account and /restapis were mapped, so API keys,
  usage plans, client certificates, base path mappings, domain names
  and all of the v2 API went unchecked. The management API is now
  checked as apigateway:<method> on any route, as AWS authorizes it,
  and RejectDomainNameAccessAssociation and PutRoutingRule as their own
  actions. The v2 operations AWS checks only as actions of their own
  names, routing rules and portals, are not served by Floci.
- Lambda: InvokeWithResponseStream went unchecked; it is now checked as
  lambda:InvokeFunction, against the qualified function as an invoke
  is. GetLayerVersionByArn is checked as lambda:GetLayerVersion. It
  shares its path with ListLayers, so a rule can now require a query
  parameter.
- S3: the two bucket metadata configuration entries are not applied.
  Floci serves no metadata configuration, and such a request falls
  through to ListObjects or DeleteBucket, so it stays checked as the
  operation that runs.
2026-10-19 21:32:37 -05:00
Alessandro Lattao e38ec02d44 fix(cloudformation): register an ECS task definition's containers with their LinuxParameters (#6027)
* fix(cloudformation): register an ECS task definition's containers with their LinuxParameters

An AWS::ECS::TaskDefinition dropped its containers' LinuxParameters, so
a container CloudFormation registered ran without the init process,
capabilities, devices, shared memory, swap or tmpfs mounts the template
asked for, and the Fargate rules on them never applied.

They are now read from the task definition as the ECS handler converts
it and kept where RegisterTaskDefinition keeps them, among the
container's unparsed members under linuxParameters, so
DescribeTaskDefinition returns them in the API's shape and the same
validation, normalisation and Fargate checks apply as for a definition
registered through the API. As CloudFormation's handler does
(measured), the devices and tmpfs lists are sent empty when the
template has none.

* test(compat): wait for the LinuxParameters stacks through TestFixtures

Review of #6027: the test's private waitForTerminal and waitForDeleted
repeated TestFixtures.awaitStackTerminal. It now waits through that, and
deletes its two stacks with a plain DeleteStack after the class, as
CloudFormationEcsTaskDefinitionModelTest does.

* test(compat): give the ECS CloudFormation stacks Floci's and AWS's own timeouts

Review of #6027: DEPLOY_TIMEOUT was 30 seconds against both targets.
These stacks finish in milliseconds on Floci, so it is now 10 seconds
there and 10 minutes on real AWS, as CloudFormationEventsRuleTargetTest
splits it. CloudFormationEcsTaskDefinitionModelTest, from #6018, had the
same single 60 seconds and splits the same way.
2026-10-19 22:32:16 -04:00
Andre Kurait 0517a7a936 fix(cloudformation): enforce SAM REST authorization defaults (#6021)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-19 21:32:03 -04:00
Jackson Price e520166170 fix(ec2): protect subnets and VPCs that load balancers use (#5663)
* fix(elbv2): protect subnets and VPCs that load balancers use

DeleteSubnet and DeleteVpc returned success while an Application or
Network Load Balancer still used the subnet, and DescribeLoadBalancers
went on listing a subnet that no longer existed. EC2 now asks each
VpcDependencyProvider, implemented by ELBv2, before deleting a subnet or
VPC, under the lock CreateLoadBalancer and SetSubnets hold while they
record their subnets, and refuses with DependencyViolation. Covered end to
end through CloudFormation, including updates, rollbacks and stack
deletes that move or delete load balancers, subnets and VPCs.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): record the subnets a load balancer is on

A load balancer's attributes named none of its subnets, so once a
template stopped naming it, the stack walks had nothing to order it by
and deleted it after them, which EC2 now refuses. The provisioner keeps
one hidden uses attribute per subnet, refreshed when an update moves the
balancer and when a rollback moves it back.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): delete removed resources dependents first

The update cleanup deleted removed and condition-disabled resources in
reverse map order, before the replacement cleanup. A subnet an earlier
update added sits after the load balancer it moved onto it, so removing
both deleted the subnet first, and a renamed balancer's old entity still
used a subnet the same update dropped. Both now end DELETE_FAILED, since
EC2 refuses to delete a subnet a load balancer uses.

The removed resources are now walked in dependency order, and a failed
delete is tried once more after the replacement cleanup before it is
reported.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(ec2): name every ELBv2 load balancer type as a subnet dependency

The DeleteSubnet and DeleteVpc rows named only Application and Network
Load Balancers, while the check counts every ELBv2 type. The SDK
lifecycle test now deletes its subnets and VPC even when an assertion
fails.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(cloudformation): pin the order of the removed-resource deletes

The removal test passed through the retry alone, so it now checks that
the load balancer is deleted before its subnet is tried, and that the
replaced balancer's old entity goes before the dropped subnet. The
provisioner attribute test reads only what Fn::GetAtt can see, with the
balancer on subnets.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 21:13:00 -04:00
David Phillips 0f4f59bbbb fix(elbv2): require an HTTPS default certificate (#5989)
* fix(elbv2): require an HTTPS default certificate

Refuse HTTPS listener changes until a default certificate is supplied.

* docs(elbv2): keep certificate checks documented correctly
2026-10-19 21:12:16 -04:00
Allen Sanborn eb968b0b69 fix(redshift): reject foreign-account or foreign-region ARNs in tagging (#6026)
* fix(redshift): reject foreign-account or foreign-region ARNs in tagging

resolveTagHandle checked only that the ARN's service was redshift, then
looked the resource up by id. CreateTags, DeleteTags, DescribeTags and the
tag listing therefore acted on the caller's local resource of the same name
when given another account's or another region's ARN, for every resource
type in the switch: cluster, snapshot, parametergroup, subnetgroup,
snapshotcopygrant and snapshotschedule.

The ARN's account and region are now compared with the caller's
(RegionResolver.getAccountId / getRegion, the same values the service uses
to mint these ARNs) before the lookup.

Error choice: ResourceNotFoundFault (404). It is the not-found fault the
Redshift model lists for all three tag operations (CreateTags, DeleteTags,
DescribeTags), and the snapshotcopygrant branch already uses it for a missing
resource. The per-type faults (ClusterNotFound etc.) are not modelled on
these operations. What real AWS returns for a foreign-account or
foreign-region ARN was not confirmed against the live service.

* fix(redshift): reject foreign-partition ARNs in tagging

resolveTagHandle compared an ARN's account and region with the caller's
but not its partition, so arn:aws-cn:redshift:<local-region>:<local-account>:...
still resolved to the local resource. Reject it with ResourceNotFoundFault
like the other foreign-scope ARNs.

* refactor(redshift): use AwsArnUtils.isForeignAccount for the tag ARN account check

Pairs it with isForeignPartition the way LambdaLayerService does, per review.
2026-10-19 21:07:28 -04:00
TATSUNO “Taz” Yasuhiro 7fb649715c fix(cloudfront): serve a Lambda Web Function endpoint origin from Floci itself (#6022)
* fix(cloudfront): serve a Lambda Web Function endpoint origin from Floci itself

A custom origin whose domain is an endpoint this Floci minted now goes to
the listener the viewer reached, with the endpoint domain as Host. Before,
the endpoint host did not resolve, and loopback failed the private address
check.

As on AWS, a forwarded viewer Host is a 502, because the endpoint's
certificate does not name it.

* fix(cloudfront): fetch the endpoint origin over plain HTTP for TLS viewers

A viewer over TLS reached the HTTPS port, and Floci sent plain HTTP to it.
The request now goes to the plain HTTP port at the same address.

The endpoint domains are also indexed by the host a CloudFront origin
names, so a base URL host with upper case or a trailing dot still matches.
2026-10-19 21:06:57 -04:00
Allen Sanborn ec6f8a9d81 fix(opensearch): apply only supplied fields on partial UpdateDomainConfig (#6028)
* fix(opensearch): apply only supplied fields on partial UpdateDomainConfig

UpdateDomainConfig overwrote DedicatedMasterEnabled and ZoneAwarenessEnabled
unconditionally, and the ClusterConfig/EBSOptions parsers filled omitted
fields with model defaults. A partial block such as {"InstanceCount":5} or
{} reset dedicated master, zone awareness, instance type and count; a
partial EBSOptions reset VolumeType to gp2 and EBSEnabled to true.

The model fields are now boxed, the parsers leave omitted fields null, and
create and update share one merge that copies only non-null fields, so an
explicit false still turns a setting off. The legacy 2015-01-01 ES API
delegates to the same controller and is covered by the same fix.

* test(opensearch): drop internal tracker id from test comment
2026-10-19 20:17:02 -04:00
Andre Kurait 4b3681eb90 fix(apigateway): preserve API ownership across integration invocations (#6001)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-19 19:58:19 -04:00
Jackson Price 456ae15684 fix(ec2): apply the AWS public address rules and displace earlier Elastic IPs (#5963)
* fix(ec2): assign mock public addresses and displace earlier Elastic IPs

In mock mode an instance never received a public IPv4 address, whatever
its subnet's MapPublicIpOnLaunch or its launch's AssociatePublicIpAddress
said, and an associated Elastic IP never reached DescribeInstances.

- A mock instance that asks for a public address gets one when it reaches
  running, whether DescribeInstances, DescribeInstanceStatus or
  StartInstances completes the launch. Stop and termination release it.
  An associated Elastic IP replaces it and survives a stop; disassociating
  it gives a running instance a new automatic address when its launch
  asked for one.
- AssociateAddress disassociates the Elastic IP an instance already has,
  including one a retained interface carried onto it, as the
  AssociateAddress reference describes.
- Launches from a template take AssociatePublicIpAddress from its
  device-index-0 interface (RunInstances, CreateFleet, Auto Scaling), and
  RunInstances and CreateFleet also take that interface's subnet.
- RunInstances refuses an instance-level SubnetId combined with network
  interfaces, on the request or in its launch template, with
  InvalidParameterCombination.

Split out of #5671 at review.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): scope Elastic IP displacement and automatic addresses as AWS does

- AssociateAddress ignored PrivateIpAddress, so an Elastic IP meant for
  a secondary private address displaced the one on the primary. The
  address is now recorded on the private address it names, only an
  address already on that private address is displaced, the interface
  shows it there, and in mock mode only the primary's address becomes
  the instance's public address.
- An instance launched on an existing network interface got an
  automatic public address; AWS assigns one only to an interface the
  launch creates.
- A released automatic address was replaced while a second interface
  was attached; AWS does not replace it then.
- An Elastic IP that a retained interface carried to a new instance
  stayed without an instance. It now names that instance, which shows
  the address and keeps it across a stop.
- A mock launch could complete over a concurrent stop or termination,
  and DescribeAddresses could write back an address disassociated
  meanwhile; both now re-check under the instance's lock.

The tests also cover a request's own network interfaces with an
instance-level SubnetId, and the template interface docs now say which
launches take the subnet.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): settle second-review findings on mock public addresses

- DescribeAddresses re-points associated addresses under the allocation
  lock, and a mock launch, start or stop reads the instance's Elastic IP
  under it, so none of them acts on an association written halfway or
  changed meanwhile.
- An Elastic IP that a retained interface carries is found through that
  interface, also when it is disassociated, instead of being rebound to
  the next instance at launch, which left a dead InstanceId behind when a
  container launch failed.
- StartInstances leaves a running mock instance alone.
- In container mode too, an address on a secondary private address no
  longer becomes the instance's public address.
- The second-interface test associates its address before attaching the
  interface, since AssociateAddress by InstanceId needs exactly one.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): keep terminated mock instances down and address reads unblocked

- StopInstances leaves a terminated or shutting-down mock instance as it
  is, re-checked under the lock, so terminate, stop and start no longer
  revives it with a public address.
- DescribeAddresses waits for the allocation lock only when an address
  is associated with an instance, and the container re-point no longer
  rewrites an unchanged instance.
- A mock start treats a state without a name as settled instead of
  throwing.

Tests now cover the terminated instance and, with a reachable container
address, an Elastic IP on a secondary private address leaving the
instance's public address alone.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): settle Qodo findings on mock public addresses

- AssociateAddress refuses a PrivateIpAddress that is neither the
  instance's primary private address nor a secondary address of its
  primary interface, with InvalidParameterValue and before any
  association changes, instead of treating it as the primary and
  displacing the Elastic IP already there.
- RunInstances from a launch template whose device-index-0 interface
  names an existing NetworkInterfaceId launches on that interface, in
  its subnet and without an automatic public address, as a request
  naming it would, instead of on a new interface in the default subnet.
- The SubnetId-with-interfaces refusal test now launches against a real
  subnet and checks that the refused request leaves no instance or
  interface behind.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): accept a container instance's launch address in AssociateAddress

In container mode without AWS-faithful private addresses, the container
manager replaces the instance's reported private address with its Docker
bridge address once the container runs, and nothing keeps the subnet
address RunInstances returned. The new PrivateIpAddress check therefore
refused that address with InvalidParameterValue, though callers may still
name it. Only mock mode and the AWS-faithful mode, which keep the launch
address, now refuse a stray PrivateIpAddress; elsewhere any value means
the primary address, as before.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): decide automatic public addresses the same way with containers

The public IPv4 rules were applied to mock instances only. A
container-backed instance kept its address after a stop and a
termination, got one on an existing network interface, kept its
reachable address after its Elastic IP was disassociated even when the
launch never asked for one, and had a released address replaced while
a second interface was attached.

One rule, AutomaticPublicAddress, now decides whether an instance has
an automatic address in both modes: the launch asked for one on an
interface the launch created (recorded when the instance is built), a
stop, a termination or a disassociated Elastic IP releases it, and a
replacement is held back while a second interface is attached. An
Elastic IP on the primary private address still takes precedence. Only
the value differs by mode: the container's reachable address, or an
invented one where there is no container.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): settle review findings on the shared public address rule

- DisassociateAddress decides by the association, not by comparing
  addresses: only an Elastic IP on the instance's primary private address
  gives way to another one left there, or to an automatic address when
  one is due. With a container, every Elastic IP points at the one
  reachable address, so disassociating a secondary one no longer clears
  the instance's public address, and one a restart moved no longer
  survives its disassociation.
- StartInstances on a stopped container instance releases an automatic
  address that a stop outside StopInstances, such as Floci's shutdown,
  left in place, so the start decides afresh.
- With a container, these writes no longer wait on the instance's lock
  while holding the allocation lock, since the port-forward manager holds
  that lock across Docker calls.
- A start test case now keeps an address distinct from the one it
  expects, and two comments describe the flag as it now is.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): release only the primary interface's Elastic IP on disassociation

- DisassociateAddress treats an Elastic IP as the instance's public one
  only when it sits on the primary interface, not on a retained
  interface attached at another device index, so disassociating that one
  no longer clears the instance's automatic address.
- With a container, DescribeAddresses no longer writes a re-pointed
  address back onto a terminated or shutting-down instance.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): show a carried Elastic IP on a container instance's launch

- An instance launched on a retained interface that still carries an
  Elastic IP records that address at RunInstances, and the container
  launch re-points it once the container runs. With containers, such an
  instance had no public address until a stop and start, since the
  shared rule gives an existing interface no automatic address.
- With a container, TerminateInstances clears the public address under
  the allocation lock, so a DescribeAddresses re-point already under way
  cannot write it back onto the terminated instance.
- The secondary-interface disassociation test checks the address was
  still associated before the call and is not after it.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): re-point a carried Elastic IP at its new instance

- DescribeAddresses re-points an Elastic IP that a retained interface
  carries at the instance that interface is now the primary interface
  of. With containers, the address otherwise kept the previous
  container's address for good, since termination clears its instance
  id.
- With a container, StopInstances leaves a terminated or shutting-down
  instance alone, as mock mode does, instead of stopping it into a
  startable state and writing its Elastic IP back.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): give mock instances no invented public address by default

Mock instances due an automatic public IPv4 address got a random
54.x.x.x one, a real AWS range, so a tool that connected to it reached
someone else's host. The new floci.services.ec2.mock-public-addresses
setting (FLOCI_SERVICES_EC2_MOCK_PUBLIC_ADDRESSES) chooses the address:
none (the default) gives none, documentation draws distinct addresses
from 203.0.113.0/24 as Lightsail and EMR do, and fixed gives every
instance mock-public-address (default 127.0.0.1), an address the caller
can reach.

Only the value changes. The launch still records whether it asked for
an address, so the shared rule and Elastic IP precedence work as before,
and instances with containers keep reporting their reachable address.
Elastic IP allocation still draws from 54.x.x.x, as on main.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): settle review findings on the mock public address setting

A configured mock-public-address with surrounding spaces was reported
as is; it is now stripped. The docs and the AutomaticPublicAddress
Javadoc no longer describe every mock instance as getting an address,
and the test configurations that launch mock instances name the
setting instead of leaving it null.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): allocate Elastic IPs from the documentation range

AllocateAddress handed out random 54.x.x.x addresses, a real AWS range,
and this branch shows an associated Elastic IP as a mock instance's
public address, so even with mock-public-addresses at none a client
could reach someone else's host through one. Elastic IPs now come from
203.0.113.0/24 in every mode, distinct from the account's other
Elastic IPs and its instances' public addresses; once all 254 are taken
AllocateAddress fails with AddressLimitExceeded rather than repeat one,
since callers name an Elastic IP by its address.

Under mock-public-addresses: fixed, an Elastic IP on a mock instance's
primary private address is re-pointed at the configured address, as one
on a container instance is at the container's reachable address, and
disassociation restores the allocated address.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): settle review findings on documentation-range Elastic IPs

An Elastic IP re-pointed at the fixed address kept it after a restart
under another setting; the next read now shows its allocated address
again. The re-point Javadoc and the Elastic IP docs no longer claim a
54.x.x.x allocation or addresses that never repeat, the docs say that
earlier allocations keep their address until released, and a test now
proves an allocation skips the addresses instances hold.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 19:48:20 -04:00
Mario Toffia 34d904fde5 feat(iot): search fleet things by connectivity status (#6025)
* feat(iot): search fleet things by connectivity status

SearchIndex refused every connectivity field and its documents carried
no connectivity, so an application that finds its things by connection
state got InvalidQueryException.

With connectivity indexing on, a thing now reports the MQTT broker
session whose client id is its name, and connectivity.connected,
connectivity.clientId and connectivity.disconnectReason can be
searched. The other connectivity fields are still refused with
InvalidQueryException. A thing whose client id never connected reports
connected false and timestamp 0, as on AWS.

The broker now records the account, region, connect time, keep alive
and clean session of each session, and keeps in memory how the last
one of each client id ended in each account and region, until a state
reset. The reason is the one the session's disconnected lifecycle
event carries, recorded by the same single endSession under the
session lock, so the late end of a displaced session cannot overwrite
its successor's. A plaintext session counts in the default account and
region, a TLS session in its certificate's.

Closes #4912

* fix(iot): serialize connectivity reads and resets with session ends

A connectivity lookup read the live session without the session lock,
so a search racing DeleteConnection could see the session connected
after its disconnect was recorded. A state reset cleared the history
without the lock too. Both now run under the session lock; the lookup
tests the session's ended flag instead of the endpoint, as the lock is
never held across endpoint calls.

Tests cover the reset contract, a lookup and a reset racing a held
DeleteConnection, and a TLS session counting in its certificate's
account and region.
2026-10-19 19:45:53 -04:00
Hector Ventura 1eb402d623 fix(ec2): keep tags in the region of the resource they label (#5973)
* fix(ec2): keep tags in the region of the resource they label

DescribeTags listed every region's tags because the tag store was keyed by
the bare resource id. Tags are now stored per region, so DescribeTags,
DeleteTags, CreateTags and the aws:ResourceTag IAM condition only see the
request region's tags. Each side of a cross-region transit gateway or VPC
peering connection keeps its own tags in its own region.

Tags stored by bare id are moved under their resource's region at startup,
for every account; a tag whose resource no region holds is dropped.

DescribeTags now reports image, volume, snapshot, network-acl,
vpc-peering-connection and spot-instances-request instead of "unknown".
Tags given when a volume or peering connection is created reach the store,
and DescribeVolumes, DescribeSnapshots and DescribeSpotInstanceRequests show
later CreateTags and DeleteTags changes.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(ec2): remove tags with their resource and keep node and catalog AMI tags on upgrade

Deleting a volume (directly or as a delete-on-termination volume of a
terminated instance), a snapshot with its image or a VPC peering connection,
and pruning a terminated instance, now removes the resource's tags, both
peering sides included.

The startup migration no longer drops tags it cannot place in a store: a
catalog AMI's tags move to the default region, and an instance's are kept
until its EKS node is found in a region, which then claims them.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(ec2): file a cluster node's legacy tags under its own region

A region-less findInstanceById reaches the EKS provider, which answers from any region, so the claim moved the node's legacy tags under a null region where DescribeTags never finds them. The claim now uses the instance's own region, and with no region known it reads the legacy tags in place for a regional lookup to claim.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

* fix(ec2): pass the region in the query GET resource-tag stub

Signed-off-by: Hector Ventura <hectorvent@gmail.com>

---------

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-19 19:13:38 -04:00
Allen Sanborn 1b89d5da39 fix(storage): skip keys deleted mid-iteration in StorageBackedMap views (#6017)
* fix(storage): skip keys deleted mid-iteration in StorageBackedMap views

The entry iterator walks a key snapshot and each entry's getValue() re-read
storage, so a key deleted after the snapshot made values()/entrySet() yield
null. Callers streaming values() (AutoScaling was patched per-site in #5751;
many other services do the same) then hit NullPointerExceptions.

Fix it once in the map: the iterator looks one element ahead and skips keys
whose value is gone, and entries carry the value read at iteration time.
Because size() is a separate snapshot, the entrySet/keySet/values views now
report unknown-size spliterators; a SIZED stream would otherwise throw
"End size N is less than fixed size M" when a key disappears mid-stream.

* test(storage): cover iterator remove after lookahead, exhaustion and entry setValue

* fix(storage): bind view spliterators lazily at first traversal

The view spliterators wrapped iterator() at spliterator() time, so the key
snapshot was taken when stream() was called rather than when the terminal
operation ran. Collection.spliterator()'s default, which these views used
before, is late-binding. Defer taking the iterator to the first tryAdvance
or split, still reporting unknown size.
2026-10-19 18:21:18 -04:00
andrehoong-px 5774e7db8d feat(cloudformation): support S3 Vectors resources (#5853)
* feat(cloudformation): support S3 Vectors resources

* fix(cloudformation): validate S3 Vectors encryption settings

* fix(cloudformation): align S3 Vectors provisioning contracts

* fix(cloudformation): restore S3 Vectors properties on rollback
2026-10-19 18:16:10 -04:00
Priamo Germosen eba0f72255 fix(iam): check iam:PassRole for ECS, Step Functions, EventBridge and CloudFormation (#5971)
Under IAM enforcement, a request that handed one of these services a role
needed no iam:PassRole on it. A user allowed only ecs:RegisterTaskDefinition
and ecs:RunTask could start a task with any role in the account, and with
ECS task-role credentials on, the task got that role's credentials. The
IAM user guide requires the permission for every role passed to a
service. AWS's Service Reference names the service each operation passes
its role to, and the check now covers these operations as it already
covers Lambda and EC2:

- ECS: RegisterTaskDefinition passes its task and execution roles to
  ecs-tasks.amazonaws.com. RunTask and StartTask pass the task
  definition's roles and any role override, and CreateService,
  UpdateService and CreateTaskSet pass the roles of the task definition
  they name. The infrastructure roles go to ecs.amazonaws.com: a managed
  EBS volume's role, the service role, the load balancer, lifecycle hook,
  Service Connect TLS and VPC Lattice roles, and a Managed Instances
  provider's infrastructure role. A role given by name is the role of
  that name in the caller's account.
- Step Functions: CreateStateMachine and UpdateStateMachine pass roleArn
  to states.amazonaws.com, in a JSON or a CBOR body, gzip-encoded or
  not, since the CBOR endpoint decompresses a body before running it.
- EventBridge: PutRule passes RoleArn, and PutTargets each target's
  RoleArn, to events.amazonaws.com.
- CloudFormation: CreateStack, UpdateStack, DeleteStack, CreateChangeSet
  and ContinueUpdateRollback pass RoleARN when the request names one. A
  later operation that names none reuses the stack's role without the
  check, as CloudFormation does. CreateStackSet and UpdateStackSet pass
  AdministrationRoleARN, or the default
  AWSCloudFormationStackSetAdministrationRole for a self-managed
  StackSet, as the CloudFormation user guide says. An update goes by the
  StackSet's own permission model, which Floci keeps whatever
  PermissionModel the request names.

A role override on RunTask is checked as well as the task definition's
roles, not instead of them, because Floci runs a task with the
definition's task role. The task definition and the StackSet's permission
model are looked up through a new PassedRoleLookup interface, which ECS
and the StackSet service implement, so the filter does not depend on
either service.

Three services are left out. Floci authorizes Cloud Control as
cloudcontrolapi:*, where AWS uses cloudformation:*, so its RoleArn waits
until that namespace is fixed. EventBridge Scheduler and Pipes are REST
services that no IAM route rule maps to an action yet, so enforcement
does not check their requests at all, iam:PassRole included.
2026-10-19 17:07:08 -05:00
Aniket Shukla 5787dac5e8 fix(kinesisanalytics): retry Flink configuration uploads (#6020)
Rebuild archive streams for transient daemon failures using the shared tar copier. Preserve required and optional copy handling, and cover consumed streams, retry exhaustion and startup order without sleeping in tests.
2026-10-19 17:48:45 -04:00
Allen Sanborn fb390968d5 feat(guardduty): support publishing destinations (#6016)
* feat(guardduty): support publishing destinations

Add CreatePublishingDestination, DescribePublishingDestination,
UpdatePublishingDestination, DeletePublishingDestination and
ListPublishingDestinations under /detector/{detectorId}/publishingDestination.
Previously these returned UnknownOperationException, which broke
Terraform's aws_guardduty_publishing_destination.

Destinations are stored per detector through StorageFactory, so they follow
the detector's account and region scoping, survive a persistent-storage
reload, and report PUBLISHING on create (the state Terraform's create waiter
targets). A missing destination returns BadRequestException with the message
the Terraform provider matches for not-found. Deleting a detector removes its
destinations.

clientToken makes create idempotent and is capped at the model's 64
characters, measured in code points as the model's length constraint is.
destinationArn stays optional on create: the GuardDuty model marks
DestinationProperties.DestinationArn and KmsKeyArn as not required
(botocore guardduty/2017-11-28 service-2.json).

The service gains a five-store constructor; the existing three- and
four-store (malware protection plan) constructors delegate to it.

Closes #4983

* docs(guardduty): update the service matrix operation count

* test(guardduty): cover the publishing destination lifecycle through the SDK

Create, describe, update, list and delete an S3 publishing destination
with the AWS SDK v2 GuardDuty client, asserting the shapes as the SDK
reads them, including the required publishingFailureStartTimestamp.
2026-10-19 16:45:15 -04:00
Alessandro Lattao 28799ed352 fix(apigatewayv2): answer an HTTP API's Lambda proxy body it cannot read with 500 (#6012)
* fix(apigatewayv2): answer an HTTP API's Lambda proxy body it cannot read with 500

Review of #5985: the catch at the end of buildProxyResponse still
answered an HTTP API with 502 and the function's output, for example
when isBase64Encoded is set on a body that is not base64.

Measured on HTTP APIs (eu-west-1), with payload formats 1.0 and 2.0:
API Gateway answers 500 with {"message":"Internal Server Error"} a body
that is an object or a list, an isBase64Encoded it cannot read as a
boolean, and a body said to be base64 that does not decode. It reads
isBase64Encoded's text as Go's strconv.ParseBool does: "True", "TRUE",
"t" and 1 are true, "F" and 0 false, and "tRuE", "yes", 2 and 1.5 are
not read. Floci read true, the text "true" and any integer but 0 as
true, so it relayed "True" and "t" bodies undecoded, "yes" ones as
plain text, decoded a body under 2, and answered an object body 200
with an empty body. A number or a boolean body is still its text.

The catch now answers an HTTP API with the same 500 for a result Floci
cannot parse at all; a REST API keeps its 502.

* refactor(apigatewayv2): decode an HTTP API's base64 body once

Review of #6012: the readability check decoded a base64 body that the
response then decoded again, a second decode and array for every
encoded reply. The catch at the end of buildProxyResponse already
answers an HTTP API with 500 and the generic message, so the check now
looks only at the body's shape, and a body said to be base64 that does
not decode fails where it is decoded and reaches that catch.
2026-10-19 16:40:26 -04:00
Allen Sanborn 65e35adf54 feat(backup): add CreateLogicallyAirGappedBackupVault (#6015)
* feat(backup): add CreateLogicallyAirGappedBackupVault

Route PUT /logically-air-gapped-backup-vaults/{name}. The vault shares the
standard vault namespace and ARN shape; DescribeBackupVault reports VaultType
LOGICALLY_AIR_GAPPED_BACKUP_VAULT, VaultState and the retention days. Both
retention values are required, MinRetentionDays >= 7, MaxRetentionDays >= Min.

The vault is locked at creation so the existing retention enforcement applies,
vault-lock put/delete are rejected on it, and ListBackupVaults honours the
vaultType filter.

Closes #4986

* docs(backup): correct the service matrix operation count

* fix(backup): fail a job whose vault was replaced before it completed

A backup job resolved its vault by name at completion. Deleting a
logically air-gapped (or locked) vault while a job was in flight is
allowed, since it holds no recovery point yet; recreating the name as a
standard vault then received the old job's recovery point, which the
unlocked replacement let be deleted inside the original vault's minimum
retention.

Completion now checks, under the vault-name monitor, that the vault
holding the name is the incarnation the job started in. If not, the job
ends FAILED with no recovery point, as it cannot land in a vault that no
longer exists.

* fix(backup): air-gapped vault LockDate at creation; standard vault VaultType BACKUP_VAULT

CreateLogicallyAirGappedBackupVault now sets LockDate to the creation
date, so the vault's lock reads as compliance mode (immutable) rather
than a governance lock with no LockDate. DescribeBackupVault and
ListBackupVaults report VaultType BACKUP_VAULT for standard vaults,
filled at read time so vaults stored with no VaultType are covered.
2026-10-19 16:24:05 -04:00
Aniket Shukla f8ab55f319 feat(sfn): encode HTTP Task object bodies as form data (#6010)
* feat(sfn): encode HTTP Task object bodies as form data

* refactor(sfn): simplify HTTP Task payload encoding

Reuse the shared RFC 3986 URI encoder and remove the unused form payload branch while preserving buffer and no-body requests.
2026-10-19 16:21:02 -04:00
Mario Toffia 87aa6f38a1 feat(iot): publish connection lifecycle events (#5277)
* feat(iot): publish connection lifecycle events

The MQTT broker publishes $aws/events/presence/connected and disconnected
for every session, with its session identifier, certificate principal,
version number and disconnect reason, through topic rules and to
subscribers. Topic filters starting with a wildcard no longer match $ topics,
as on AWS.

Closes #5275

* fix(iot): keep lifecycle events within the reset guard

A lifecycle event admits its topic rules under the rule state at the time
of the event, so one queued before an emulator reset skips them. A
DeleteConnection that wins the session tolerates an endpoint the client's
DISCONNECT already closed.

* fix(iot): serialize session transitions and report keep-alive timeouts

Admission, takeover, DeleteConnection and session end now allocate the
versionNumber and change the session map under one lock, with endpoint
I/O kept outside it. A takeover of an endpoint that is already closed
still accepts the new connection.

A close after a full keep-alive period without a packet from the client
is reported as MQTT_KEEP_ALIVE_TIMEOUT, as AWS IoT does. The WebSocket
upgrade carries the client's port, and the wildcard-first exclusion is
limited to the lifecycle topics, which AWS does not deliver to such
filters while it does deliver shadow topics.

* fix(iot): keep ended sessions out of subscriptions and time keep-alive from CONNECT

* test(iot): drive keep-alive tests from an injected nano-time source

The broker takes a LongSupplier nano-time source, as ReloadingKeyManager
does, so the keep-alive unit tests move a fake clock forward instead of
sleeping. The race test uses ThreadStates.awaitBlockedOrDone.
2026-10-19 16:18:54 -04:00
Alessandro Lattao fcb41966a8 fix(cloudformation): read an ECS task definition's properties as the ECS handler does (#6018)
Measured on CloudFormation (eu-west-1): an AWS::ECS::TaskDefinition gets
no template validation. CloudFormation hands the ECS handler every
scalar as text, and the handler converts each to the type the resource
schema declares: an integer is a sign and digits once trimmed, within
32 bits ("+128", " 128", "0128"), and a boolean is true or false in
lower, upper or title case once trimmed. A value it cannot convert
("abc", 4.5 or true for an integer, "yes", "tRuE" or "1" for a
boolean), and an object, a list and a scalar standing for one another,
fail the resource with every violation of the unconverted model, where
every scalar is a String, so a Memory of 128 is listed beside the value
that failed. At each object its missing required members come first,
then its members in the schema's order. When every value converts, the
required members the model lacks fail it alone, grouped where their
paths meet as the schema validator groups them.

Floci read the properties as plain JSON: a Memory of "abc" and a
container without an image were registered, and an Essential of
"False" registered an essential container.

AWS::ECS::TaskDefinition joins the generated cfn-property-types.json,
whose structures now carry the members the schema requires, read into
RequestShapeModel's shapes. CfnPropertyTypes' walk over the shapes is
shared by the template validation Reader and the new HandlerReader,
which differ in how a scalar converts and in what a mismatch does.
2026-10-19 16:15:05 -04:00
Jimmy Liu Jia 0a510d3510 fix(stepfunctions): override HTTP task user agent (#5995) 2026-10-19 15:52:38 -04:00
Andre Kurait a103b938d2 fix(query): route signed GET requests through the Query dispatcher (#6007)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-19 15:34:33 -04:00
Jackson Price b955aa09ff fix(cloudformation): order leftover deletes by what their attributes reference (#5998)
* fix(cloudformation): infer no leftover order from custom resource data

Leftover ordering read every attribute of a resource the template no
longer names as a reference to what it uses. A custom resource's
attributes are its handler's response Data, which can name a resource
that depends on it, so a custom resource whose Data named a bucket that
DependsOn it was deleted before the bucket. Before leftovers were
ordered, reverse creation order got this right.

A custom resource is now one the dispatcher routes to the generic
handler, and of its attributes only Floci's own __Floci keys, such as
its ServiceToken, count. Custom::DynamoDBReplica has its own provisioner
and keeps the edge its TableName gives. A nested stack's Outputs.* and
an SSM parameter's Value are values passed through, not references, and
no longer order leftovers either.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): order leftovers without recursion

The leftover walk recursed once per link, so a long chain of leftovers,
each naming the next, could overflow the stack. A StackOverflowError is
not an Exception, so it got past the fall back to insertion order and
stopped the delete, cleanup or rollback. The walk now runs on an explicit
stack, with the same memo and the same cut where a cycle closes. Its
test walks 10,000 links on a small thread stack, which the recursive
walk overflows, and waits for it a bounded time.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): keep a leftover's own id from ordering it after a dependent

Some dependents take their parent's id as their own physical id: a
bucket policy is named by its bucket, a secret target attachment by its
secret's ARN. The parent's attribute naming that id then matched the
dependent, so a leftover bucket or secret was deleted before the policy
or attachment that depends on it.

An attribute naming the leftover's own id is no longer a reference, nor
is a resource whose id extends it. A leftover whose id extends another's
past a separator, as parent-1/child-1 does parent-1, goes before that
resource. A bucket policy or secret target attachment goes before
whatever else holds its id, including a bucket or secret the template
still names, whichever of the two was recorded first.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): order a custom resource or nested stack by what it was given

Leftover ordering read no edges from a custom resource's Data or a
nested stack's outputs, which left both with nothing they use. A custom
resource whose properties name a bucket it empties went after that
bucket, and a nested stack whose child created subnets in a VPC the
parent passed it went after the VPC, which then could not be deleted.
A Lambda ServiceToken, an ARN, never matched its function either, whose
physical id is its name.

A custom resource now orders by its resolved properties, with the
function name any Lambda ARN in them gives. A nested stack records the
parameters it passes its child under hidden __FlociUses keys and orders
by those. An SSM parameter's Value is what the parameter was given, as
with Value: !Ref Bucket, so it counts again. The registry now says which
types the generic custom-resource handler serves.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): let a leftover's own id still name another resource

A value equal to a leftover's own id was skipped outright, so a leftover
rule named like the event bus it is on lost its EventBusName edge and
went after the bus, which cannot be deleted while it has rules. Such a
value now skips only the leftover itself and the dependents that take
the same id. A function URL and a cluster's capacity provider
associations also take their parent's id, so they go before it. A
leftover recorded without a type no longer throws on the type check,
which had sent the whole stack back to insertion order.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): order a custom resource or nested stack by the resources it names

Ordering a leftover custom resource by the text of its properties, and a
nested stack by the values of its parameters, also matched literals. A
certificate resource given a domain's name went before the custom domain
that uses the certificate, which then cannot be deleted.

A custom resource or nested stack now keeps, as it is provisioned, the
physical id of each resource its definition names through Ref,
Fn::GetAtt, Fn::Sub or DependsOn, under hidden __FlociUses keys, and is
ordered by those. An update replaces them, and a rolled-back update puts
back the ones from before. Its properties and parameters are no longer
read for this.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): find what a leftover depended on by its logical id too

A custom resource or nested stack keeps the physical id of each resource
its definition names, but an update replaces a resource it only
DependsOn without touching it, so the id it kept goes stale and the
leftover lost that edge. A kept resource now also counts as whatever the
stack holds under its logical id.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): let what a definition named outweigh a shared id

CDK's S3AutoDeleteObjects resource takes its bucket's name as its id and
depends on the bucket and its policy. Left over with both, the bucket's
own name named the custom resource, the own-id rule dropped the policy
the definition named, and the policy counted the custom resource as the
holder of its id it uses, so the bucket went first and its delete failed
on the objects the custom resource would have removed.

What a definition named is now found by logical id and taken as given,
and a resource whose definition named a leftover is its dependent, not
something it uses. A nested stack saved before definitions were kept
orders by its outputs again, as it did then.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* docs(cloudformation): say which leftovers order by their kept uses

A nested stack keeps no uses when its definition names no resource, as
well as when it was saved before uses were kept, and orders by its
outputs either way. A kept use is found by its logical id, its physical
id being a record. A resource whose own definition named a leftover is
skipped by all three inferred rules, not only the value match.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): read no parent from a WAF or custom action type id

A WAFv2 web ACL or IP set has the physical id name|id|scope, and a
CodePipeline custom action type category|Custom|provider|version. Their
first part is their own identity, not a parent's id, yet the leftover
walk read it as the id of a resource they belong to, so a leftover web
ACL sharing a bucket's name was ordered after the bucket. These types no
longer get an edge from a prefix of their own id.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): keep a DependsOn-only change for a later leftover delete

An update that changes only a custom resource's or nested stack's
DependsOn does not re-provision it, so the resources it was kept as
using stayed as they were, and as a leftover it could later be deleted
after a resource it had come to depend on. As an update commits, what
each custom resource and nested stack the template names now names is
kept again. An update that rolls back keeps what was kept before.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): refresh kept uses only for active resources, safely

The refresh as an update commits re-read the definition of a custom
resource or nested stack whose condition had turned false, choosing its
Fn::If branches by conditions it was never provisioned under; if its
cleanup delete then failed, it stayed held with uses it never had. It
also ran where a failure would skip the committed update's cleanup. Such
a resource now keeps what it was provisioned with, and a failure in the
refresh is logged and costs only those keys.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(cloudformation): let provisioners say how their ids name a parent

The leftover walk listed in CloudFormationService which types take their
parent's physical id (bucket policy, secret target attachment, function
URL, capacity provider associations) and which types' ids name no parent
(WAFv2 web ACL and IP set, CodePipeline custom action type). That is
knowledge of how those types are provisioned. Two default hooks on
CfnResourceProvisioner, asked through the dispatcher as for replacement
updates, now let the S3, Secrets Manager, Lambda, ECS, WAFv2 and
CodePipeline provisioners say it for their own types. No behaviour
changes.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(cloudformation): answer the provisioner hooks as production does

The rollback test's stand-in provisioners were plain mocks, so they
answered no to a prefix of a custom resource's id naming its parent,
where a provisioner that overrides nothing answers yes. They now call
the interface's own defaults, the dispatcher test checks a custom type
keeps them, and a static import is back in order.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 15:23:10 -04:00
Jimmy Liu Jia d8064fae14 fix(s3): preserve multipart initiator for private ACL (#5990) 2026-10-19 14:52:29 -04:00
andrehoong-px 1278fea1a4 fix(s3vectors): return modeled fields in list summaries (#5922) 2026-10-19 14:25:04 -04:00
Andre Kurait 0a37ea830b fix(dynamodb): support legacy table discovery and batch cleanup (#5986)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-19 13:30:04 -04:00
Alessandro Lattao e5a206554f refactor(cloudformation): read property types from the vendored resource schemas (#5988)
* refactor(cloudformation): read property types from the vendored resource schemas

Follow-up asked on #5958: the types EventsCfnProvisioner checked a rule
target's members against were written by hand from describe-type, and
LambdaCfnProvisioner named the JSON type of each property it reads. They
now come from src/main/resources/aws/cfn-property-types.json, which
tools/aws/regen_cfn_property_types.py generates from the resource
schemas AWS publishes for us-east-1, in the request shapes' layout so
RequestShapeModel reads it: a structure, list, map or scalar per shape,
and "json" for what a schema leaves free.

The schemas come from AWS's live archive rather than a pinned package.
cfn-lint ships copies, but widens some types: a Lambda environment
variable's value takes any JSON type there and a string in the published
schema, where CloudFormation refuses an object or a list with "Property
[AB] expected type: String, found: JSONObject" (measured). The archive
keeps no older copy, so the generator follows the IAM data's split:
--check is offline and structural and runs on every pull request,
--verify compares a fresh generation with the vendored file and runs in
cfn-schema-drift.yml, weekly and on changes to the file or its generator.

CfnPropertyTypes.Reader walks the vendored shapes instead of type trees,
maps included: a map's values are read as its value shape, and a
mismatch names the key, as CloudFormation does ("Property [h] expected
type: String, found: JSONObject", measured). Every member of a rule
target is now read against its schema type, not only the four #5958
typed, and Lambda reads the properties it already typed through the same
reader, nested members included (VpcConfig.SubnetIds, EphemeralStorage.
Size, ImageConfig.Command, TracingConfig.Mode, Environment.Variables).
The messages for the newly checked members were measured on
CloudFormation (eu-west-1) and are in the tests.

* fix(cloudformation): keep a literal list's blank entries where the template put them

Review of #5988: the reader read every list of strings through the
engine's resolveStringList, which drops blank entries, so a rule
target's HttpParameters.PathParameterValues ["", "b"] became ["b"]
and moved "b" into the first wildcard. CloudFormation passes a literal
list on as written (measured: SecurityGroups ["", "sg-..."] reaches the
target as both). A literal list is now read through the engine's new
resolveLiteralList, which keeps blanks and still expands a list-valued
intrinsic in place; a list an intrinsic yields keeps the engine's
reading. Lambda's literal lists, read through the same reader, keep their
blanks too, for Lambda to judge as on AWS.

resolveLiteralList delegates to the private resolveListElements rather
than opening it: tests that mock the engine and call resolveStringList's
real code would otherwise get the mock's empty list from it, as
IamUserCfnProvisionerTest did.

* refactor(cloudformation): read a launch configuration's MetadataOptions by its schema shape

Review of #5988: #5964, merged after this branch opened, read
AWS::AutoScaling::LaunchConfiguration's MetadataOptions through the type
trees this PR removes. The generator now vendors that resource type too,
and AutoScalingGroupCfnProvisioner reads the block by the shape its
published schema declares (HttpTokens and HttpEndpoint strings,
HttpPutResponseHopLimit an integer, the same types #5964 wrote by hand),
so its tests pass unchanged. The hop limit's type is an anchor of the
generator's offline check.
2026-10-19 12:40:17 -04:00
Aniket Shukla 83147f204e fix(rds): buffer PostgreSQL login responses for PgBouncer (#6005) 2026-10-19 11:48:34 -04:00
Aniket Shukla 2b45288e13 fix(sagemaker): retry model and training archive uploads (#5999)
* fix(sagemaker): retry model and training archive uploads

* test(sagemaker): avoid production backoff in retry tests
2026-10-19 11:23:43 -04:00
TATSUNO “Taz” Yasuhiro 2bb69a030b fix(s3): keep a percent sign in a virtual-hosted object key (#6000)
* fix(s3): keep a percent sign in a virtual-hosted object key

A virtual-hosted request for a key such as a%/b failed with 400 or 500.
The same request in path style worked. S3 stores the key as sent in
both styles.

RESTEasy keeps the decoded path of a rewritten request URI and later
decodes it again. S3VirtualHostFilter now escapes the raw path once more,
so routing sees the same path as a path-style request. The request URI
then decodes to /<bucket> plus the raw path, so the virtual-hosted key
check compares against the decoded path.

Fixes #5997

* test(s3): keep only the percent-key cases that guard the fix
2026-10-19 10:57:03 -04:00
Andre Kurait ca47df9ec5 fix(lambda): preserve Docker provided runtime bootstrap paths (#5974)
Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-19 10:47:58 -04:00
Aniket Shukla 4c9deed379 fix(elbv2): apply duration-based target stickiness (#5978)
* fix(elbv2): apply duration-based target stickiness

* fix(elbv2): honor inherited cross-zone stickiness

* fix(elbv2): simplify target-group stickiness eligibility
2026-10-19 10:23:45 -04:00
TATSUNO “Taz” Yasuhiro 6e5b1569fe feat(lambdaweb): publish the Web Function metrics (#5976)
* feat(lambdaweb): publish the Web Function metrics to CloudWatch

AWS counts a request that reached an environment in ExecutedRequests, also one answered with
Runtime.OriginRequestError or Runtime.RequestTimeout. The status classes count the platform pages too,
except the 400, 404 and 505 pages. Each environment has a datapoint at init, also a failed one, then
one each minute and one when it ends.

* fix(lambdaweb): bound the waiting metric writes and store them before shutdown

* fix(lambdaweb): report each answer before it goes out and build datapoints with MetricDatum.of

A test can then wait for the publisher once and read the metrics without polling. RDS and SES build
their datapoints with the same factory.

* fix(lambdaweb): wait for the metric writes even when their queue is full

The wait now takes the last accepted write instead of a slot in the queue.
The writes run one at a time in order, so once it is done all are.
Only PutMetricData stores a zero timestamp as the current time, so the
MetricDatum.of comment says so.
2026-10-19 10:22:15 -04:00
Mario Toffia c145fa104c fix(ssm): normalize parameter resource ARNs (#5261)
* fix(ssm): normalize parameter resource ARNs

A parameter's ARN is now arn:<partition>:ssm:<region>:<account>:parameter/<name
without leading slash> for both top-level names and paths, matching AWS. Before,
a top-level name such as foo got parameterfoo.

SsmService.parameterResource(name) is the single formula, used by PutParameter
and by the AWS::SSM::Parameter provisioner, so the CloudFormation Arn attribute
equals the GetParameter ARN.

Tag operations and the internal getParameter(nameOrArn, region) read resolve an
ARN to the stored name and, for parameter/x when only x is stored, fall back to x,
so a top-level parameter is found by its ARN, also with a :version or :label
selector. ECS task secrets pass valueFrom to
that read whole instead of stripping only ":parameter". Legacy parameterfoo ARNs
still resolve.

* test(cloudformation): share the CloudFormation Query request builder

Six CloudFormation integration tests each carried a private copy of the
same Query request builder, as cfn or request. CfnRequests.cfn in testing
replaces them, as RdsRequests.rds does for RDS. A null stack name leaves
StackName out, which the ContinueUpdateRollback validation test needs.
2026-10-19 09:46:50 -04:00
Jackson Price e75b15809f fix(autoscaling): honor launch configuration metadata options (#5964)
* fix(autoscaling): honor launch configuration metadata options

CreateLaunchConfiguration ignored MetadataOptions, so
DescribeLaunchConfigurations never returned them and every instance
launched from the configuration got EC2's defaults, HttpTokens=optional
included.

- The Query handler and the AWS::AutoScaling::LaunchConfiguration
  provisioner read the structure, validate it as EC2 does
  (ValidationError for a value outside the allowed set or range) and
  store it. CloudFormation resolves Fn::If and AWS::NoValue inside it.
- DescribeLaunchConfigurations returns the structure with defaults for
  the members left out, and omits it when it was never given.
- The reconciler passes it to every launch, instance refresh
  replacements included.
- Auto Scaling launches from a launch template, directly or through a
  mixed instances policy, and CreateFleet forward the template's
  metadata options, which they dropped before.

Split out of #5671 at review.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): clean up after the launch configuration metadata tests

The metadata tests now delete the groups, launch configurations and
stacks they create, so later reconcileAll calls in the shared test
application stop reconciling leaked groups. They build their
Authorization headers with EnforcementFixtures.auth, and the case that
expects no MetadataOptions first checks that the launch configuration
was found.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(autoscaling): word metadata option errors as Auto Scaling does

CreateLaunchConfiguration refused bad MetadataOptions with EC2's
InvalidParameterValue text under a ValidationError code. It now answers
with Auto Scaling's model-validation text, for example "1 validation
error detected: Value '65' at 'metadataOptions.httpPutResponseHopLimit'
failed to satisfy constraint: Member must have value less than or equal
to 64", and reports every invalid member of the structure in one
error, "N validation errors detected: ...; ...". EC2's validator is no
longer shared.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): refuse list or object launch configuration metadata members

A MetadataOptions member given as a list or an object, such as
HttpTokens: [required], read as an empty string and so as absent: the
launch configuration was created with that member at its default,
HttpTokens=optional included. Such a member now fails the resource with
ValidationError, as the whole structure already does when it is not an
object.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): cover every metadata member in the combined error

The test that sends several invalid MetadataOptions members now makes
all three invalid, so the position of HttpEndpoint in the combined
ValidationError is checked, and confirms that no launch configuration
was created.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): report metadata type errors as CloudFormation does

A launch configuration MetadataOptions block or member of the wrong
JSON type failed with wording Floci made up, such as "HttpTokens must
be a string.". It now fails with CloudFormation's schema type error, as
the S3 and DynamoDB provisioners already report it, for example "Model
validation failed (#/MetadataOptions/HttpTokens: expected type: String,
found: JSONArray)". A value of the right type that Auto Scaling rejects
keeps Auto Scaling's ValidationError.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): report an oversized metadata hop limit as out of range

A whole-number HttpPutResponseHopLimit too large for an int, such as
2147483648, failed with the contradictory "expected type: Integer,
found: Integer". It is an integer outside 1 to 64, so it now fails with
the same Auto Scaling ValidationError text as 65 or 0, with the value
as written.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): count an oversized hop limit with the other metadata errors

An oversized CloudFormation HttpPutResponseHopLimit was refused before
the other MetadataOptions members were checked, so an invalid
HttpTokens beside it went unreported, and the value was echoed as
written, "+002147483648" included. Auto Scaling now builds the whole
error from the options and the hop limit as a BigInteger, so the
oversized value is counted with every other violation and printed as
a plain number.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(autoscaling): build metadata option errors through SmithyValidationErrors

The launch configuration MetadataOptions validator assembled its "N
validation errors detected" message by hand. It now uses
SmithyValidationErrors, which main adopted for Auto Scaling's other
checks. The error code and text are unchanged.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(cloudformation): read launch configuration metadata through CfnPropertyTypes

The MetadataOptions reader had its own type check and answered every
wrongly typed value with the handler's "Model validation failed"
message. It now reads the block through CfnPropertyTypes, as the Events
and Lambda provisioners do:

- a value of the wrong type fails template validation first, for
  example "Property [HttpTokens] expected type: String, found:
  JSONArray", and a hop limit of 4.5 is "found: Float";
- a hop limit beyond 32 bits fails the handler's model validation,
  before Auto Scaling's own check runs;
- a number or a boolean given for a string member arrives at Auto
  Scaling as its text, as CloudFormation converts it, and fails its
  enum check there.

The hand-written type helpers go away.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* refactor(autoscaling): fold the metadata options error back into its validator

The public metadataOptionsError took the hop limit as a BigInteger so
that CloudFormation could report a value beyond 32 bits through it.
CloudFormation now refuses such a value in model validation, before
Auto Scaling, so the helper goes back to a private validator over the
Integer field. The error code and text are unchanged.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): delete the launch template the metadata test creates

Ec2LaunchTemplateMetadataOptionsIntegrationTest never deleted its
launch template, and its cleanup began only after the fleet or group
had launched, so an earlier failure left everything behind. Everything
after the template is created now runs in the try block, and the
finally block removes the group or the instance and then the template,
ignoring the status so a test's own failure is kept.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(ec2): check template metadata options before a CreateFleet dry run

A launch template stores its metadata options unchecked, as AWS does,
so they fail at launch. CreateFleet forwards them to the launch since
this branch, but a dry run returned DryRunOperation before any launch
ran, saying a fleet would succeed that then fails with
InvalidParameterValue. CreateFleet now checks every launch's metadata
options with the rest of its pre-launch checks, as RunInstances does
before honoring DryRun.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(autoscaling): pin the Query answer for a hop limit beyond 32 bits

CreateLaunchConfiguration with MetadataOptions.HttpPutResponseHopLimit=
2147483648 answers MalformedInput, as for any value that is not a
32-bit integer: the awsQuery protocol binds the member before model
validation runs. A row now covers it beside the non-numeric case.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-19 09:42:58 -04:00
Aymen JAMAAOUI 09b14e9d10 fix(s3): check the extra IAM actions a CreateBucket needs (#5961)
* fix(s3): check the extra IAM actions a CreateBucket needs

A CreateBucket whose headers configure the new bucket needs more than
s3:CreateBucket, as the CreateBucket API reference lists:

- s3:PutBucketAcl for a canned ACL other than private, or a grant header
- s3:PutBucketObjectLockConfiguration and s3:PutBucketVersioning for
  x-amz-bucket-object-lock-enabled: true
- s3:PutBucketOwnershipControls for x-amz-object-ownership

S3Controller now checks these actions before the bucket is created, so
a denied request creates nothing.

* chore(s3): move the CreateBucket header actions next to the object ones

S3ObjectActions.bucketCreationActions now gives the actions a
CreateBucket needs from its headers, and reuses GRANT_HEADERS.
EnforcementFixtures.putUserPolicy replaces the test's own PutUserPolicy
helper.
2026-10-19 09:30:22 -04:00
Huan Jiang 3a913ca8d6 fix(s3): ignore hoisted upload checksum query parameters (#5977)
* fix(s3): ignore hoisted upload checksum query parameters

* fix(s3): ignore hoisted multipart checksum types
2026-10-19 09:30:12 -04:00