Commit Graph
102 Commits
Author SHA1 Message Date
Alessandro Lattao 63af5cd299 fix(cloudformation): pass a function's LoggingConfig to Lambda (#5902)
* fix(cloudformation): pass a function's LoggingConfig to Lambda

The AWS::Lambda::Function provisioner never read LoggingConfig, so every
function a stack created logged in Text to /aws/lambda/<name>, whatever
the template said, and an update to it was never applied.

Measured on AWS (eu-west-1, 2026-10-16): the function reads back the
LogGroup the template names; a change to JSON with an ApplicationLogLevel
updates it in place, SystemLogLevel reading back INFO; and removing the
property from the template puts the function back on Text and
/aws/lambda/<name>, again in place. So the provisioner always sends a
LoggingConfig, empty when the template has none, which Lambda resolves to
the function's defaults (JSON for a durable function, which refuses
Text).

The update check compares what Lambda would store, through the same
LambdaService.loggingSettings that UpdateFunctionConfiguration applies,
so an unchanged LoggingConfig is still a no-op redeploy and the two
cannot drift apart.

Tests: the stack lifecycle in CloudFormationLambdaLoggingConfigIntegrationTest
and, through the SDK clients, CloudFormationLambdaLoggingConfigTest, both
failing on main; the normaliser in LambdaServiceTest. The compatibility
suite gains TestFixtures.awaitStackTerminal for the new test rather than
another private copy of the stack wait.

* fix(cloudformation): refuse an invalid log level before comparing LoggingConfig

The update check compared normalised logging settings, and the normaliser
dropped both log levels under Text before anything validated them. An
update whose only change was an invalid level, ApplicationLogLevel VERBOSE
on a Text function, then looked unchanged, never reached
UpdateFunctionConfiguration, and the stack went UPDATE_COMPLETE where
AWS fails the update. LambdaService.loggingSettings now runs
validateLoggingConfig before it normalises, so the comparison refuses
what Lambda refuses, and applyLoggingConfig validates once, through it.

The integration test registers its stacks' deletion with PartitionCleanup,
and the compatibility test's cleanup no longer swallows a failed
DeleteStack, which succeeds for a stack that is already gone.
2026-10-18 00:47:18 -04:00
Jackson Price f22c2a4db1 feat(cloudformation): support SAM's optional AutoPublishAlias version properties (#5823)
* feat(cloudformation): support SAM's optional AutoPublishAlias version properties

With AutoPublishAlias, read the three function properties SAM uses to
shape the version it publishes:

- AutoPublishCodeSha256: a string names the version by its first ten
  characters instead of the hash, so new code under the same value
  publishes nothing. A Ref to a parameter resolves first.
- AutoPublishAliasAllProperties: the hash covers every property the
  transform gives the function, plus its SnapStart.
- VersionDeletionPolicy: the version's DeletionPolicy when the
  function sets none; a function with a CapacityProviderConfig
  defaults to Delete, any other to Retain. An intrinsic value is
  copied unresolved, as SAM copies it.

Each gets SAM's type checks and messages: AutoPublishCodeSha256 must
be a string and make an alphanumeric id, AutoPublishAliasAllProperties
a boolean, and VersionDeletionPolicy Delete or Retain, only with
AutoPublishAlias.

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

* test(cloudformation): pin the default Ref hash and AutoPublishAliasAllProperties coverage

Keep the check that a Ref in the code changes the version id without
AutoPublishAliasAllProperties, and show that with it a Timeout change
names a new version and false hashes as if the property were absent.
Pin that an AutoPublishCodeSha256 Ref resolving to an empty value
leaves the hash in place. The docs say that ids under
AutoPublishAliasAllProperties are floci's own and that a Ref to a
parameter works for AutoPublishCodeSha256.

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

* fix(cloudformation): refuse AutoPublishCodeSha256 in SAM Globals

SAM refuses a Globals property it does not list for a section, and
Globals.Function does not list AutoPublishCodeSha256. Now that the
property names the version, merging it from Globals would give every
function the same version id, so a code change would never publish.
Refuse the template with SAM's message, without the list of supported
properties that SAM appends.

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

* test(cloudformation): pin the AutoPublishAliasAllProperties ids and SAM version updates

Pin two version ids under AutoPublishAliasAllProperties to the SHA-1 of
the generated function's properties, worked out by hand, and that a
given AutoPublishCodeSha256 still names the version there. Show that
Globals.Function carries AutoPublishAliasAllProperties and
VersionDeletionPolicy. On a stack, a Timeout change under
AutoPublishAliasAllProperties publishes version 2 with the new timeout,
and VersionDeletionPolicy: Delete reports the replaced version
DELETE_COMPLETE instead of DELETE_SKIPPED. An intrinsic
VersionDeletionPolicy is copied unresolved, which the assertion now
says.

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

* docs(cloudformation): say when a new SAM version id publishes

Say which statements about the version id hold by default, that
AutoPublishCodeSha256 outranks AutoPublishAliasAllProperties and cannot
come from Globals, and when a new id publishes nothing: SnapStart, a new
AutoPublishCodeSha256 alone, or, under AutoPublishAliasAllProperties, a
Tags or ReservedConcurrentExecutions change, which AWS fails with "A
version for this Lambda function exists". A hot-reloaded function
publishes for every new id. State the DeletionPolicy order, and that
CloudFormation takes intrinsic functions only in resource properties,
outputs, metadata and update policies. The javadocs of the version id
and of AutoPublishAlias say the same.

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

* docs(cloudformation): note IgnoreGlobals and LanguageExtensions for SAM versions

Say that floci does not honour IgnoreGlobals, so a function cannot opt
out of a VersionDeletionPolicy in Globals, and that an intrinsic
VersionDeletionPolicy reaches CloudFormation only through a transform
such as AWS::LanguageExtensions, which floci does not implement. Under
AutoPublishAliasAllProperties the code's parameter references are still
resolved, and any SnapStart change publishes nothing.

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

* test(cloudformation): pin the SnapStart id under AutoPublishAliasAllProperties

Pin the id a SnapStart with ApplyOn None gives under
AutoPublishAliasAllProperties, worked out by hand like the others, and
show that a version VersionDeletionPolicy: Delete reports deleted is
still listed, as the docs say floci keeps every version it publishes.

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

* docs(cloudformation): say that IgnoreGlobals is the opt-out floci ignores

A function can still clear a Globals VersionDeletionPolicy with a null
of its own; what floci does not honour is IgnoreGlobals.

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

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-17 14:04:04 -04:00
Alessandro Lattao e12b878b77 fix(cloudformation): resolve Fn::GetStackOutput as CloudFormation does (#5848)
* fix(cloudformation): resolve Fn::GetStackOutput as CloudFormation does

Fn::GetStackOutput was not implemented, and an intrinsic the template
engine does not know falls through to the node's text, which for an
object is "". A weak cross-stack reference, which aws-cdk-lib synthesizes
as Fn::GetStackOutput, therefore deployed CREATE_COMPLETE with an empty
string wherever the value was used.

The engine now resolves it through a StackOutputResolver that
CloudFormationService answers as DescribeStacks would in the referenced
account and Region, and the YAML parser maps the !GetStackOutput short
form. Every rule follows what CloudFormation does, measured in eu-west-1,
where that departs from the function's reference page: a missing stack
or output fails the resource and the stack rolls back, an output that
cannot be read rolls the stack back once the resources exist, an output
whose Condition is false is never read, a dynamic reference reaches
DescribeStacks unresolved, and the function is refused in Conditions and
inside Fn::ImportValue when the operation is requested, AWS::Include
fragments included. A RoleArn has to name an existing role: Floci runs
no stack operation under an execution role, so, as AssumeRole does with
IAM enforcement off, its trust policy is not evaluated.

* fix(cloudformation): refuse Fn::GetStackOutput in export names and nested stacks as AWS does

Answers the review of #5848, each point measured on CloudFormation in
eu-west-1 on 2026-10-17.

An output's Export.Name holding Fn::GetStackOutput is refused when the
operation is requested, with "Template format error: Output O is
malformed.  The Name field of Export must not depend on any resources,
imported values, or Fn::GetAZs.", so it never reaches execution. A
nested stack's template is checked when the child is created: the Child
resource fails with the template error and the parent rolls back.

A dynamic reference inside an Fn::Sub variable map of the function's
arguments is left as written too: CloudFormation hands it to
DescribeStacks unresolved, which refuses the name. The engine suspends
dynamic references while it resolves the arguments.

An output that cannot be read now logs the stack and the output before
the rollback, and the placement check skips only a template that does
not parse or an AWS::Include that fails, which the operation reports
where it processes them.

* fix(cloudformation): check a Fn::GetStackOutput role's trust and permissions under IAM enforcement

With IAM enforcement on, a RoleArn only had to name an existing role, so a
stack could read another account's outputs through any role there,
whatever the role trusted. GetStackOutputRoleAuthorizer now decides the
role as AssumeRole and AppSyncDataSourceAuthorizer do: its trust policy
has to allow a principal in the consuming account, and its policies,
through IamPolicyEvaluator, have to allow cloudformation:DescribeStacks
on the referenced stack. The refusals carry the messages measured on
CloudFormation: STS's AccessDenied, and DescribeStacks' for the
GetStackOutput session. With enforcement off nothing changes.

Which principal CloudFormation acts as is not known in Floci, which runs
stack operations under no execution role and keeps no caller, so a grant
to any principal of the consuming account is enough: its root, or any
principal of it the policy names, such as the CDK's execution role.
That question is AssumeRolePolicyEvaluator.allowsAnyPrincipalOf, built on
its own decide(), so the trust policy is parsed and evaluated in one
place.

Reuse instead of copies: the tests use EnforcementFixtures.auth, a new
EnforcementFixtures.createRole overload taking the trust policy, and
PartitionCleanup, and the two GetStackOutput tests share their stack and
parameter helpers. The placement checks find the function with
JsonNode.findValues instead of three hand-written walks, and the
resolveOutputValue wrapper of resolve() is gone.
2026-10-17 09:09:24 -04:00
Alessandro Lattao 197ccb5fb7 fix(cloudformation): refuse an update that has nothing to change (#5849)
* fix(cloudformation): refuse an update that has nothing to change

UpdateStack ran a full update for a stack resubmitted as it was, ending
UPDATE_COMPLETE, and CreateChangeSet created an AVAILABLE change set for
it. CloudFormation refuses the update with "No updates are to be
performed." and creates the change set FAILED, UNAVAILABLE, with "The
submitted information didn't contain changes. Submit different
information to create a change set."; the CDK and aws cloudformation
deploy read that reason as "no changes".

What CloudFormation compares was measured in eu-west-1: each active
resource's Type, Properties, Metadata, DeletionPolicy, UpdateReplacePolicy
and UpdatePolicy, and each active output's Value, Description and Export,
with whatever does not depend on a resource resolved first, and the tags
as a set (absent Tags keep the stack's). ComparedTemplate brings a
template to that form: a new Description, an unused parameter, a
DependsOn or a literal written as Fn::Join is no change, while a used
mapping value, a Ref of a resource rewritten as Fn::Sub, or a dynamic
reference whose stored value moved is one. Templates are compared as
processed, AWS::Include fragments read again and the SAM transform
applied with the stack's parameter values, and a stack with a nested
stack is always updated. The change set diff uses the same form.

The CDK deletes the FAILED change set and deletes it again by name
before its next deploy, so DeleteChangeSet now answers success for a
change set the stack does not have, as CloudFormation does. A stack set
instance whose stack has nothing to change is left as it is. Tests that
resubmitted an identical template to exercise an update add an output
through CfnUpdates.forceUpdate, which is an update on AWS too.

* fix(cloudformation): record dynamic reference values when an operation commits

Answers the review of #5849.

The value each dynamic reference resolved to is now recorded when the
stack's operation commits, from the template the stack then has and
keyed as ComparedTemplate hands the references over, instead of while
the engine provisioned each resource. Recording and comparison so see
the same strings, an Fn::Sub that also reads a resource included; an
update that fails and rolls back records nothing and keeps the last
deployment's values; a reference the template dropped is dropped; and
AWS::RDS::DBInstance's master credentials, which its provisioner
resolves itself with ssm-secure, are compared like any other reference.
The values are kept as an HMAC-SHA256 under a random key of the stack's
own rather than a bare SHA-256.

ComparedTemplate keeps an AWS::NoValue inside a function it compares as
written, and gives the array form of Fn::Sub the static variable
substitution the string form has, its own variables left as written.

A stack set instance with nothing to change succeeds whatever status an
earlier rolled-back update left its stack in, and the change set that
found it so is deleted. DeleteChangeSet by a change set's ARN alone
succeeds when the change set is gone, as measured on CloudFormation in
eu-west-1 on 2026-10-17.

The comparison now catches only what it can meet: a template that does
not parse, and the AwsException an AWS::Include, the SAM transform or an
SSM parameter raises, which the update itself then reports.
2026-10-16 21:53:03 -04:00
Jackson Price 3cb1643d30 fix(cloudformation): publish content-hashed versions for SAM AutoPublishAlias (#5744)
* fix(cloudformation): publish content-hashed versions for SAM AutoPublishAlias

Point the alias AutoPublishAlias generates at the Version attribute of
the generated AWS::Lambda::Version, as SAM does, instead of $LATEST,
and name that version as SAM names it: <Function>Version plus the
first ten hex digits of the SHA-1 of the function's code, with
template parameters resolved as a Ref or as ${Name} in an Fn::Sub,
merged with its Environment and MemorySize, as sorted compact JSON
escaped the way Python's json.dumps escapes it. Under
AutoPublishAliasAllProperties the hash covers every property floci
gives the function. A string AutoPublishCodeSha256 takes the hash's
place with its first ten characters. As in SAM, the version is
retained (DeletionPolicy: Retain) unless the function says otherwise,
and version properties of the wrong type are refused.

With the alias on the published version, a template change to the
code names a new version resource, which publishes, and the alias
moves to it, while changes made to $LATEST outside the stack no longer
reach the alias. The $LATEST pin worked around #1987 and #1988: a cold
invoke of a published version timed out, and a warm $LATEST container
served version-qualified invokes. Both are fixed on main.

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

* fix(cloudformation): hash an applied SnapStart into the SAM version id

SAM adds a function's SnapStart to the hash behind the AutoPublishAlias
version's logical id when its ApplyOn is anything but None, so turning
SnapStart on names a new version, which publishes and gets its
snapshot. Without it a SnapStart function got a different id than SAM
gives it, and changing SnapStart published nothing. Under
AutoPublishAliasAllProperties SnapStart is hashed like the other
properties.

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

* refactor(cloudformation): resolve SAM destination types with parameterValue

destinationType repeated the parameter lookup parameterValue already
does for the version hash: the stack's value, else the Default. Use the
one helper. A non-string Default still names no destination type.

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

* docs(cloudformation): describe the SAM version hash in SAM terms

Reword the comments and test names around the AutoPublishAlias version
id to state what SAM and CloudFormation do, rather than how another
project or language implements it.

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

* fix(cloudformation): hash a null SnapStart ApplyOn and state what it changes

SAM leaves SnapStart out of the version hash only when ApplyOn is
missing or "None"; a null ApplyOn is hashed. The check read a null as
"None".

floci does not pass SnapStart to the function, so turning it on
changes the version's logical id but publishes no new version, and
no snapshot is taken. 44eae301d said it publishes; the docs and the
comment now say what happens.

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

* docs(cloudformation): say which characters the SAM version hash escapes

Characters outside printable ASCII are hex escapes except where JSON
has a short escape, such as a newline's, and SnapStart is hashed only
when it sets an ApplyOn other than None.

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

* refactor(cloudformation): leave the optional SAM version properties to their own change

Take AutoPublishCodeSha256, AutoPublishAliasAllProperties and
VersionDeletionPolicy, with their validation, docs and tests, out of
the AutoPublishAlias fix so they can follow as their own change. The
transform no longer reads them, as on main: each is ignored, never
refused, and none changes the version's logical id or its
DeletionPolicy. The CapacityProviderConfig default goes with
VersionDeletionPolicy.

The fix keeps the alias on Fn::GetAtt of the version's Version, the
hashed version id over the code, Environment, MemorySize and an
applied SnapStart, and the version's default DeletionPolicy: Retain.

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

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-16 07:07:51 -04:00
TATSUNO “Taz” Yasuhiro 0492fc9842 feat(lambdaweb): CloudFormation types for Lambda Web Functions (#5722)
* feat(lambdaweb): CloudFormation types for Lambda Web Functions

AWS::Lambda::WebFunction, AWS::Lambda::WebFunctionRevision and
AWS::Lambda::WebFunctionEndpoint provision through the resource
registry. Ref of each is its ARN. Every property of a revision is
createOnly in the registry schema, so a changed revision mints a new one
and the displaced revision is deleted once the update commits. An
endpoint keeps its identity while its function, name, type and regions
stay the same. Fn::GetAtt on RegionalEndpoints is recorded as a gap.

Part of #5699

* fix(lambdaweb): compare a revision against the function's default log group

revisionMatches filled a request without a log group with the existing
revision's log group, so a template that dropped a custom log group kept
the old revision. The default is the function's log group, as when a
revision is created. replaceTags returns the updated function.

* fix(cloudformation): put a Lambda Web function or endpoint back after a failed stack update

A function's tags and an endpoint's mutable configuration are changed in
place on update. The provisioner now snapshots them before the change and
restores them from rollbackUpdate, as the other in-place provisioners do.
The function attributes after a tag update come from the updated
function, so UpdatedAt moves with the tag change.

* test(cloudformation): roll a Lambda Web stack update back after a failed revision

A revision that fails to create after the endpoint moved to a replaced
revision rolls the stack back. The endpoint returns to the kept revision
and the replacement is deleted. The doc page says that a CloudFormation
endpoint is always Disabled with RevisionWeights, since the schema has no
AutoDeploymentMode, and that a failed update puts in-place changes back.

* fix(cloudformation): refuse AutoDeploymentMode on a Lambda Web endpoint

The registry schema has no AutoDeploymentMode property and AWS fails a
template that sets it at validation. An endpoint from CloudFormation is
always Disabled and routes by RevisionWeights. Floci passed the property
through to the service, which accepted LatestRevision.

* refactor(lambdaweb): share the create and tag steps between the API and CloudFormation paths

createFunction and createFunctionShell both check the name and refuse a
duplicate under the function's lock. tagResource and replaceTags both
check the tags, lock, write, stamp and persist. Each pair now calls one
private helper, so the two paths cannot drift.
2026-10-15 19:02:50 -04:00
Jackson Price 945f5d3995 fix(cloudformation): restore SSM parameters on failed updates (#5752)
A stack update that changed an AWS::SSM::Parameter and then failed on a
later resource ended in UPDATE_ROLLBACK_FAILED with the new value left
in place: the provisioner had no rollback.

An update that keeps the name now keeps the parameter's value, settings
and managed tags before it writes, and the rollback writes them back as
a new version unless the parameter still holds them. A changed Name
creates the replacement and leaves the displaced parameter to the
shared ReplacementCleanup record: a committed rename deletes it unless
UpdateReplacePolicy is Retain, a rollback deletes the replacement, and
ContinueUpdateRollback retries a restore or delete that failed. A
snapshot is spent when the update commits, and one a skipped rollback
left is dropped when the next update starts.

A create or replacement is one PutParameter without overwrite that
carries the tags, as AWS's handler sends it, so a name held outside the
stack fails the resource instead of being overwritten or adopted; a
dispatcher stub's id is taken over by a create. As AWS's handler checks
that the parameter exists before an update writes it, a parameter
deleted outside the stack fails the update in place, and a rollback
that finds it gone, with ParameterNotFound. A delete treats
ParameterNotFound as already deleted.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-15 18:27:31 -04:00
Jackson Price ad8fba7f45 fix(cloudformation): evaluate conditions with intrinsics, require parameter values (#5737)
* fix(cloudformation): require a value for every declared parameter

CreateStack, UpdateStack and CreateChangeSet accepted a template that
declares a parameter with no Default when the request gave it no value.
The stack deployed with the parameter unset: a condition compared it as
an empty string, and a Ref resolved to the parameter's own name.

Such a request now fails with ValidationError "Parameters: [Env] must
have values", naming every such parameter in declaration order, before
the SAM transform and the dependency preflight run and before any stack
state changes. An empty value counts as a value. An update does not
carry values over, so it needs a value or UsePreviousValue, which keeps
the deployed one, for each parameter without a Default.
UsePreviousValue on a parameter with no deployed value passes none,
rather than an empty string. A request its stack refuses outright, an
update of a stack that is missing or cannot be updated or a create over
a name in use, still gets that refusal. A parameter that an AWS::Include
defines, which only execution merges, is not checked up front.

The same check refuses CreateStackSet and UpdateStackSet, before the
stack set changes or an operation is recorded. UpdateStackSet resolves
UsePreviousValue against the previous template's Defaults too, since a
stack set keeps only the values it was given. A nested stack resource
whose Parameters leave a child parameter without a value fails, before
the child is created or changed. Those Parameters now resolve as a
property value: an Fn::If may choose the whole map, and an AWS::NoValue
value passes nothing.

A CreateStackInstances whose targets cannot be resolved, or whose
change set is refused, now ends its operation FAILED. Left RUNNING, it
refused every later operation on the stack set.

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

* fix(cloudformation): evaluate conditions through the template engine

Conditions resolved only a bare Ref, and only to a parameter, the
account or the region. Every function other than that Ref compared as
an empty string inside Fn::Equals: Fn::FindInMap, a Ref to
AWS::StackName or AWS::StackId, Fn::Join. A condition on a mapped value
or on the stack's own name was decided wrongly, so the wrong resources,
or none, were created.

The operands now resolve through the template engine, with the
template's Mappings and the stack's name and id. The change-set preview
and the dependency preflight evaluate against the stack too: the live
one an update targets, or the name a create takes, whose id does not
exist yet. An operand the engine cannot resolve compares as an empty
string, as every function did before, so a template that evaluated then
still does. A declared parameter that a stack stored by an older Floci
lacks still compares as an empty string, and AWS::NotificationARNs is
the empty list, now in properties and outputs too.

CloudFormation does not allow Fn::ImportValue in a condition, so a
template being deployed with one there is refused with "Template error:
Cannot use Fn::ImportValue in Conditions.", also in an operand that
evaluation never reaches. A SAM template's change set, or its stack,
fails with that reason instead. A stored template compares the import
as an empty string, so it never blocks an update that supplies a new
template; UsePreviousTemplate checks the stored one as it would a new
one.

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

* fix(cloudformation): check a create's dependencies with its stack id

A create's dependency preflight evaluated AWS::StackId as an empty
string while the execution used the stack's id, so a dependency on a
resource whose condition reads the stack id could pass the preflight
and then fail the deploy, or the other way round. A create over a name
in use was checked against the stack holding the name instead, and
could get a dependency error rather than AlreadyExistsException.

createChangeSet now allocates the new stack's id before the preflight
and creates the stack with it, so the preflight, the change-set preview
and the execution evaluate the same id. An update, or a create that
attaches to a REVIEW_IN_PROGRESS placeholder, is checked against that
stack as before, and a create over a name in use is checked as the new
stack it asks for.

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

* docs(cloudformation): place the parameter check before dependency checks

The parameter section said template errors such as a dependency cycle
come first, but createChangeSet checks the parameter values before the
dependency checks, which evaluate conditions that read those values.
Say so, and keep the stack's own refusal ahead of both.

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

* docs(cloudformation): order the stack's refusal after dependency errors

The previous commit said the stack's own refusal comes ahead of both
the parameter check and the dependency checks. It comes ahead of the
parameter check only: a request its stack refuses still gets a
template's dependency error first, as on main. Say so, and re-wrap the
conditions paragraph.

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

* docs(cloudformation): say parameter values are checked before dependency errors

The parameter section still read as if a template's dependency errors
came first. createChangeSet checks the parameter values before the
dependency checks, which evaluate conditions that read the values, so
a template with a cycle and a missing value gets the parameter error.
Say that, and that a stack's own refusal replaces the parameter error
but still follows a dependency error.

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

* test(cloudformation): pin a missing value ahead of a dependency cycle

A template with both a DependsOn cycle and a parameter without a value
gets "Parameters: [Env] must have values" and creates no stack.

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

* refactor(cloudformation): name the tolerated parse failures ignored

requireParameterValues and parametersWithDefaults return when the
template does not parse, as intended: there is nothing to check or to
add, and the preflight and the execution report the parse error. Name
the caught exception ignored and say why, as AGENTS.md asks.

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

* refactor(cloudformation): say only execution reports a parse failure

The comment on the ignored parse failure in requireParameterValues
said the preflight reports it too. The dependency preflight skips a
template that does not parse; only executing the change set reports
the error.

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

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
2026-10-15 16:56:00 -04:00
Allen Sanborn 1e423420ed fix(ec2): resolve a NAT gateway's network interface and mark its Elastic IP associated (#5622)
* fix(ec2): resolve a NAT gateway's network interface and mark its Elastic IP associated

CreateNatGateway gave each gateway address a networkInterfaceId of
"eni-" + randomHex(17), but nothing else knew about that interface:
DescribeNetworkInterfaces had no NAT arm, so the id DescribeNatGateways
publishes (aws_nat_gateway.network_interface_id) answered
InvalidNetworkInterfaceID.NotFound. The Elastic IP the gateway took was
also never marked associated, so DescribeAddresses showed a held
allocation as free.

The interface id is now derived from the gateway id, as endpoint ENIs
are, and DescribeNetworkInterfaces reports one requester-managed
nat_gateway interface per gateway address, built from the stored
address so the two reads cannot disagree. CreateNatGateway records the
association, interface and private address on the allocation (no
instanceId), and DeleteNatGateway clears them if the association is
still the gateway's.

* fix(ec2): refuse a NAT gateway on an occupied Elastic IP, keep its association, scope its ENI lookup to the account

CreateNatGateway rejects an allocation already held by an instance or another gateway
(Resource.AlreadyAssociated) under the lock that writes the association. DisassociateAddress
rejects an association owned by a NAT gateway. The NAT arm of DescribeNetworkInterfaces reads
gateways and subnets for the account asked about.

* fix(ec2): lock NAT gateway EIP release, treat a legacy gateway's EIP as held

DeleteNatGateway releases the Elastic IP under the lock CreateNatGateway
takes. CreateNatGateway also refuses an allocation any live gateway
references, covering gateways persisted before Address records were
marked. The CloudFormation networking test gives the replacement NAT
gateway a new EIP: replacement creates before it deletes, and AWS's
CreateNatGateway refuses an EIP still associated elsewhere.

* fix(ec2): AssociateAddress refuses a NAT gateway's Elastic IP; legacy gateways hold theirs

AssociateAddress checks for a gateway holding the allocation and writes
under the allocation lock CreateNatGateway and DeleteNatGateway take, so
an instance cannot take over an address the gateway still claims. The
gateway scan behind that check, and CreateNatGateway's, now includes
unmigrated pre-account-isolation gateway records for the default
account, never another account's.

* fix(ec2): scope NAT gateway ownership checks to the caller's records

callerNatGateways scanned every account's gateways before filtering. Read
the caller's own records, plus unprefixed legacy records only for the
default account.

* fix(ec2): create a NAT gateway failed on an Elastic IP already in use

CreateNatGateway with an allocation another gateway or an instance holds
no longer answers 400. As the NatGateway shape documents, the gateway is
created in state failed with FailureCode Resource.AlreadyAssociated and
FailureMessage "Elastic IP address <alloc> is already associated". It
gets no interface, claims nothing, and does not count as a holder.
AWS::EC2::NatGateway fails the resource and deletes the failed gateway.

ReleaseAddress on an allocation a NAT gateway holds, legacy gateways
included, answers InvalidIPAddress.InUse. DisassociateAddress and
ReleaseAddress run under privateIpAllocationLock. The NAT interface lookup
reads legacy unprefixed gateways and subnets for the default account. It
also loads the interface's tags, and DeleteNatGateway deletes them.
endpointEniId and natEniId become one helper, eniIdFromSeed.

* test(cloudformation): say why the replacement template keeps NatEip

The replacement template keeps NatEip for two reasons. On AWS a gateway
given an Elastic IP the displaced gateway still holds is created failed.
And Floci update cleanup deletes removed resources before the old copies
of replaced ones, so dropping the EIP while replacing its gateway would
try to release it while it is still held.

* fix(ec2): a failed NAT gateway does not pin its subnet or VPC

#5503 made DeleteSubnet and DeleteVpc refuse while a NAT gateway that is
not deleted sits in the subnet. A failed gateway was never created and
holds no interface, so it no longer counts, matching the Elastic IP
holder check.
2026-10-15 13:53:49 -04:00
danielxoi fa682b2d62 fix(cloudformation): clean up, roll back and delete AWS::EC2::VPC like the other EC2 types (#5503)
* fix(cloudformation): clean up, roll back and delete AWS::EC2::VPC like the other EC2 types

A CidrBlock change, or a tenancy change other than dedicated to default,
replaces the VPC, but the provisioner never recorded the displaced one and had
no delete arm, so the old VPC was left behind; in-place Tags, EnableDnsSupport
and EnableDnsHostnames changes were not snapshotted, so a later failing
resource left the VPC changed and reported rollback as not implemented.

Ec2VpcCfnProvisioner now follows Ec2NetworkCfnProvisioner: ReplacementCleanup
records the displaced VPC and deletes it after the update commits or restores
it on rollback; a prior-state snapshot restores DNS attributes, tags and a
dedicated-to-default tenancy change on rollback, eagerly when provision itself
fails; and a delete arm through CfnDeletes.safeDelete removes the VPC on stack
teardown, tolerating only InvalidVpcID.NotFound so stack-external dependents
fail the delete with DependencyViolation, as on AWS.

* refactor(cloudformation): use the shared CfnRollback.guarded in the VPC provisioner

* fix(ec2): count instances and NAT gateways as subnet and VPC dependents

DeleteSubnet and DeleteVpc checked subnets, security groups, route tables,
ACLs, gateways and endpoints but not the instances and NAT gateways living in
a subnet, so a stack teardown could remove a subnet and its VPC out from under
an instance launched into it out of band. Both now fail with
DependencyViolation while an instance that is not terminated (shutting-down
still holds its interface) or a NAT gateway that is not deleted sits in the
subnet, as on AWS. The rollback integration test also pins Boom after the VPC
with DependsOn so the scenario cannot pass by ordering alone.

* fix(cloudformation): keep the VPC and subnet rollback snapshot until the restore succeeds

rollbackUpdate removed the in-place snapshot before restoring; a restore that
threw left the resource persisted as UPDATE_FAILED with no prior state for a
ContinueUpdateRollback retry. Ec2VpcCfnProvisioner and the pre-existing
Ec2NetworkCfnProvisioner now restore first and remove after, as the AgentCore
provisioner already did. The describeTags loop shared by Ec2Tags.reconcile and
the VPC snapshot moves to Ec2Tags.current.

* fix(ec2): count standalone network interfaces and interface endpoints as subnet dependents

A subnet is pinned by any network interface in it, not only the ones an
instance or NAT gateway owns: a standalone interface from
CreateNetworkInterface and an interface or Gateway Load Balancer endpoint
keep DeleteSubnet at DependencyViolation on AWS too. The endpoint test that
deleted a subnet out from under a live endpoint relied on that state being
reachable; it now asserts the refusal and that the published interface ids
are unchanged.

* fix(cloudformation): wait for terminated on instance delete and resolve VPC properties before creating

With real containers an instance is still shutting-down when the stack's
instance delete returns, so the subnet delete that follows was refused by the
new resident check and the stack ended DELETE_FAILED. The instance provisioner
now polls until the instance is terminated or gone, as CloudFormation does.

The VPC provisioner created the VPC before EnableDnsSupport, EnableDnsHostnames
and Tags were resolved, so a resolution failure left it untracked; the resolves
now run first, as the subnet provisioner does. Ec2Tags.current drops reserved
aws: keys so a rollback snapshot never tries to write one, and the replacement
integration test waits in the stack's own region.
2026-10-15 11:14:56 -04:00
XuJian 7f8383db38 feat(cloudformation): provision SES email identities (#4812)
* feat(cloudformation): provision SES email identities

* fix(cloudformation): retry pending SES update rollback

* fix(cloudformation): keep recovered SES resource complete

* fix(cloudformation): retain recovered SES state on failed replacement

* test(cloudformation): use shared waiter for SES DKIM verification
2026-10-15 10:26:40 -04:00
David ad1b225591 feat(cloudformation): apply AssociatedRoles on RDS clusters and instances (#5656)
* feat(cloudformation): apply AssociatedRoles on RDS clusters and instances

AWS::RDS::DBCluster and AWS::RDS::DBInstance ignored AssociatedRoles,
so a CDK DatabaseCluster with s3ImportBuckets deployed with no role on
the cluster.

The roles are now associated when the resource is created, through the
same checks as AddRoleToDBCluster and AddRoleToDBInstance; a list RDS
refuses fails the resource and deletes the new database. An update adds
the roles the template gained and removes the ones the previous
template declared and this one drops, so a role associated outside the
stack is kept. An Aurora cluster member carrying its own
AssociatedRoles is a ValidationError, as the schema calls the property
not applicable there. addRolesToNewDbCluster now also refuses a role
named twice in its own list.

Closes #5638

* fix(cloudformation): follow AWS on repeated roles, and check before changing a database

A renamed instance's predecessor was deleted before the new instance
took its roles, so a refused list left neither; the roles now go on
first. The property is resolved before it is read, so Fn::If around the
list or an entry works and AWS::NoValue leaves it out, and any other
value that is not a list is a ValidationError rather than "no roles".

Repeated roles follow AWS's handlers: an instance skips a role or
feature already associated (AWS ignores DBInstanceRoleAlreadyExists),
while a cluster's list is checked first on an update too, and a role
the template newly declares is always added, so one attached by hand
fails the update with DBClusterRoleAlreadyExists. A rolled back cluster
replacement also restores the record of which roles the stack declared.

* fix(cloudformation): undo a failed role update's own changes

An update changed roles one at a time, so when a later step was
refused the roles it had already added stayed on the database while
the stack restored its old record, and a retry failed on them with
DBClusterRoleAlreadyExists. A refused step now removes the roles the
update added and puts back the ones it removed before the error is
reported. The cluster check also takes the template's engine, now that
it checks feature names, and the roles record reader catches only the
JSON parse error.
2026-10-15 06:59:49 -04:00
Mario Toffia a5228a0bf7 fix(cloudformation): apply TimeToLiveSpecification on DynamoDB tables (#4951)
* feat(dynamodb): add typed time-to-live operations to the table access

DynamoDbTableAccess gains timeToLive and updateTimeToLive next to the
stream operations. The native engine reads the TTL flag and attribute
from the table definition and calls DynamoDbService.updateTimeToLive
under the scope's account; the Local engine sends DescribeTimeToLive
and UpdateTimeToLive.

* fix(cloudformation): apply TimeToLiveSpecification on DynamoDB tables

An AWS::DynamoDB::Table declaring TimeToLiveSpecification reached
CREATE_COMPLETE while DescribeTimeToLive answered DISABLED, because the
provisioner never read the property.

The provisioner now reconciles TTL against what the table reports, so
UpdateTimeToLive is called only when the setting differs: enabled turns
it on, Enabled false or a block removed on an update turns it off with
the current attribute name, and renaming an enabled attribute fails with
the DynamoDB ValidationException before anything changes. Enabled with
no AttributeName fails with ValidationError before the table is created.

An in-place table update now records the tags, stream and TTL setting
it replaces, and rollbackUpdate puts all three back, so a stack whose
update fails on a later resource ends UPDATE_ROLLBACK_COMPLETE instead
of UPDATE_ROLLBACK_FAILED. A restore that throws keeps the snapshot.

* fix(cloudformation): roll back and clean up failed DynamoDB table provisions

A table's in-place update that failed after its snapshot, for example on
UpdateTimeToLive after the tags and the stream had changed, lost the
snapshot: the engine put the previous resource back and reported
UPDATE_ROLLBACK_COMPLETE with the changes still live. The provisioner
now retains a failed attempt that carries its snapshot, so the engine
hands it to rollbackUpdate. A failure before the snapshot changed
nothing and still uses the engine's restore.

A provision that failed after createTable left the new table behind,
on create and on a replacing update alike. The provisioner now deletes
a table this attempt created, tolerating ResourceNotFoundException, and
never one it adopted or updates in place. A delete that fails is logged
and leaves the physical id and the rollback ownership marker, so the
stack's create rollback retries it. A table recreated because the
update target was gone takes no snapshot, since it has no prior state.

* fix(cloudformation): match the AWS status reasons for invalid TimeToLiveSpecification

Renaming an enabled TTL attribute and enabling TTL without an
AttributeName now fail with the handler message AWS CloudFormation
reports, as measured in eu-west-1, and with its InvalidRequest handler
error code. The resource status reason is the AWS inner text exactly;
the type and logical id prefix are gone, since AWS does not include them.

* fix(cloudformation): scope DynamoDB table TTL to the stack and validate Enabled

- An update leaves TTL alone when neither the template nor the previous
  one declared TimeToLiveSpecification, so TTL enabled outside the stack
  survives, as on AWS.
- A TimeToLiveSpecification without Enabled, or with a non-Boolean one,
  fails model validation before the table is created.
- A replacing update whose created table cannot be deleted reports a
  rollback failure naming the table instead of leaving it untracked.
2026-10-14 15:57:36 -04:00
Mario Toffia c4a809f47f feat(cloudformation): refuse updates after a failed rollback and add ContinueUpdateRollback (#4949) 2026-10-14 08:01:54 -04:00
XuJian f6c8ebd5a0 feat(cloudformation): provision Scheduler schedules (#4834)
* feat(cloudformation): provision Scheduler schedules

* fix(cloudformation): track schedule move destination ownership

* fix(cloudformation): preserve failed schedule deletion cleanup

* fix(cloudformation): guard Scheduler schedule cleanup ownership

* fix(cloudformation): verify Scheduler ownership before replacement

* fix(cloudformation): omit conditional Scheduler properties

* fix(cloudformation): share optional resolution and delete cleanup hooks

* fix(cloudformation): address Scheduler schedules by group and name

* fix(cloudformation): reject malformed Scheduler cleanup entries

* fix(cloudformation): align Scheduler replacement cleanup with main
2026-10-14 07:47:29 -04:00
Nazimuddin Tajuddin Basha daef71ca76 feat(guardduty): add Malware Protection plans and AWS::GuardDuty::MalwareProtectionPlan (#5373)
* feat(guardduty): add Malware Protection plans and AWS::GuardDuty::MalwareProtectionPlan

Adds CreateMalwareProtectionPlan, GetMalwareProtectionPlan,
UpdateMalwareProtectionPlan, DeleteMalwareProtectionPlan and
ListMalwareProtectionPlans, and routes plan ARNs through the shared tag
operations.

Adds a CloudFormation provisioner for AWS::GuardDuty::MalwareProtectionPlan.
Ref and Fn::GetAtt MalwareProtectionPlanId return the plan id, and Arn,
CreatedAt, Status and StatusReasons are set. Role, object prefixes, the
tagging action and tags update in place; a different BucketName is rejected
because the update API cannot change the bucket.

Management plane only: no scan runs, so a plan stays ACTIVE.

Closes #4657

* fix(guardduty): address review findings on Malware Protection plans

- Apply a plan update all-or-nothing: validate every supplied field before
  storing any, so a rejected request no longer changes the role.
- Page ListMalwareProtectionPlans by the last returned id instead of an
  offset, so deleting a plan between pages neither fails nor skips, and use
  the documented default page size of 100.
- Restore a plan on a failed CloudFormation stack update from a snapshot
  taken before the first change, and delete a plan an update created in
  place of one deleted out of band.
- Clear ObjectPrefixes and Actions on a stack update that drops them.
- Apply the creation tag rules to the shared tag routes.
- Require the role to be an IAM role ARN.
- Use explicit types instead of var.

* style(guardduty): import ArrayList instead of fully qualified name

* test(cloudformation): wire GuardDuty into CfnProvisionerFixture

CfnProvisionerFixtureTest requires every provisioner to be reachable through a public Builder setter. Add a guardDuty(...) setter that registers GuardDutyMalwareProtectionPlanCfnProvisioner.

* fix(guardduty): address second review round on Malware Protection plans

- Rolling back a stack update that recreated a plan deleted out of band now
  restores the prior plan's Arn, CreatedAt, Status and StatusReasons, not only
  its id, so Fn::GetAtt no longer names the deleted replacement. The
  out-of-band test now changes the plan's properties: unchanged resources are
  skipped on update, so it never reached the create before.
- Plan tag keys are checked against GuardDuty's documented TagKey pattern
  (^(?!aws:)[a-zA-Z+-=._:/]+$) on creation and on TagResource.
- The tag routes require the supplied ARN to equal the stored plan's ARN, so
  a matching plan id under another account, service or partition is
  ResourceNotFoundException.
- The /malware-protection-plan routes move behind a @PreMatching filter that
  rewrites only guardduty-signed requests to /_guardduty, as DlmRouteFilter
  does, so path-style S3 requests for a bucket of that name reach S3.

* style(guardduty): import Instant and List, drop em-dash, document the plan route

Review on #5373: GuardDutyController used an inline java.time.Instant and its
Javadoc carried an em-dash, which AGENTS.md rules out. The Javadoc's routing
paragraph now names /malware-protection-plan next to /detector and /admin and
says GuardDutyRouteFilter keeps a same-named S3 bucket reachable. The
CloudFormation and plan integration tests import List and nullValue instead of
spelling them out.

* refactor(core): share signed-service route rewriting across DLM, GuardDuty and Resource Explorer 2

DlmRouteFilter, GuardDutyRouteFilter and ResourceExplorer2PathRewriteFilter each
repeated the same path test, credential-scope check and rewrite. They now
delegate to SignedServiceRoute in core.common.

The helper also reads the signing service from the X-Amz-Credential query
parameter when there is no Authorization header, as ServiceEnabledFilter does
(which now uses the same lookup), so a query-signed plan request reaches
GuardDuty instead of S3.

A request sent straight to an internal prefix that is not signed for the
service is refused as S3 refuses that bucket name, rather than reaching the
service's routes. Resource Explorer 2's prefix moves from /re2 to /_re2, since
re2 is a valid bucket name.
2026-10-13 13:17:16 -04:00
Vũ Thế Huy b8e628356c feat(cloudformation): provision ElastiCache serverless caches (#5423)
* feat(cloudformation): provision ElastiCache serverless caches

Add the AWS::ElastiCache::ServerlessCache provisioner on top of the serverless cache API, with dotted Endpoint.* and ReaderEndpoint.* Fn::GetAtt attributes, in-place modification, rejected immutable changes and replacement on rename.

* fix(cloudformation): reject a malformed NoPasswordRequired on ElastiCache users

* fix(cloudformation): restore serverless cache settings on a failed update and reset removed ones

* refactor(elasticache): inject ElastiCacheService once into the serverless service

* fix(cloudformation): replace a serverless cache on its create-only properties

Register AWS::ElastiCache::ServerlessCache in create-only-properties.json so a
change to ServerlessCacheName, SubnetIds, KmsKeyId or SnapshotArnsToRestore is
reported as a replacement instead of being applied in place or ignored.

Share one Docker availability probe across the ElastiCache integration tests and
validate the tag count in one place in ElastiCacheServerlessService.

* fix(cloudformation): reject custom-named serverless cache replacement on create-only properties

* fix(cloudformation): simplify serverless create-only update check and share replacement error
2026-10-13 13:00:16 -04:00
XuJian ebae2ba0e0 feat(cloudformation): provision Cognito resource servers (#4832)
* feat(cloudformation): provision Cognito resource servers

* fix(cloudformation): align rollback tests with deletion cleanup

* fix(cloudformation): abandon exhausted Cognito replacement cleanup

* fix(cloudformation): verify Cognito resource server ownership

* test(cognito): use switch expression for ownership writers

* fix(cloudformation): share optional resolution and delete cleanup hooks

* fix(cognito): use resource server API addresses for stack lifecycle

* fix(cloudformation): avoid repeated Cognito cleanup on stack deletion

* fix(cloudformation): keep consumed resource server cleanup removed

* fix(cloudformation): abandon exhausted Cognito cleanup

* test(cloudformation): cover Cognito resource servers with AWS SDK

* fix(cloudformation): validate Cognito scopes and replace missing servers

* refactor(cloudformation): keep Cognito resource server change scoped
2026-10-12 23:20:09 -04:00
danielxoi f50437efba feat(cloudformation): provision AWS::BedrockAgentCore::Runtime, RuntimeEndpoint and Memory (#5226)
* feat(cloudformation): provision AWS::BedrockAgentCore::Runtime, RuntimeEndpoint and Memory

The AgentCore control plane is emulated but had no CloudFormation provisioner,
so the three types fell through to the generic stub that exposes only Arn and
a template using Fn::GetAtt [Memory, MemoryArn] in an IAM policy failed the
stack. BedrockAgentCoreCfnProvisioner maps every template property the
services can store onto CreateAgentRuntime / CreateAgentRuntimeEndpoint /
CreateMemory, publishes Ref as the registry schema's primaryIdentifier and
Fn::GetAtt for every read-only property, updates in place when the
create-only properties are unchanged and replaces otherwise, and deletes on
stack teardown. Properties the emulated services have no model for are logged
once at warn and listed in the docs.

* fix(cloudformation): make AgentCore updates rollback-aware and authoritative

Reachable through CfnProvisionerFixture (two-service inference arm). In-place
updates snapshot the prior runtime, endpoint and memory configuration and tags,
restore them on rollback, and delete a created entity when a later step of the
same provision fails. The template is authoritative: UpdateAgentRuntime replaces
the full configuration as AWS's PUT does (omitted authorizer, protocol and
environment are cleared on the SDK path too), and the partial-update Memory and
Endpoint calls get a replace-omitted overload for the provisioner. Nested
AWS::NoValue members are omitted rather than stored blank, and the control
service validates networkMode and serverProtocol with the API's
ValidationException wording.

* fix(cloudformation): accept AGUI runtimes and share the guarded provision helper

The protocol check left out AGUI, which the AgentCore API and the Runtime
schema allow, so an AG-UI runtime was refused through the API and in a stack.

Ec2NetworkCfnProvisioner and BedrockAgentCoreCfnProvisioner carried the same
guarded helper; it now lives on CfnRollback, taking the provisioner's
in-place undo as a callback, and both use it.
2026-10-12 21:38:57 -04:00
Jay aff6f0eec4 fix(cloudformation): expand a SAM function's EventInvokeConfig (#5524)
* fix(cloudformation): expand a SAM function's EventInvokeConfig

SAM's EventInvokeConfig was dropped, so a function declaring retries, a maximum
event age or invoke destinations deployed with Lambda's defaults and no
destination at all. It now expands as AWS's SAM translator expands it: an
AWS::Lambda::EventInvokeConfig on $LATEST or the AutoPublishAlias alias, the
inline role policy for each destination, the SQS queue or SNS topic SAM creates
for a destination given only its Type, and SAM's conditions and error messages.

The function's Condition, DeletionPolicy and UpdateReplacePolicy now reach every
resource generated for it, as SAM passes them through. A condition naming another
with anything but a string is rejected as CloudFormation rejects it, which also
fails the template SAM produces for a conditional function with a conditional
destination, as on AWS.

* fix(cloudformation): resolve SSM parameters for the SAM transform and omit NoValue destinations

CloudFormation resolves an AWS::SSM::Parameter::Value<String> parameter before it
runs the SAM transform, so a destination Type taken from one is the stored value.
The transform now gets the given parameter values over each Default, with
SSM-typed parameters read from Parameter Store, wherever it runs.

A Destination of AWS::NoValue passes through SAM unchanged and leaves its side
without an ARN, which CloudFormation's validation rejects. The event invoke config
provisioner resolved it to an empty string and stored that; it now omits
AWS::NoValue, so the destination fails as the schema requires.

* refactor: share SHA-1 as Digests.sha1

The SAM transform's generated condition names, EC2 key pair fingerprints and
the SAML assertion name qualifier each made their own one-shot SHA-1 digest.
They now share Digests.sha1 beside sha256. Also moves samTransformParameters
above resolveSsmParameters' Javadoc, which it had been inserted beneath.
2026-10-12 18:34:39 -04:00
lex00 991bf3ab9e fix(autoscaling): round-trip InstanceMaintenancePolicy, AvailabilityZoneDistribution, CapacityReservationSpecification, ServiceLinkedRoleARN, WeightedCapacity and EnabledMetrics (#5513)
* fix(autoscaling): round-trip InstanceMaintenancePolicy, AvailabilityZoneDistribution, CapacityReservationSpecification, ServiceLinkedRoleARN, WeightedCapacity and EnabledMetrics

DescribeAutoScalingGroups dropped several members of the AutoScalingGroup shape
that CreateAutoScalingGroup and UpdateAutoScalingGroup accept, so a client that
set them read them back as absent and saw a permanent diff.

- AsgOptionalFields gains ServiceLinkedRoleARN, InstanceMaintenancePolicy,
  AvailabilityZoneDistribution and CapacityReservationSpecification with its
  CapacityReservationTarget. The four-argument constructor stays, so existing
  call sites are unchanged.
- MixedInstancesPolicy launch template overrides carry WeightedCapacity.
- EnableMetricsCollection and DisableMetricsCollection are implemented, and
  DescribeAutoScalingGroups reports EnabledMetrics.
- Validation follows the botocore model. MinHealthyPercentage 0 to 100 and
  MaxHealthyPercentage 100 to 200, both required, at most 100 apart, and -1
  on both clears the policy. CapacityDistributionStrategy and
  CapacityReservationPreference enums. No target with preference none.
  CapacityReservationIds 1 to 255 characters matching [A-Za-z0-9-_/] and
  resource group ARNs 1 to 1600. ServiceLinkedRoleARN 1 to 1600 characters.
  WeightedCapacity 1 to 999 in at most 32 characters, set on every override
  or none. Granularity required and 1Minute. Known metric names only.
- The AWS::AutoScaling::AutoScalingGroup provisioner passes the new properties
  and MetricsCollection through, and its update rollback snapshot restores
  them. It requires CapacityReservationPreference and each entry's
  Granularity as the resource schema does, and rejects an unknown metric
  before creating the group.
- The Java SDK compatibility suite gains a round-trip case that sets every
  new member, reads it back through DescribeAutoScalingGroups, then clears
  the maintenance policy and the enabled metrics.

* fix(autoscaling): route the metrics collection actions and close the review gaps

EnableMetricsCollection and DisableMetricsCollection now route to Auto
Scaling when a request carries no credential scope. Both hold the group
lock, so concurrent calls keep each other's changes and a call racing a
delete cannot write the group back.

A failed stack update now clears the service-linked role, AZ
distribution and capacity reservation when the group had none before.
A blank ServiceLinkedRoleARN or WeightedCapacity in a template reaches
the service's validation instead of reading as unset. The provisioner
reuses the service's granularity rule and message.
2026-10-12 16:26:44 -04:00
Vũ Thế Huy 86b32584f3 feat(cloudformation): provision ElastiCache users and user groups (#5422)
* feat(cloudformation): provision ElastiCache users and user groups

Add AWS::ElastiCache::User and AWS::ElastiCache::UserGroup provisioners with authentication mode handling, create-only UserName, membership deltas, engine changes and replacement on rename.

* fix(cloudformation): address review findings for ElastiCache users and user groups

- Require Engine property when provisioning AWS::ElastiCache::User

- Reject invalid and conflicting AuthenticationMode combinations

- Add setUserGroupMembers to atomically update group membership under lock

- Require UserIds property when provisioning AWS::ElastiCache::UserGroup

- Snapshot and restore User and UserGroup on stack update rollback

- Tighten replaced subnet group deletion assertion in integration test

* refactor(elasticache): share user authentication and user group update logic

Move the AuthenticationMode / Passwords / NoPasswordRequired decision into
UserAuthentication so the query handler and the CloudFormation provisioner
no longer duplicate it. Make modifyUserGroup and setUserGroupMembers share
one locked update path, and drop the concurrency test that passed without
the lock.
2026-10-12 14:28:27 -04:00
Mario Toffia e8a300f4d5 fix(cloudformation): roll back a changed custom resource (#4941)
When a stack update sent a custom resource's handler an Update and the
update then failed, Floci never told the handler. If a later resource
failed, the rollback recorded "Rollback is not implemented for
Custom::..." and the stack ended UPDATE_ROLLBACK_FAILED with the
handler's change still applied. If the handler failed its own Update,
Floci put the previous resource back in silence. In both cases
CloudFormation sends the handler a second Update with the previous
properties so it can undo the change.

CustomResourceCfnProvisioner now snapshots the resource before an
Update reaches its handler: the prior physical id, the old and the
attempted properties, the region and the Data attributes, under the new
CUSTOM_RESOURCE_UPDATE_SNAPSHOT_ATTR. A stale snapshot from an earlier
update is dropped first, so an update that sends nothing needs no
rollback. The ServiceToken is checked as Lambda's Invoke checks it
before the snapshot is written, so an Update rejected before it reaches
any handler is restored as before and sends no rollback request. While
the snapshot is held, retainsFailedUpdateState answers
true, so an Update the handler failed keeps its copy for the rollback
walker instead of being restored over. Its rollbackUpdate spends the
snapshot:

- the physical id was kept: report UPDATE_IN_PROGRESS and send Update
  with the old properties as ResourceProperties and the attempted ones
  as OldResourceProperties, under the same physical id and stack id. On
  SUCCESS the Data attributes are replaced by the response's. A
  response naming another id is taken, and the id that was sent gets a
  best effort Delete with the attempted properties at once, since Floci
  has no rollback cleanup phase.
- the handler replaced the resource: send a best effort Delete for the
  new id with the attempted properties and point the resource back at
  the old id and attributes, with no Update. CloudFormation sends this
  Delete in its cleanup phase; Floci sends it during the rollback.

The old properties become the resource's own before the handler is
called, as on AWS, which treats the rollback target as the resource's
properties even when the handler fails it: a later DeleteStack sends
them in its Delete and the next update sends them as
OldResourceProperties. A FAILED answer throws with the handler's
Reason, so the resource is UPDATE_FAILED and the stack
UPDATE_ROLLBACK_FAILED, as on AWS, and the snapshot stays so a retry
sends the same Update again.
2026-10-12 11:34:24 -04:00
Alessandro Lattao 85e0061a6f feat(cloudformation): provision AWS::ApiGatewayV2::DomainName and ApiMapping (#5038)
* refactor(apigateway): move the v2 domain and API mapping rules into the service

CreateDomainName and CreateApiMapping on /v2/domainnames kept their rules in
ApiGatewayController: the one-configuration check, the refusal of inputs Floci
does not emulate, the flattening onto the shared custom-domain store, the API
and stage existence check, the mapping key conflict check, the API type the
mapping is routed as, and the mapping id. A CloudFormation provisioner cannot
reach a controller, so it would have had to copy them.

They now live in ApiGatewayService. createV2DomainName validates the body and
creates the domain; createApiMapping checks the API and stage, refuses a key
that is taken and routes the mapping as the API's protocol type; getApiMapping,
deleteApiMapping and apiMappingId follow. ApiGatewayService takes
ApiGatewayV2Service for the API and stage lookup, so the whole rule sits in one
place and a caller needs one service. Nothing on the v2 side depends on the v1
service, so this adds no cycle. Leaving the lookup in ApiGatewayV2Service was
tried first, but then every caller had to resolve the API before calling into
ApiGatewayService, and the rule was split across two classes again.

The code is moved, not rewritten: messages, error codes, the order of the
checks and the id scheme are unchanged, and the controller delegates.

* feat(cloudformation): provision AWS::ApiGatewayV2::DomainName and ApiMapping

Both types were left to the stub arm. A stack reported CREATE_COMPLETE, but no
domain or mapping existed, Fn::GetAtt on the domain resolved to literals such
as DomainResource.RegionalDomainName (so a Route 53 alias built from it pointed
nowhere), and with allow-stub-unsupported-resource-types off the stack rolled
back.

ApiGatewayV2DomainCfnProvisioner creates them through the v2 rules in
ApiGatewayService and injects only that service. Ref on a domain is its name
and Fn::GetAtt returns DomainNameArn, RegionalDomainName and
RegionalHostedZoneId as GetDomainName reports them. Ref on a mapping is its
ApiMappingId, which is also its only attribute.

Updates follow AWS. DomainName is the only createOnly property of either type,
and everything else changes in place: the domain's configuration is replaced as
a whole, as DomainNameConfigurations is on AWS, and a mapping's ApiId, Stage and
ApiMappingKey change without a new id. To keep the id across a key change, a
mapping now stores the apiMappingId it was given instead of deriving it from
its key on every read. A record persisted before is still read under the
derived id, and a new mapping gets the id it always had unless another mapping
holds it. Deriving the id and documenting the difference was the first version;
it was dropped because Ref changed where AWS keeps it, and the change set
already reported the key change as an update.

A replacement creates the new entity and leaves the displaced one to
ReplacementCleanup, so it is deleted in UPDATE_COMPLETE_CLEANUP_IN_PROGRESS,
kept under UpdateReplacePolicy: Retain, and put back when a later resource
fails the update. The first version deleted the old domain inside provision, as
the v1 provisioner does, and a failed rename then ended in
UPDATE_ROLLBACK_FAILED with the original domain and its mappings already gone.
A mapping moved to another domain gets an id the displaced mapping does not
hold, since two mappings under one physical id cannot be told apart, and the
domain of each displaced id is recorded beside the cleanup. An in-place update
snapshots what it changes, so a failed stack update restores it instead of
ending in UPDATE_ROLLBACK_FAILED.

CDK templates needed the v2 rules to match AWS in two more places.
apigateway.DomainName with a multi-level basePath maps a REST API through
AWS::ApiGatewayV2::ApiMapping, so a mapping now accepts a REST API stage. And
the restrictions AWS documents for API mappings are enforced, in the API and in
templates alike: no v2 call on an edge-optimized domain, with AWS's message;
TLS_1_2 for an HTTP API or a multi-level key, which also keeps such a domain on
TLS_1_2; no WebSocket API beside an HTTP or REST API; and AWS's key characters
and length.

The id-only delete accepts <ApiMappingId>|<DomainName>, the type's primary
identifier, which is how Cloud Control names a mapping; a bare id still answers
NotFoundException, so Cloud Control cannot report a delete that did not happen.
The integration test deploys two templates aws-cdk-lib 2.272.0 synthesized,
checked in with the app that produced them, and compat-cdk deploys the same
shapes.

* fix(apigateway): answer v2 domain and API mapping calls as API Gateway does

The review of this PR found four places where Floci answered differently
from API Gateway. Each was measured against API Gateway in eu-west-1 on
2026-10-04, with an imported certificate on a throwaway domain.

An HTTP API custom domain is regional. CreateDomainName and
UpdateDomainName with an endpoint type of PRIVATE, or one API Gateway does
not know, give a REGIONAL domain, where Floci refused the first and stored
the type on an update. EDGE is refused with "EDGE endpoint type is not
supported for APIGatewayV2 domainName", not the message for v2 calls on an
existing edge-optimized domain.

API mapping keys are checked as API Gateway checks them, with its messages:
a key does not end with '/', does not start with '/' or hold '//', holds
letters, digits and $-_.+!*'(), between its levels, and is at most 300
characters. No key, an empty one, or on a create one of whitespace only, is
the root; an update refuses whitespace only. Floci took "/" for the root and
had its own message for the characters, without the comma.

UpdateApiMapping and UpdateDomainName answer over the v2 HTTP API, not only
from CloudFormation. What an UpdateApiMapping leaves out keeps its value.

Cloud Control identifies an AWS::ApiGatewayV2::ApiMapping by the type's
primary identifier, <ApiMappingId>|<DomainName>, while CloudFormation's Ref
stays the bare id: CloudControlService derives the identifier from the
desired state, as it already names primary identifier fields by type, and
the provisioner deletes by it with the create-time attributes too.

* fix(apigateway): refuse a v2 update of an edge domain, and recover a compound identifier whole

The second review pass found three gaps in the previous commit.

UpdateDomainName through the v2 API converted a v1-created edge-optimized
domain to REGIONAL. The v2 API does not manage an edge-optimized domain, so
the update is refused with the message every other v2 call on one gets, and
the CloudFormation in-place update goes through the same check.

A v2 UpdateDomainName without a configuration returned the domain unchanged
without looking at the rest of the body, so a mutual TLS request was
silently dropped. ApiGatewayService.updateV2DomainName now refuses what
Floci does not emulate, and the edge-optimized domain, either way.

Cloud Control's recovery of a create that finished just before a restart
took the identifier after the last '|' of its key, which for an API
mapping's <ApiMappingId>|<DomainName> left only the domain. It now takes
everything after the key's third separator.

A later review pass found four more points.
UpdateApiMapping fills in what its body leaves out under the lock the update
takes, so two partial updates of one mapping cannot write back each other's
old values. A v2 domain's certificate is stored as the v1 API's regional
certificate, which is what a regional domain reports through both APIs; a
domain the v2 API wrote before still reports the one it holds until its
configuration is replaced. The domain ARN both APIs and both CloudFormation
provisioners build comes from ApiGatewayService.domainNameArn, the Cloud
Control test waits with the awaitSuccess helper main has since gained, and
requireMappingAllowed's javadoc is back on it.
2026-10-12 11:28:04 -04:00
Anders Wasen bfa9c2fbcc feat(cloudformation): provision Application Auto Scaling targets and policies (#5407)
* feat(cloudformation): provision Application Auto Scaling targets and policies

AWS::ApplicationAutoScaling::ScalableTarget and ::ScalingPolicy had no
provisioner, so a template that scales an ECS service failed on those two
resources although the Application Auto Scaling service behind them, including
the ECS capacity adjuster, was already there. This wires the two together.

A scalable target has no name of its own: it is keyed by the triple of service
namespace, resource id and scalable dimension, and CloudFormation's Ref is those
three joined by a pipe. That composite is the physical id, which is also what a
policy's ScalingTargetId carries when a template points one at the other with
Ref, so the provisioner splits it back into the triple. A policy's Ref is its
ARN rather than its name, so deleting one resolves the ARN through
findPolicyByArn to recover the name and triple the service deletes by.

Because the target's id is derived from the triple, changing any part of it
replaces the target rather than updating it, so both types go through
ReplacementCleanup to deregister what they displaced. Deletes tolerate only
ObjectNotFoundException through CfnDeletes.safeDelete: a target takes its own
policies with it, so a stack teardown reaches an already-deleted policy by
ordinary ordering, while any other failure still surfaces as DELETE_FAILED.

The properties each schema marks required are enforced rather than defaulted.
MinCapacity and MaxCapacity on a target, and PolicyName and PolicyType on a
policy, would otherwise register a target that never scales or accept a template
CloudFormation itself rejects.

The two scaling configuration blocks are parsed by the same code the
PutScalingPolicy API path uses, extracted to ScalingConfigurationParser, since
CloudFormation spells their members exactly as the API does. One parser means a
template and an API call cannot disagree about what a policy means.

ScheduledActions on a target is logged rather than dropped silently: Floci does
not run scheduled scaling, and a template that scales on a clock should not look
fully provisioned when nothing is scheduled.

* fix(cloudformation): resolve intrinsics inside the scaling configuration blocks

Review on #5407: the two scaling configuration blocks and SuspendedState reached
the parser as raw template JSON, so an intrinsic inside one was never resolved.
That is worse than it sounds, because an intrinsic is still a non-null node:
hasNonNull passes and the value is read with asDouble, asText or asBoolean,
which answer 0, "" and false. A policy written as TargetValue: !Ref TargetCpu
registered as a policy targeting 0 percent rather than failing, a ResourceLabel
built with Fn::Join arrived empty, and a flag behind Fn::If read false.

Each block now goes through ctx.engine().resolveNode first, which is what
AutoScalingScalingPolicyCfnProvisioner already does with its own block. Only
nested objects were affected: the top-level properties were already read through
ctx.resolveOptional, which resolves.

A target's Tags were dropped as well, passed to the service as an empty map
rather than read with ctx.resolveTags.

ScheduledActions now carries a note in the generated resource-type table rather
than only a warning in the log, so the gap is visible before someone wonders why
their clock-based scaling never fires.

* test(cloudformation): make the SuspendedState intrinsic test fail without its fix

Review on #5407: anIntrinsicInsideSuspendedStateIsResolvedToo passed against the
previous commit too. REFS had no Suspend entry, so the flag resolved to an empty
string and read false either way, and assertNotNull held regardless because the
raw block was already an object. The test pinned nothing.

REFS now maps Suspend to true and the assertion is on
isDynamicScalingInSuspended(), so it fails with expected: <true> but was:
<false> when SuspendedState is read without resolveNode. The redundant copy of
the properties node is gone.
2026-10-11 12:19:25 -04:00
Aymen JAMAAOUI 61fe304619 feat(cloudformation): provision CloudFront public keys, key groups and functions (#5390)
* fix(cloudfront): reject CreateFunction when the name already exists

* feat(cloudformation): provision CloudFront public keys, key groups and functions

* fix(cloudformation): validate CloudFront function properties and always drop its tags on delete

* fix(cloudformation): require the CloudFront function comment and reuse resolveOptional
2026-10-11 00:16:51 -04:00
Vũ Thế Huy 475d230ebc feat(cloudformation): provision ElastiCache cache clusters and subnet groups (#5307)
* feat(cloudformation): provision ElastiCache cache clusters and subnet groups

Add AWS::ElastiCache::CacheCluster and AWS::ElastiCache::SubnetGroup provisioners with Ref, Fn::GetAtt endpoint attributes, create-only replacement and update handling. Subnet group updates now carry tags through modifyCacheSubnetGroup, and Memcached clusters record their network type.

* fix(elasticache): validate cluster name, rollback subnet groups and preserve memcached tags

* fix(elasticache): align in-use error wire code and enforce schema required properties
2026-10-10 11:11:00 -04:00
Mario Toffia 233d05eab1 docs(cloudformation): scope required AppSync resources (#4897)
The AppSync page did not say which AWS::AppSync resource types
CloudFormation provisions, what Ref and Fn::GetAtt return for them, or
what happens to the AppSync types Floci does not serve. A CDK app that
deploys a GraphQL API had to read the provisioner to find out.

The page now has a CloudFormation section. It lists the six provisioned
types with their Ref value and Fn::GetAtt attributes, and the
differences measured by deploying the same template to AWS and to
Floci: Ref on GraphQLApi and ApiKey returns the id where AWS returns the
ARN, GraphQLEndpointArn is not modeled, the URL and DNS attributes point
at Floci, and AWS refuses Fn::GetAtt Id on a GraphQLSchema while Floci
resolves it. It also states that a schema given only by S3 location
and S3 code locations are refused, and that the remaining AppSync types
are stubbed by default.

The generated CloudFormation resource-type table gets a row note with
the Ref difference and a link to that section.
2026-10-09 14:54:03 -04:00
Mario Toffia f248eb51af fix(cloudformation): send the stack's StackId to custom resources (#4861)
AWS documents StackId in every Create, Update and Delete request as the
ARN of the stack that contains the custom resource, and handlers rely on
it. #4973 now passes the engine's stack id and stashes it for Delete, but
an engine with no stack ARN still leaks a non-ARN: Cloud Control's
standalone engine uses the stack name as its id, so its custom resources
got StackId "cloudcontrol".

A stack id is now minted when there is no stack ARN to send. A resource
created through Cloud Control has its minted id stashed at Create, so its
Delete repeats it. A resource stashed by an earlier release with no
__FlociStackId, or with a non-ARN one, gets a freshly minted ARN on
Delete, because the delete path does not reach the stack.

An integration test drives Create, Update and Delete through a mocked
handler and checks the event's StackId against Ref AWS::StackId and
DescribeStacks, including a nested stack's own id, and the docs say so.
2026-10-08 14:43:01 -04:00
TATSUNO “Taz” Yasuhiro ee2d1a68a6 feat(cloudformation): pass Lambda DurableConfig through (#5218)
* feat(cloudformation): pass Lambda DurableConfig through

AWS::Lambda::Function.DurableConfig reaches CreateFunction and
UpdateFunctionConfiguration. As on AWS, a RetentionPeriodInDays the
template leaves out is 14 on update too, a durable function created
without Timeout gets min(ExecutionTimeout, 900), and adding or removing
DurableConfig replaces the function.

* test(terraform): cover aws_lambda_function durable_config

The provider creates a durable function, reads it back without a diff,
updates execution_timeout in place, and before destroy stops a RUNNING
durable execution through ListDurableExecutionsByFunction,
StopDurableExecution and GetDurableExecution.

* fix(cloudformation): honor AWS::NoValue, cleared keys and large numbers in DurableConfig

A DurableConfig that Fn::If removes with AWS::NoValue leaves the
function plain. A KMSKeyArn the template leaves out or sets to "" clears
the key, as CloudFormation does on AWS, since Lambda keeps a stored key
when the update omits the member. A number beyond an integer reaches
Lambda unchanged, so its range check rejects it.

* fix(cloudformation): reject a DurableConfig that is not an object

Only an intrinsic that resolves to AWS::NoValue removes DurableConfig.
CloudFormation rejects a string, number or list in its schema check
before the function is touched, so an update with one no longer
replaces and deletes a durable function.

* test(cloudformation): cover Lambda DurableConfig with the AWS SDK

The CloudFormation and Lambda SDK clients create a durable function,
update DurableConfig in place, and remove it by replacing the function.

* fix(cloudformation): require ExecutionTimeout and known members in DurableConfig

CloudFormation checks DurableConfig against the schema on update too: an
update without ExecutionTimeout, or with a member the schema does not
list, fails before the function is touched. Floci let such an update
through and kept the old timeout.

* refactor(cloudformation): look up a Lambda function once per deploy

The name choice and the replacement decision now share one lookup and one
durable check, so they cannot disagree.
2026-10-07 12:39:36 -04:00
Mario Toffia 4be8309e8d feat(cloudformation): provision AWS::IoT::Authorizer (#4830)
* test(cloudformation): cover AWS::IoT::Authorizer against AWS

* feat(cloudformation): provision AWS::IoT::Authorizer

CloudFormation stubbed AWS::IoT::Authorizer with a fake ARN and created
nothing. IotAuthorizerCfnProvisioner now creates a real authorizer
through IotAuthorizerService.

Ref is the authorizer name and Fn::GetAtt Arn the ARN. A missing
AuthorizerFunctionArn fails with the registry's model validation error
before any call. Status, EnableCachingForHttp, AuthorizerFunctionArn and
the token settings update in place, sending only the declared
properties, tags are reconciled, and a failed stack update restores
them from a snapshot. Changing AuthorizerName or SigningDisabled
replaces the authorizer and deletes the old one once the update
commits; a replacement that keeps an explicit name is refused. Delete
deactivates the authorizer first and tolerates one already gone.

Closes #4822

* chore(cloudformation): move the IoT authorizer snapshot constant

It sat at the same insertion point as other pull requests' snapshot constants, so they could not be merged together.

* fix(cloudformation): treat only an empty intrinsic result as AWS::NoValue for IoT authorizers

* fix(cloudformation): undo an IoT authorizer update whose tag reconcile fails

* fix(cloudformation): report a SigningDisabled change on an IoT authorizer as a replacement

* fix(cloudformation): create an IoT authorizer over a dispatcher stub and refuse declaring its generated name

* fix(cloudformation): refuse an IoT authorizer boolean that is neither true nor false

* fix(cloudformation): never delete a dispatcher stub's id in replacement cleanup

* fix(cloudformation): tell a stub from a migrated resource and roll back a stub migration that kept its id

* fix(cloudformation): name an unnamed IoT authorizer <LogicalId>_<12 chars> as CloudFormation does
2026-10-05 14:37:54 -04:00
Matheus Oliveira c6304a26c8 feat(cloudformation): provision AWS::Transfer::User (#5076)
* feat(cloudformation): provision AWS::Transfer::User

Adds the user type to TransferCfnProvisioner with in-place update and replacement.

* Fix #4655

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* docs: count the IAM SSH public key operations in the service matrix

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

---------

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-04 18:19:43 -04:00
Vũ Thế Huy 108f2b54bf feat(eventbridge): add ApiDestination target support (#4702) (#5009)
* feat(eventbridge): add ApiDestination target support (#4702)

- Add ApiDestination, ApiDestinationState, and HttpParameters models

- Implement CRUD operations for API destinations in EventBridgeService

- Add CreateApiDestination, DescribeApiDestination, UpdateApiDestination, DeleteApiDestination, ListApiDestinations actions in EventBridgeHandler

- Support HttpParameters on targets in PutTargets and ListTargetsByRule

- Implement HTTP delivery to API destinations in EventBridgeInvoker with connection auth and SSRF protection

- Add CloudFormation provisioning for AWS::Events::ApiDestination in EventsCfnProvisioner

- Update docs and tests

* fix(eventbridge): harden ApiDestination delivery and CloudFormation lifecycle

- Throw on delivery failure so TargetDispatcher retries 429/5xx and connection
  errors and dead-letters permanent failures
- Enforce InvocationRateLimitPerSecond per destination
- Run the OAuth client-credentials exchange for OAUTH_CLIENT_CREDENTIALS connections
- Reject non-http(s) endpoints and wildcard hosts, encode path parameter values,
  keep the query before any fragment, and stop logging URLs that may carry secrets
- Resolve destination and connection ARNs only when they match the stored ARN
- Validate every UpdateApiDestination field before applying any of them
- Paginate ListApiDestinations with Limit and NextToken
- Keep HttpParameters on AWS::Events::Rule targets and roll back
  AWS::Events::ApiDestination updates from a snapshot

* fix(eventbridge): keep connection credentials authoritative and require a valid endpoint host

- Apply target headers and query parameters before the connection's so a target
  cannot override its credentials, and replace header names that differ only by case
- Reject endpoints without a parsed host (for example https://:8080/path)
- Sweep stale rate-limit windows once the map grows

* fix(eventbridge): make the ApiDestination rate limit check atomic

Count permits inside ConcurrentHashMap.compute on an immutable window so the
stale-window sweep can no longer remove a window another delivery is using,
which let concurrent deliveries exceed InvocationRateLimitPerSecond.

* refactor(eventbridge): drop the in-service InMemoryStorage constructor and tidy tests

- Remove the compatibility constructor that instantiated InMemoryStorage inside
  EventBridgeService; tests pass the ApiDestination store explicitly
- Import classes instead of qualifying them inline in the ApiDestination integration test
- Surface worker failures in the concurrent rate limit test by checking each Future

* docs: correct the EventBridge and IAM operation counts in the service matrix
2026-10-04 18:03:31 -04:00
Mario Toffia 2749cd6fcd feat(cognito): provision user group attachments (#4806)
* feat(cognito): provision user group attachments

Serve AWS::Cognito::UserPoolUserToGroupAttachment through a new per-service
provisioner. Ref is <UserPoolId>|<GroupName>|<Username>, as measured on AWS.
Every property is createOnly, so a change replaces the membership and the old
one is removed in cleanup; delete tolerates a membership that is already gone.

* test(cognito): read stack outputs with XmlPath

* fix(cognito): attach users to groups from their recorded parts, as AWS does

* test(cognito): cover pipe group names and alias updates, delete seeded pools

* fix(cognito): remove an unrecorded attachment named unambiguously by its id

* test(cognito): pin that a failed rollback keeps the replacement's recorded parts

* fix(docker): finish a failed tar copy's writer before retrying

* test(docker): wait for each attempt's tar writer instead of racing it

Restores RetryingTarCopier.copyStreamed to its state on main: joining a failed attempt's writer could block on a writer stalled outside the pipe.

* docs(cloudformation): note the no-op delete of a short membership id

The class Javadoc said an unrecorded id that does not split into exactly three parts is refused. An id of fewer parts names no membership and its delete does nothing; only more parts is refused.

* fix(cloudformation): keep __Floci attributes out of Fn::GetAtt

Provisioners keep private state under __Floci attribute keys. Fn::GetAtt and Fn::Sub resolved them like any attribute, so a template could read, for example, an attachment's recorded pool, group and username, while AWS resolves no such attribute. They now resolve as unresolved, like any attribute a type does not have.

* docs(cloudformation): note that custom resource Data keys under __Floci are reserved
2026-10-04 17:00:35 -04:00
Vũ Thế Huy 99a6b4050c feat(redshift-serverless): add running workgroups and Data API WorkgroupName support (#5012)
* feat(redshift-serverless): add running workgroups and Data API WorkgroupName support

Redshift Serverless workgroups get full CRUD (Create/Get/List/Update/Delete),
tagging by ARN, and the AWS::RedshiftServerless::Namespace and ::Workgroup
CloudFormation types with dotted Fn::GetAtt keys taken from the registry
schema. A namespace has at most one workgroup, and DeleteNamespace is refused
while one is attached.

Each workgroup runs a PostgreSQL container behind an authenticating proxy,
sharing the managers and the proxy port pool with provisioned Redshift. Add
GetCredentials, accept WorkgroupName (name or ARN) in the Redshift Data API,
and push a changed namespace adminUserPassword down to the running backend.
The runtime is re-attached when Floci restarts.

Not covered: snapshots, usage limits, endpoint access, and COPY/UNLOAD/Spectrum
on workgroups.

* fix(redshift-serverless): stop the runtime when workgroup creation fails after it started

If persisting the workgroup record failed after the container and proxy were
already running, the runtime was left behind with no record. createWorkgroup
now stops it (best effort) and releases the endpoint on the failure path.

Fix the CloudFormation error for a NamespaceName change: suggesting a new
WorkgroupName can never succeed because a namespace holds only one workgroup.

* fix(redshift-serverless): reset omitted CloudFormation properties and order startup observers

When UpdateStack drops a property from the template, the provisioner now sends
its default (BaseCapacity, EnhancedVpcRouting, PubliclyAccessible, Port,
TrackName, PricePerformanceTarget) instead of keeping the stored value, which
matches CloudFormation semantics. MaxCapacity has no default and keeps its
stored value.

Give the workgroup StartupEvent observer a @Priority after RedshiftService so
every persisted cluster has reserved its proxy port before workgroups restore
theirs.

Also remove an unused import and move DEFAULT_DATABASE to the top of
RedshiftContainerManager.

* fix(redshift-serverless): address review findings on password rotation and namespace updates

- Roll the backend password back when a rotation cannot be completed or stored, and apply
  it last so validation failures never leave the backend ahead of the stored namespace.
- Keep a workgroup endpoint reserved when its runtime cannot be stopped during clear().
- Reject an in-place DbName change in CloudFormation, since it is fixed at creation.
- Reset an omitted KmsKeyId and DefaultIamRoleArn on CloudFormation updates.

* fix(redshift-serverless): keep rollback failures from masking errors and drop stale GetAtt role

- Do not reset the proxy password when the role restore fails, and attach restore
  failures to the original exception instead of replacing it.
- Remove Namespace.DefaultIamRoleArn from the stack resource when an update no
  longer declares a default role.

* docs: correct the Redshift Serverless operation count in the service matrix

* fix(redshift-serverless): expose Workgroup.ConfigParameters through Fn::GetAtt

* fix(redshift-serverless): parse ConfigParameters resolved from a GetAtt attribute

* docs(redshift-serverless): list every unsupported operation group
2026-10-04 15:34:24 -04:00
Mario Toffia 66f04cde25 feat(eventbridge): provision AWS::Events::Archive (#4818)
* fix(eventbridge): make UpdateArchive a partial update

UpdateArchive reset the event pattern to null and the retention to 0
whenever a request omitted them. On AWS an omitted Description,
EventPattern or RetentionDays keeps the stored value, an empty
Description or EventPattern clears it, and RetentionDays 0 sets 0.

* feat(eventbridge): provision AWS::Events::Archive

CloudFormation stubbed AWS::Events::Archive with a fake ARN and created
nothing. EventsArchiveCfnProvisioner now creates a real archive through
EventBridgeService.

Ref is the archive name and Fn::GetAtt Arn the archive ARN. ArchiveName
is generated when omitted and kept across updates. Description,
EventPattern and RetentionDays update in place, sending only the
properties the template declares, and a failed stack update restores
them from a snapshot. Changing SourceArn or ArchiveName, or dropping an
explicit name, replaces the archive and deletes the displaced one once
the update commits. A replacement that keeps an explicit name is refused
with CloudFormation's custom-named resource error before any change.
KmsKeyIdentifier is ignored.

Closes #4815

* fix(eventbridge): reject an archive source that is not an existing bus of the account and region

CreateArchive now checks EventSourceArn as AWS does, before the archive
name: a bus in another account fails with AccessDeniedException, one in
another region with ValidationException, and a bus that does not exist
with ResourceNotFoundException. The AWS::Events::Archive provisioner goes
through the same service call, so a stack can no longer reach
CREATE_COMPLETE with an archive that could never capture an event.

* test(eventbridge): roll back an in-place archive update when a later resource fails

A stack update changes an archive's description and retention in place,
then fails on a second archive whose source bus does not exist. The stack
ends UPDATE_ROLLBACK_COMPLETE, DescribeArchive shows the original values
and the second archive was never created. The golden case passes on AWS
and is mirrored in the Floci integration test.

* fix(cloudformation): refuse declaring a generated archive name explicitly

Adding ArchiveName with the name CloudFormation generated for an unnamed
archive asks AWS to replace the archive under the same custom name, which
it refuses with the custom-named resource error and rolls the stack back.
Floci took the in-place path and reached UPDATE_COMPLETE; the existing
refusal now also fires when the previous name was generated.

* fix(cloudformation): provision a real archive when updating a stack whose archive was stubbed

A stack created before AWS::Events::Archive had a provisioner holds the dispatcher's stub, whose physical id names no archive. Its next update now creates the archive instead of failing to describe that id, and the stub id is left to the replacement cleanup.

* fix(eventbridge): validate archive description, pattern and retention as CreateArchive and UpdateArchive do

CreateArchive and UpdateArchive now reject a description over 512 characters, an event pattern over 4096 characters and a negative retention with the ValidationException AWS returns, all violations reported together. The check runs before the source, existence and duplicate checks, so it also fails the AWS::Events::Archive resource in a stack.
2026-10-04 13:39:49 -04:00
Aymen JAMAAOUI 2c544fdb9f feat(cloudformation): provision AWS::ApiGatewayV2::VpcLink (#5008)
* feat(apigatewayv2): implement UpdateVpcLink and VPC link tagging

* feat(cloudformation): provision AWS::ApiGatewayV2::VpcLink

* fix(cloudformation): keep VPC link and integration connection state on updates

* fix(cloudformation): restore the integration connection when its own update fails
2026-10-04 09:09:18 -04:00
Mario Toffia ae0a591bb1 feat(cognito): provision user pool users (#4805)
* feat(cognito): provision user pool users

Add a CloudFormation provisioner for AWS::Cognito::UserPoolUser. Ref is the
username Cognito reports (the sub in an email-as-username pool). Every property
is createOnly: a changed custom-named user is refused as on AWS, any other change
replaces the user, and each delete targets the pool the user was created in.

* fix(cognito): refuse a RESEND user pool user that already exists

* fix(cognito): keep the user's pool out of Fn::GetAtt

* fix(cognito): keep only owed users in the pool record
2026-10-03 15:15:50 -05:00
Mario Toffia 9e178d77a0 feat(wafv2): provision web ACL associations (#4804)
* feat(wafv2): provision web ACL associations

WafV2CfnProvisioner now serves AWS::WAFv2::WebACLAssociation with Ref
ResourceArn|WebACLArn, as measured on AWS. Any property change replaces
the pair through ReplacementCleanup. Delete disassociates only while the
resource still uses that ACL, so cleanup of an old pair keeps the new one.
Rollback re-associates the restored pair.

* test(wafv2): cover ResourceArn replacement and read stack outputs with XmlPath
2026-10-03 15:01:18 -05:00
XuJian bcb50b765f feat(cloudformation): provision Transfer Family servers (#4809)
* feat(cloudformation): provision Transfer Family servers

* fix(cloudformation): clear Transfer update snapshot after success

* test(cloudformation): cover Transfer tag rollback

* fix(cloudformation): match Transfer server return values
2026-10-01 22:28:47 -04:00
Mario Toffia a338a430cc feat(cloudformation): provision Cloud Map namespaces and services (#4599)
* feat(cloudformation): provision Cloud Map namespaces and services

AWS::ServiceDiscovery::PrivateDnsNamespace, PublicDnsNamespace,
HttpNamespace and Service were stubbed, so a stack reported them created
while nothing existed in Cloud Map and Fn::GetAtt resolved to literals.

CloudMapCfnProvisioner creates them through CloudMapService. Ref returns
the id; Fn::GetAtt exposes Id and Arn, HostedZoneId on a DNS namespace and
Name on a service. An unnamed service is named <LogicalId>-<12 chars>, as
measured on AWS. Description, DnsConfig, HealthCheckConfig and Tags update
in place; a createOnly change replaces the resource through
ReplacementCleanup, and a rolled-back replacement restores the createOnly
record. A Ref to a Number parameter is coerced back to a JSON number for
DnsRecords TTL and FailureThreshold.

Closes #4596
* fix(cloudformation): roll back in-place Cloud Map updates

An in-place namespace or service update followed by a later resource
failing left the Cloud Map changes live and the stack in
UPDATE_ROLLBACK_FAILED, since rollbackUpdate only undid replacements.
The provisioner now keeps the description, DnsConfig, HealthCheckConfig
and tags an in-place update overwrites and puts them back on rollback;
a committed update drops the snapshot.
* fix(cloudmap): reject DNS record type changes on service update

UpdateService only changes the TTLs of a service's existing DNS records on AWS. An in-place CloudFormation update that changes the record types, or gives a DnsConfig to a service without one, now fails with InvalidInput instead of being applied, so it rolls back like on AWS and a rollback never has to remove a DnsConfig.
* fix(cloudmap): accept only TTL changes in a service DnsConfig update

UpdateService carries only DnsRecords on AWS and CloudFormation does not support a RoutingPolicy update. Comparing the record types as a set let a RoutingPolicy change or an added record of the same type through; the requested and stored DnsConfig now have to match apart from the TTLs.
* fix(cloudmap): ignore DNS record order in a service DnsConfig update

A TTL-only update that listed the same records in another order was rejected. The comparison now uses the sorted record types, so counts, types and RoutingPolicy still have to match.
* test(cloudformation): restore a real HealthCheckConfig in the Cloud Map rollback test

The in-place rollback test went from a null health check config to null, so dropping it from the snapshot would have passed.
2026-09-30 21:45:18 -05:00
Mario Toffia 560de5c13f fix(tagging): find resources by the tags their own service holds (#4563)
* fix(tagging): list resources by the tags their own service holds

GetResources, GetTagKeys and GetTagValues merge the tagging store with every
ResourceProvider, so SQS, Lambda and Logs tags are discoverable. Resource type
filters now parse colon and leading-slash ARNs (function:f, log-group:x, /apikeys/k),
and TagResources/UntagResources write through to the owning TagHandler.

* fix(apigateway): expose tagged resources and API key tags to the tagging API

ApiGatewayService is a ResourceProvider for REST APIs, stages, API keys, usage plans and
domain names, and ApiGatewayTagHandler serves /apikeys/<id> ARNs, so GetResources finds
API Gateway resources by tag and tagging-API writes land on the API key itself.

* fix(cloudformation): forward AWS::Lambda::Function Tags

CreateFunction now receives the template Tags; an in-place UpdateStack untags dropped keys and retags the desired set, mirroring SqsCfnProvisioner.

* fix(tagging): scope global-ARN resources by region and clamp stale page tokens

Provider resources with an empty ARN region use their own region, stale page tokens
past the end return an empty page, and provider tags are copied inside the skip guard.

* test(compat): discover SQS, Lambda, Logs and API Gateway resources by tag

* docs(tagging): describe owning-service discovery

* fix(tagging): forward tags only for resources the owning service lists

* fix(apigateway): report the calling account and tag usage plans

* docs(cloudformation): note Lambda tag reconciliation on update

* fix(tagging): match declared resource types and scope owner writes to the request

API Gateway API key and usage plan ARNs must now name the key or plan at the
start of the resource part, so a nested /apikeys/ segment no longer tags the key.

* fix(tagging): match AWS type filters, regions and failure codes

Compared against a live AWS account: type filters, IAM listing, cross-region
TagResources and FailedResourcesMap entries now answer as AWS does.

* fix(cloudformation): keep Lambda tags added outside the template

* fix(tagging): route TagResources to V1 tag handlers too

* fix(apigateway): reject sub-resource ARNs when tagging a REST API

* fix(tagging): write tagging API tags through to SQS, Lambda and Logs

TagResources and UntagResources now reach the queue, function or log group's own tags through TagHandler beans qualified @TaggingApiOnly, so ListQueueTags, Lambda ListTags and Logs ListTagsForResource show them. The qualifier keeps these handlers off the /tags/{arn} and /v1/tags/{arn} paths, since each service defines tags in its own protocol.

* fix(cloudformation): forward SSM parameter tags

AWS::SSM::Parameter now applies its Tags after the overwriting put. On UpdateStack only the keys the previous template set and the new one drops are removed, tracked in the internal FlociSsmTemplateTagKeys attribute, so tags added outside the template are kept.

* fix(tagging): hide tagging-store copies of global resources

GetResources no longer lists an IAM role or user tagged through TagResources, since AWS never lists global resources.

* fix(tagging): reject every wildcard log group ARN

TagResources and UntagResources now send a log group ARN ending in :* to CloudWatch Logs even when the group does not exist, so it is rejected as in AWS instead of stored.

* fix(tagging): clear store tags on every untag

UntagResources now removes the keys from the tagging store for every ARN, even one the owning service rejects, so a copy stored earlier can always be cleared.

* fix(cloudformation): tag an adopted Lambda function

When CreateFunction conflicts and the provisioner adopts the existing function, the template's tags are now applied to it.

* fix(apigateway): tag only exact domain and stage ARNs

A domain or stage segment nested elsewhere in an API Gateway ARN, such as /restapis/<id>/domainnames/<d>, is now rejected instead of tagging that domain or stage.

* fix(cloudformation): leave an adopted Lambda function's tags alone

Adoption uses the existing function as it is, as before, so a function outside the stack keeps its tags.

* fix(cloudformation): record no template tag keys for an adopted Lambda function

An adopted function keeps its own tags, so a later update adds the template's tags without removing any it never set.

* fix(tagging): never list IAM ARNs from the tagging store

A role tagged through TagResources stays hidden after DeleteRole, as AWS never lists IAM resources.

* fix(tagging): fail a write when an owning service cannot be read

A provider that fails while routing TagResources or UntagResources now returns InternalServiceException instead of writing the tagging store and reporting success.

* fix(tagging): fail only unresolved ARNs when a provider cannot be read

A provider failure no longer fails the whole TagResources or UntagResources call; only ARNs whose owner could not be resolved are reported in FailedResourcesMap.

* fix(tagging): report another account's ARN instead of storing it

TagResources and UntagResources report an ARN from another account in FailedResourcesMap with AccessDeniedException, as AWS reports it per ARN, and never write it to the tagging store.

* fix(tagging): keep stored tags for an ARN an untag could not resolve

UntagResources leaves the tagging store unchanged for an ARN it reports as unresolved or from another account; an ARN its owner rejected is still cleared.

* fix(tagging): fail an unresolved ARN only when its own service cannot be read

A provider failure now only affects unlisted ARNs of the services that provider declares.

* fix(tagging): copy stored tags under the writers' lock

GetResources, GetTagKeys and GetTagValues no longer race a concurrent TagResources on a stored mapping.

* fix(apigateway): reject reserved tags when tagging a usage plan

TagResources on a usage plan now refuses floci:override-id as the other API Gateway tag paths do, instead of dropping it and reporting success.

* fix(apigateway): reject tag ARNs with an account or another region

The /tags path now answers an ARN with an account segment with BadRequestException and one naming another region with NotFoundException, as AWS does, instead of resolving the id in the caller's region.

* fix(ssm,lambda): reject tag keys outside the AWS pattern

AddTagsToResource, PutParameter, TagResource and CreateFunction now reject a tag key outside the AWS pattern or 1 to 128 characters with ValidationException, as AWS does, which also keeps the CloudFormation managed-key attributes lossless.

* fix(ssm,lambda): validate CloudFormation tag keys before changing the resource

* docs(tagging): say every handled ARN ending in :* reaches its service

* fix(tagging): read a negative pagination token as the first page
2026-09-30 06:10:27 -04:00
stodan 60d112542d fix(cloudformation): delete UPDATE_FAILED resources on DeleteStack (#4470)
* fix(cloudformation): delete UPDATE_FAILED resources on DeleteStack

A failed update whose rollback cannot restore a resource leaves it
UPDATE_FAILED with its physical id and the stack in
UPDATE_ROLLBACK_FAILED. DeleteStack only walked CREATE_COMPLETE,
UPDATE_COMPLETE and DELETE_FAILED resources, plus UPDATE_FAILED ones
whose provisioner opted in, so every other failed resource was skipped
without an event and the stack still reached DELETE_COMPLETE, leaving
the role, log group or bucket behind.

Delete every UPDATE_FAILED resource that has a physical id. Delete a
CREATE_FAILED resource only when the provisioner marked its entity as
created by the stack, as the create rollback does, since a failed
create can name an entity that existed before.

Closes #4467

* test(cloudformation): clean up the outside log group when the test fails

* docs(cloudformation): list the resource statuses DeleteStack deletes

* fix(cloudformation): mark a failed nested stack the operation created as stack-owned

A nested stack whose child fails during creation came back CREATE_FAILED
with the child's stack id but no ownership marker, so neither the create
rollback nor DeleteStack deleted the child stack.

* test(cloudformation): clean up the stack, role and log group when the test fails

* docs(cloudformation): update the hasPendingRollbackCleanup javadoc now that DeleteStack no longer calls it
2026-09-26 16:23:44 -05:00
Mario Toffia 4abba5a218 fix(lambda): preserve CloudFormation event source mapping options (#4316)
AWS::Lambda::EventSourceMapping now forwards MaximumBatchingWindowInSeconds,
MaximumRetryAttempts, MaximumRecordAgeInSeconds, BisectBatchOnFunctionError,
FilterCriteria, DestinationConfig and ScalingConfig to LambdaService, so a
stack-created mapping matches an API-created one. On UpdateStack each of
these that the template omits is sent as null, which clears it.

ParallelizationFactor and TumblingWindowInSeconds are not modeled and remain
ignored; the resource-type table notes this.

Fixes #4313
2026-09-24 21:05:00 -04:00
stodan 34f4f72e82 fix(cloudformation): pass Lambda hot-reload code through to the Lambda service (#4093)
* fix(cloudformation): pass Lambda hot-reload code through to the Lambda service

AWS::Lambda::Function code of {S3Bucket: hot-reload, S3Key: /host/path} is
Lambda's bind-mount hot-reload convention: the bucket is a marker and the key
is a directory on the Docker host. The provisioner probed S3 for the pair
before calling CreateFunction, so no such object existed and the stack failed
with a ValidationError (or, with allow-stub-lambda-code on, quietly deployed
the stub handler).

Skip the S3 probe for the hot-reload bucket and hand the Code map to
LambdaService unchanged, which keeps enforcing hot-reload enablement, the
absolute-path rule and the allow-list, and reports its own error as the
resource status reason. Record a hot-reload code identity so a redeploy with
the same path is a no-op, and compare adopted functions by host path since a
hot-reload function carries no S3 bucket or key.

* fix(cloudformation): canonicalise the hot-reload code identity

LambdaService stores a hot-reload host path normalised (#4053), while the
provisioner recorded the raw template key as the code identity and compared
adopted functions against it. A template that spelled the same directory with
a trailing slash or a ".." segment, or a function adopted from a direct
CreateFunction, therefore looked like a code change and triggered an
UpdateFunctionCode that mounted the same directory again.

Build the identity from, and compare against, the normalised path. The raw key
still goes to Lambda so its validation and error messages are unchanged. Also
cover the documented SAM CodeUri form, s3://hot-reload//abs/path, through the
transform.
2026-09-23 18:03:35 -05:00
Allen Sanborn 67f06c3ac9 feat(cloudformation): list a deleted stack and report its DeletionTime (#4246)
* feat(cloudformation): list a deleted stack and report its DeletionTime

A deleted stack is already retained so DescribeStacks and DescribeStackEvents
keep answering for it by stack id after the delete, but the record they answer
with was incomplete in two ways.

It carried no deletion time, so DescribeStacks reported DELETE_COMPLETE with
nothing saying when. Stack now has a deletionTime, set as the stack reaches
DELETE_COMPLETE from the same service clock the retention window uses, and the
query handler emits DeletionTime wherever AWS does.

ListStacks omitted deleted stacks entirely. AWS keeps one there as
DELETE_COMPLETE long after DescribeStacks has stopped answering for it by name,
which is how a client reconciles what it deployed against what is left, and a
StackStatusFilter of DELETE_COMPLETE selects exactly those. Retained stacks are
now merged into the listing, still scoped to the caller's account and region and
still dropped once the window passes. A name reused after a delete lists twice,
once per stack id, as it does on AWS. Resource Explorer reads the live map
directly and is unaffected.

Restores deleted-stack-retention-seconds to application.yml, which #849 dropped
in a merge: the knob kept working on its @WithDefault, but the repository YAML
is the source of truth for what a deployment actually runs. Pinned in the test
YAML too, since the retention tests advance the clock past that exact window.

Nothing here changes how a delete runs, and it does not make a multi-stack cdk
destroy work: that client polls a destroy entirely by stack name, so a record
retained by stack id, these two members included, never enters its path.
DeleteStack does already return before the delete finishes, and the stack does
pass through DELETE_IN_PROGRESS, but the whole delete completes in roughly 15ms,
well inside one poll interval, so a client that starts watching when it issues
the delete finds the stack gone by name on its first poll. Giving a deleting
stack an observable window is separate work.

* fix(cloudformation): set a stack's deletion time before publishing the status

Stack.status is volatile and is documented as the publishing write of a deploy:
a reader that observes a terminal status is guaranteed to observe every write
that preceded it. deletionTime was assigned after it, outside that guarantee, so
a DescribeStacks running concurrently with the last step of a delete could
observe DELETE_COMPLETE while deletionTime was still null and answer with no
DeletionTime element at all.

Assigning it first puts it inside the same happens-before edge as the rest of
the delete. The window is nanoseconds wide and no test can land in it reliably,
so this carries none; the ordering rule is the thing being fixed, and the
comment records it so the next edit here keeps it.

* fix(cloudformation): retain a deleted stack before it leaves the live map

The handover at the end of a delete removed the stack from the live map, wrote
its removal through to storage, and only then retained it as deleted. A
ListStacks landing between the removal and the retention found it in neither
map and dropped it from the listing, though the stack both existed a moment ago
and is retained a moment later.

Retaining before removing closes that window. The stack is then briefly in both
maps, which is harmless: they hold the same Stack, and listStacks now reduces by
stack id, so it is listed exactly once throughout. Nothing else reads both maps,
since resolveStackForDescribe consults the retained one only after the live
lookup has missed.

Greptile reported the listing could also show the stack twice. It could not:
the old order removed before it inserted, so the two maps never overlapped. The
duplicate only becomes possible with this ordering, which is why the reduction
comes with it.

The test drives 60 deletes with four concurrent listings each. It fails on every
run against the old ordering and passes on every run against this one. It pins
the retention window open through a profile: the window is measured on the test
MutableClock, which advances on every read, and the pollers would otherwise
expire the retained record themselves.

* style(cloudformation): order the Stream import with the rest of java.util

java.util.stream.Stream landed between java.util.regex and java.util.concurrent
when it was added. It now follows both, the order AGENTS.md asks for. Only the
line this branch introduced moves; the block's older irregularities are left
where they are.

* fix(cloudformation): read the live stacks before creating the deleted-stack view

Retaining a stack before removing it keeps it in at least one map at every
instant, but listStacks built both of its views up front, the retained one
first and the live one after. A ConcurrentHashMap view reflects the table at
some point at or since its own creation and is not guaranteed to reflect a
modification made after it, so the retained view, created before the retain,
need never show the stack, while the live view, created after the remove, can
already miss it. A listing landing there loses the stack in both, which is the
window the retain-before-remove ordering was meant to close. Traversing the
retained view second does not help: creation bounds the guarantee, not
traversal.

The maps are now read one after the other instead of through a concatenated
pipeline, the live one first and in full, so the retained view is created after
any remove the live pass could have missed, and therefore after the retain that
preceded it. The reduction by stack id stays: the overlap it covers is real.

No test. The fault is the absence of a JDK guarantee rather than a behaviour:
these views do in practice reflect a later put, so the old ordering passes every
time and nothing can force it not to. The existing listing-race test still
covers the retain-before-remove ordering this rests on.

The java.util.stream.Stream import goes with Stream.concat, which the change
removes.

* test(cloudformation): stop the listing-race pollers on every exit path

The pollers were stopped after awaitDeleted returned, so a throw from the delete
or the wait left four non-daemon threads spinning on listStacks for the rest of
the run. That holds the test JVM open and buries the failure that caused it
under a hang, which is a far worse thing to debug than the failure itself.

Shutdown moves into a finally, so a failing delete stops them on its way out.
Each join is bounded and a thread still alive afterwards is interrupted and
recorded, with the poller loop now checking its own interrupt flag so that
interrupt is not merely decorative. The check that they all stopped is asserted
after the try and never inside the finally, where it would replace whatever the
delete threw with its own failure. The threads are daemons as a backstop, so a
future edit that throws somewhere nothing throws today still cannot wedge the
suite.

Also replaces an assertTrue(false, ...) in the wait helper with fail(...), which
says the same thing and reads as what it is. Noted here rather than slipped in.
2026-09-23 18:01:55 -05:00
lex00 28ca34ad6c fix(cloudformation): apply an S3 bucket's declared configuration and its policy (#3950)
S3CfnProvisioner translated CorsConfiguration and VersioningConfiguration
and nothing else, and AWS::S3::BucketPolicy took a physical id and stopped,
so a stack reported CREATE_COMPLETE for a bucket with no lifecycle, no
public-access block, no default encryption, no tags and no policy.

PublicAccessBlockConfiguration, LifecycleConfiguration, BucketEncryption
and Tags are now translated into the XML their S3 API calls take and handed
to the same service methods, so they are validated and stored exactly as a
direct PutBucket* would be. The policy document has its intrinsics resolved
and is put on the bucket.

The policy's physical id is the bucket name, as the registry schema's
primaryIdentifier declares, and deleting the resource removes the policy,
tolerating a bucket the stack already deleted. The class javadoc names the
properties that are covered and those still dropped.

Closes #3947
2026-09-21 22:27:54 -05:00
Priamo Germosen 8af15a71c4 fix(cloudformation): remove the login profile when deleting an IAM user (#3975)
Since login profiles became real state, DeleteUser returns DeleteConflict while one exists, so deleting a stack whose AWS::IAM::User was given a password out of band ended in DELETE_FAILED. The provisioner now deletes the login profile before the user, tolerating a user that has none. The resource-type table notes that the template LoginProfile and PermissionsBoundary properties are ignored.
2026-09-20 09:13:36 -05:00
Chris Jovanovski d9a4db0290 fix(cloudformation): provision Cognito user pool groups (#3695)
* fix(cloudformation): provision Cognito user pool groups

Create and reconcile user pool groups, and namespace custom schema attributes while preserving standard attributes.

* fix(cloudformation): keep a generated Cognito group name across updates

GroupName is optional, and provision generated a fresh stand-in on every call. Because
provision is also the update path, the second UpdateStack derived a different name, took
the create branch and left the group the stack already owned orphaned behind it.

Use ProvisionContext.stablePhysicalName so the prior physical id is reused when the
template does not name the group, and reusesPriorEntity for the create-or-update choice,
which is the pairing that keeps a stable name from turning an update into a duplicate
create.
2026-09-19 20:06:58 -05:00
XuJianandxujiantop-crypto 0142d443ac feat(cloudformation): provision CloudWatch log streams (#3869)
* feat(cloudformation): provision CloudWatch log streams

* fix(cloudformation): preserve conditional log stream name omission

---------

Co-authored-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
2026-09-18 20:45:44 -05:00