An AWS::ECS::Service update that left DesiredCount out set the service
back to 1. AWS omits it from the update ("For existing services, if a
desired count is not specified, it is omitted from the operation"), so a
count set through UpdateService now stays. A new service without it
still starts at 1, and a rollback puts the count back only when the
update sent one.
An AWS::Lambda::Version resource reported its deletion but left the
version published. CloudFormation now deletes the version through
Lambda's qualified DeleteFunction when the stack is deleted, the
resource leaves the template, or its creation rolls back, unless its
DeletionPolicy retains it. $LATEST and other versions stay, an
already-missing version counts as deleted, and an alias still pointing
at the version fails the delete until it is removed. A placeholder,
unqualified or alias identity is never turned into a whole-function
delete.
The SDK regressions use the shared CfnStackWaits, now with an SDK
deleteStack that follows the stack id, and AwsSdkErrors for their error
checks.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Signed-off-by: Jackson Price <jxnprice@amazon.com>
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
CDK's ApplicationListener.addCertificates puts the first certificate on
the listener and emits one ListenerCertificate for each extra one. Floci
had no provisioner for the type, so it was stubbed as CREATE_COMPLETE and
did nothing; since the default certificate is held apart from the
listener's certificate list, such a listener came up with an empty list
and served none of its SNI certificates.
ElbV2CfnProvisioner serves the type now. Create adds the declared
certificates to the listener's list, as AddListenerCertificates does, and
delete removes the ones the resource added, recorded per physical id
because the id alone cannot carry them. Certificates updates in place, as
the resource reference says: the certificates the template gains are
added, then the ones it drops removed, and a failed update puts both back.
ListenerArn is create-only, so a change replaces the resource: the
certificates go onto the new listener, and come off the old one once the
update commits.
CloudFormation publishes no format for the resource's identifier, so Ref
returns <ListenerArn>|<suffix>.
AWS's published resource schemas have moved since the vendored tables
were last synced: AWS::Lambda::Function gained AcceleratorConfig and
RuntimeConfig, and AWS::ECS::TaskDefinition TrustedExecutionConfiguration.
That fails the online check of those tables, which this change runs, so
cfn-property-types.json and schema-surface.tsv are synced from AWS here,
and the three new properties are recorded as accepted and ignored.
A template can now create the three EFS types. They are provisioned
through EfsService, so a stack and a direct API call see the same
file systems, mount targets and access points.
- Ref and Fn::GetAtt resolve for every type.
- Updates change ThroughputMode, ProvisionedThroughputInMibps,
BackupPolicy, LifecyclePolicies, FileSystemPolicy,
FileSystemProtection and tags in place; create-only properties
replace the resource, and a failed update puts back what it changed.
- Backups are off on create unless BackupPolicy is ENABLED or the file
system is One Zone, and ThroughputMode provisioned requires
ProvisionedThroughputInMibps.
- Required properties are validated from the registry schema.
Ref #7972
PutResourcePolicy replaced the tag set of an existing resource policy
whenever the request carried Tags. The model says tags apply only to
the initial creation of the resource policy and that the call throws
otherwise. It now applies Tags only when it creates the policy and
answers InvalidInputException for Tags on an existing one, before it
changes anything. The model names no error for this case;
InvalidInputException is the one it lists for invalid request values.
An empty Tags list has no tags to apply and is accepted.
The CloudFormation provisioner relied on the old replace to converge
the Tags of AWS::Organizations::ResourcePolicy on update. An update now
leaves Tags out of PutResourcePolicy and converges them through
TagResource and UntagResource by the rp- ID, as the provisioner does
for OUs, accounts and policies and as AWS's own handler does.
Co-authored-by: Priamo Germosen <6233424+pgermosen@users.noreply.github.com>
* feat(eventbridge): create partner event buses from EventSourceName
CreateEventBus and AWS::Events::EventBus now accept EventSourceName. The
bus takes the source's name, so Name must equal it and must match
aws.partner/<partner>/<source>. Floci does not model partner event
sources, so any well-formed source name is accepted without one being
created or activated first.
A partner bus name contains slashes, so rule lookups for a bus no longer
match the rules of a bus nested under its name, and a rule ARN on a
partner bus resolves its bus and rule name from the last slash.
* test(eventbridge): cover partner event buses
Covers creating a partner bus from its EventSourceName, a name that
differs from the source or is not a partner name, rules, targets, tags
and PutEvents on the bus by name and by ARN, nested partner buses
keeping their rules apart, deletion, and the CloudFormation resource.
* refactor(eventbridge): resolve rule ARNs from the first slash again
ruleKey joins the bus and rule name with a slash, so splitting a rule
ARN at the first or the last slash finds the same stored rule. The
original split is kept, and the test that only exercised the changed
split goes with it; tagging a rule on a custom bus by ARN stays covered
by the existing tag tests.
* fix(eventbridge): validate rule names in PutRule
PutRule accepted any name, so a name holding a slash was stored under a
key that ListRules, PutEvents and DeleteEventBus no longer treat as a
rule of that bus, and could collide with a rule on a nested partner bus.
Rule names now match [\.\-_A-Za-z0-9]+ and are at most 64 characters,
as AWS models them, and a missing or out-of-pattern name fails with
ValidationException. The CloudFormation AWS::Events::Rule resource
creates its rule through the same PutRule path.
* fix(cloudformation): reject a Policy or malformed source on a partner event bus
An AWS::Events::EventBus with EventSourceName now checks the source name
against aws.partner/<partner>/<source> in the provisioner, so a
malformed one fails with ValidationError like the resource's other
checks rather than with the service's ValidationException. A Policy
given with EventSourceName is rejected with ValidationError before the
bus is created, since Floci never applies a resource policy to a bus
whose name holds a slash.
* fix(eventbridge): answer partner and rule name violations in AWS's shape
CreateEventBus with EventSourceName and PutRule now report a bad name
the way AWS's validation layer does, through SmithyValidationErrors:
"1 validation error detected: Value '...' at 'name' failed to satisfy
constraint: ...", naming the length, pattern or missing member that
failed. A partner bus with no Name now gets the required-member error
rather than a name mismatch. The partner source pattern is one public
constant on EventBridgeService, which the CloudFormation provisioner
now uses too.
* fix(eventbridge): refuse PutPermission and RemovePermission on a partner bus
Both operations model the bus as NonPartnerEventBusName, so AWS refuses
a partner bus there. Floci stored the policy, but never applied a
resource policy to a bus whose name holds a slash, so the statement had
no effect. They now fail with ValidationException in AWS's validation
shape, and an AWS::Events::EventBusPolicy on a partner bus fails the
stack the same way.
* fix(cloudformation): let an update change a partner bus's EventSourceName
Once a bus exists its Name is fixed, and a Name change is already
refused as a replacement, so EventSourceName carries nothing more on an
update. An UpdateStack that drops, adds or changes it while keeping
Name used to be validated as if it were creating the bus and failed;
it now updates the bus in place. Whether the bus is a partner bus is
read from its name, so a Policy on one is still refused when the
template stops naming its source.
* test(eventbridge): cover nested-bus PutEvents, partner rule tags and CFN rules
PutEvents on a partner bus does not fire the rules of a bus nested under
its name, a rule on a partner bus is tagged and listed by its ARN, and
an AWS::Events::Rule names a partner bus in EventBusName and goes with
the stack.
* docs(eventbridge): note partner bus permissions, PutEvents and the rule-name upgrade
* fix(cloudformation): validate a supplied EventSourceName on an event bus update
An update that keeps the bus's Name skipped EventSourceName entirely, so
a malformed source, one that does not match Name, or one newly added to
a custom bus was accepted. When the template supplies EventSourceName it
is now checked the way creation checks it; leaving it out still updates
the bus in place.
* fix(eventbridge): let a legacy slash-named rule block DeleteEventBus
DeleteEventBus only counted rules whose name held no slash, so a bus
whose only rule was a legacy slash-named one could be deleted, orphaning
the rule; a scheduled one kept firing after a restart. Every rule stored
under the bus now blocks the delete, except the rules of an existing
nested partner bus, which share the key prefix but belong to that bus.
* fix(eventbridge): validate rule names in the rule and target operations
Only PutRule checked the rule name, so DeleteRule, EnableRule,
DisableRule, PutTargets, RemoveTargets and ListTargetsByRule took a
name like a/b and looked it up by key, which on a partner bus could
reach a rule of a nested bus. They now answer a ValidationException the
way PutRule does. A legacy slash-named rule that is stored on the bus
named in the request is still reachable by its exact name, so it can
have its targets removed and be deleted.
* refactor(eventbridge): split a rule ARN at its last slash
A rule name holds no slash, so the bus is everything before the last
one. Splitting at the first slash found the same stored rule, since the
key joins bus and rule with a slash, but left RuleRef's bus and rule
wrong for a rule on a partner bus such as
rule/aws.partner/example.com/acct/r1.
* docs(eventbridge): describe legacy slash-named rules and EventSourceName updates
A legacy slash-named rule is hidden from ListRules and PutEvents but
still reachable by its exact name and blocks DeleteEventBus, and the
other rule operations now validate the name. On a CloudFormation update
a supplied EventSourceName is validated as on creation.
* fix(eventbridge): keep every persisted rule reachable by its exact name
PutRule did not validate rule names before, so a stored rule can be longer
than 64 characters or contain a space, colon or at sign. Skip name validation
whenever a rule with that exact name is stored on the requested bus, not only
for slashed names, so such a rule can still have its targets removed, be
disabled and be deleted, and no longer blocks DeleteEventBus forever.
* fix(eventbridge): name the rule member in target operation validation errors
PutTargets, RemoveTargets and ListTargetsByRule take the rule name in their
Rule member, so report a rejected name at 'rule' as AWS does instead of
at 'name'.
* fix(eventbridge): validate the rule name in DescribeRule
DescribeRule now applies the same rule name check as the other rule
operations, so a malformed name fails with ValidationException instead of
ResourceNotFoundException, while a persisted rule stays describable by its
exact name.
* fix(eventbridge): resolve a legacy slashed rule ARN on a custom bus
Splitting a rule ARN at its last slash finds rules on partner buses but
misses a rule persisted with a slash in its name on a custom bus, such as
rule/foo/team/r1. When no rule is stored for the last-slash split, fall back
to the first-slash split if the rule stored there belongs to that bus, so
TagResource, UntagResource and ListTagsForResource reach it again.
* refactor(eventbridge): decide DeleteEventBus by each rule's own bus
Count a stored rule against the bus being deleted when its eventBusName is
that bus, rather than inferring ownership from whether a nested bus exists
under the rule key's prefix.
* docs(cloudformation): note that AWS replaces a bus whose EventSourceName is dropped
* test(eventbridge): cover legacy slashed rules on a custom bus
Exercise the rule and target operations on a slash-named rule persisted on a
custom bus, and check that a slashed name stored for a different bus is still
rejected by every rule and target operation.
* refactor(eventbridge): split a rule ARN at its last slash only
A rule's store key joins the bus and rule name with a slash, so splitting
rule/foo/team/r1 at its first or last slash names the same stored rule. The
first-slash fallback could never find a rule the last-slash lookup missed;
drop it and resolve the ARN without a store lookup.
* test(eventbridge): pin the error a removed legacy slashed rule returns
Once the stored rule is gone, DescribeRule validates its slashed name again and
fails with ValidationException. Assert that code, and that the rule left the
store, instead of any AwsException.
* fix(cloudformation): treat a gone legacy-named rule as deleted
A stack created before rule names were validated can hold a rule whose name
PutRule now rejects. Once that rule is gone, ListTargetsByRule validates the
name and fails with ValidationException, so DeleteStack ended DELETE_FAILED.
Check whether the rule is stored first, through a new
EventBridgeService.ruleExists that skips name validation, and treat a missing
rule as already deleted.
* docs(eventbridge): spell out what a legacy slashed rule can still do
A slashed rule on the default bus can't be tagged by ARN, since rule/team/rule-1
reads as rule rule-1 on bus team; it stays reachable by exact name for the rule
and target operations only. A stack holding a legacy-named rule can still be
deleted, but an UpdateStack touching it fails because PutRule rejects the name.
* fix(eventbridge): report the length violation of a long partner bus name on permission calls
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
* test(cloudformation): drop the section divider above the partner bus provisioner tests
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
* docs(eventbridge): ground the partner bus permission rejection in the API model
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
* fix(eventbridge): keep a partner bus off a legacy rule that shares its key
A rule key joins the bus and rule name with a slash, so a slash-named rule
persisted by an earlier version on a custom bus named aws.partner (for
example example.com/orders/r1) has the same key as rule r1 on partner bus
aws.partner/example.com/orders. Rule lookups, ListRules and PutEvents now
check the stored rule's bus, so the partner bus neither lists, fires nor
manages that rule, and PutRule on the partner bus is rejected rather than
taking over the legacy rule's tags and targets.
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
* test(eventbridge): keep Step Functions target rule names within the 64 character limit
PutRule now rejects rule names longer than 64 characters, as AWS does. The
Step Functions integration test built names from a 16 character prefix, the
suffix and a UUID, so the missing-target rule name reached 67 characters and
PutRule rejected it before the test ran. Use a shorter prefix.
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
* fix(eventbridge): check a permission call's bus name against the modeled 256 character limit
PutPermission and RemovePermission type EventBusName as NonPartnerEventBusName, which the model bounds at 1 to 256 characters with pattern [\.\-_A-Za-z0-9]+. The partner bus check used the 64 character rule name limit, so a partner bus name of 65 to 256 characters drew a length violation AWS does not report.
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
---------
Signed-off-by: Tyler Webb <tyler.webb@verkada.com>
An AWS::RDS::DBInstance created through CloudFormation never received
its VPCSecurityGroups or StorageEncrypted, so describe-db-instances
showed neither. Both now reach the instance on create.
A stack update that changes the groups moves the instance to them in
place, and one that drops them puts a standalone instance on its VPC's
default group, as AWS does; a cluster member keeps its groups. A
rollback puts the previous groups back. StorageEncrypted can only be
set at create, so changing or dropping it replaces the instance: the
old one is deleted once the update commits and kept when it rolls
back. A custom-named instance refuses the change, as on AWS.
Part of #7603
The rollback test of a security group change now starts from two groups
and from none, as well as from one, so a saved list that kept only its
last group, or saved nothing for an instance that had none, fails it.
The line that saves the list now creates the array first, which reads
more plainly.
The docs and the encryption record's Javadoc now say that an instance
created before StorageEncrypted was applied, whose template sets it
through a parameter, does not see a change made only through that
parameter on its first update, as Ec2Tags.ownedKeys already notes for
tags.
The DB instance and DB cluster arms refuse a custom-named replacement
through CfnExceptions.customNamedReplacement, and the private copy is
gone.
The DB cluster's createOnly record and the AssociatedRoles record are
CreateOnlyInputs constants now, beside the DB instance's encryption
record, so all three are read, written, put back on a rollback and
cleared on commit through it. The attribute names are unchanged, so a
stack created before keeps its records, and an update that leaves the
cluster record as it was still saves no copy of it.
One thing changes with it: the roles record an update overwrites is now
saved every time, where it used to be saved only when no saved copy was
there. A committed in-place update used to leave that copy on the
resource, so a stack from then could have its roles record rolled back
to an older one by the first update that fails; a test covers it.
The encryption record's Javadoc and the docs now say that the previous
template resolves on the update, so a change made only through a
parameter, or anything else the update changes, is not seen.
An update whose template changed a cluster member's VPCSecurityGroups
moved the member to the new groups. On AWS the handler sends that change
to ModifyDBInstance and RDS refuses it for a member, whose groups are
its cluster's, so the update fails. It now fails the same way, with
InvalidParameterCombination and RDS's message, before anything on the
instance changes.
The change is read from the template, as AWS's handler reads it, so a
member whose list stays the same still updates, including one a stack
created before Floci applied the groups. Refusing the property outright
would fail a list that matches the cluster's, which the schema allows.
Create, update and delete StackSet resources and their instances through the existing StackSet service. Preserve current main's asynchronous automatic deployment and stable tag reads while reconciling the resource's declared account and organizational-unit targets and Regions.
Return StackSetId for Ref and Fn::GetAtt and cover the provisioner lifecycle with integration tests. OperationPreferences, CallAs and ParameterOverrides remain unsupported.
* fix(cloudformation): update the tags of an AWS::Events::EventBus in place
A tag-only UpdateStack of an event bus was refused with "Updating
AWS::Events::EventBus Description, Tags, or Policy is not supported until
transactional rollback is available." and rolled back, so a template that
bumps a version tag could not be deployed.
The bus the stack already owns now takes the template's tags: a key the
stack set and the template dropped is untagged, a tag added outside the
stack stays, as measured on AWS. The tags of the keys the update touches
are snapshotted first, and rollbackUpdate puts them and the tracked keys
back when a later resource fails the update. Description and Policy
changes are still refused.
Closes#7796
* fix(cloudformation): keep a failed event bus tag update for its rollback
A tag call that fails after the bus's tags started changing left the
engine restoring the previous resource and marking it rolled back, so
the half-applied tags stayed. retainsFailedUpdateState now keeps an
attempt that carries the tag snapshot, and the rollback walker restores
it through rollbackUpdate, as the SSM parameter provisioner does.
* test(cloudformation): read EventBridge answers through callEventBridge
* refactor(cloudformation): share the tag snapshot of an update with SSM
The event bus recorded and read back the tags of an update the same way
the SSM parameter does. CfnRollback now holds that pair, putTagSnapshot,
snapshotTagKeys and snapshotTags, in the same tagKeys and tags fields, so
a snapshot an SSM update already stored still reads. The bus reconciles
its tags from the managed keys and the desired tags, as SSM's
reconcileTags does, so its update and rollback no longer each work out
the keys to remove.
* fix(cloudformation): read a null tag value back as null from a tag snapshot
* refactor(cloudformation): read the event bus update snapshot through CfnRollback
rollbackEventBusUpdate parsed its snapshot by hand, which is what
CfnRollback.updateSnapshot does; it now uses that and still reports
false when the bus carries no snapshot. The CloudFormation docs say
event bus tags now update in place on UpdateStack, keeping tags added
outside the stack, and go back when a later resource fails the update.
Floci sent no event as a stack's status changed, so a rule on `CloudFormation Stack Status Change`
never fired, and whatever starts on one, a deploy waiting for its stack to finish among them, never
started. It also dropped `ClientRequestToken`, which is how a consumer ties an event to the
operation that caused it.
- CloudFormation User Guide, "Using Amazon EventBridge with CloudFormation": events go to the
default bus, "guaranteed to be delivered, and they might be delivered out of order".
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/eventbridge-integration.html
- CloudFormation User Guide, "CloudFormation stack status change event detail": the envelope,
`stack-id`, `status-details`, and "All events that are initiated by a given stack operation are
assigned the same client request token".
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/event-detail-stack-status-change.html
The pages say nothing of nested stacks, and their sample shows an empty token. Rules read on a real
account on 2026-10-30, for a root nesting one stack, showed one event per status. Through a create
change set, an update change set and DeleteStack, each with its own token, the root's events carried
their operation's token but for REVIEW_IN_PROGRESS, which had no key, and the nested stack's had no
key at all. Through a create and an update that failed in the nested stack, the root's rollback
statuses carried the create's or the update's token, the nested stack's again had no key, neither the
root's CREATE_FAILED nor any UPDATE_FAILED reached the bus, and the nested stack's failed create was
CREATE_FAILED and then DELETE_IN_PROGRESS and DELETE_COMPLETE, with no ROLLBACK_* status. Floci now
records and sends that: a nested stack records CREATE_IN_PROGRESS or UPDATE_IN_PROGRESS as its
operation starts, its failed create ends in CREATE_FAILED for its parent's rollback to delete, without
the "Rollback requested by user." CloudFormation's reason did not carry, and an update's first rollback
passes through UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS. An operation given no token leaves the key
out too.
Two cases were not read and no test asserts them: a failure in the root's own resource with the
nested stack healthy, and a delete that fails. They send CloudFormation's documented statuses from the
same code. UPDATE_COMPLETE_CLEANUP_IN_PROGRESS stays where Floci has cleanup to do, though
CloudFormation sent it on every update. A template Floci cannot execute at all still ends a root in
CREATE_FAILED and sends it, so that stack's end is not silent; the reading has no such path.
CloudFormationService.addEvent is the one place a status is recorded, so it queues an event for a
stack's own record, and CloudFormationEventPublisher delivers them in order on one daemon thread. A
status can be recorded under the stack's lock in stacks.compute and delivery calls a rule's targets
before it returns, so delivering in place would hold that lock and the operation for as long as the
targets take. A failed path records its event before it writes the status, so delivery waits a
moment for that write. The queue is in memory: an event still in it when Floci stops is dropped and
counted in the log, and is not sent on the next start.
The query handler hands each operation's token to the service, which sets it on the stack before the
operation's first record and clears it where the operation has none. It is not persisted.
test(cloudformation): an update failing outside a resource sends no UPDATE_FAILED
An update that fails before any resource, on an SSM parameter or a template that fails at execute,
goes straight to its rollback, and CloudFormation sends no UPDATE_FAILED, as for a failure in a
resource. On 2.4.0 the failed-execute path already sends none, so this commit carries the test alone
that keeps it so: the bus hears UPDATE_IN_PROGRESS, the rollback's statuses and nothing else, each
with the operation's request token.
(test cherry picked from commit 9314dad130116c5d4c809072800c787a4d640446, whose code change 2.4.0
makes moot)
fix(cloudformation): roll back a failed nested create's RetainExceptOnCreate, and send a start only once it runs
A nested stack's failed create is deleted by its parent's rollback through the
ordinary delete path, which kept what RetainExceptOnCreate marks. The delete of
a child in CREATE_FAILED now carries the create-rollback flag, so those
resources go as they did when the child rolled itself back, and a nested case
in CloudFormationDeletionPolicyIntegrationTest keeps it so.
The status an operation starts with is recorded under the stack's lock but
sent by the operation as its first act, so an operation the executor refuses
sends nothing. A successful create or update records its completion before
the terminal status is exposed, as the failed paths do, so the event carries
the operation's own token and not a later request's.
The publisher test waits for the worker to be sleeping or stopped instead of a
fixed 200 ms, and the status events test has one wait loop for the root's and
the nested stack's events.
fix(cloudformation): a delete deferred behind a running create sends its own token
A DeleteStack accepted while an execution runs waits for it, and until now
only its retain list waited: when the execution ended and the delete began,
the stack still held the execution's token, so DELETE_IN_PROGRESS and
DELETE_COMPLETE went out with it. The deferred delete now keeps its token
beside what it retains, and the stack takes it as the delete starts.
aDeleteLandingMidCreateCarriesItsOwnToken holds a custom resource's Create
open, lands the delete, and reads the tokens on the bus; it was red before.
The stale Javadoc above awaitEvents goes.
The mid-create test stubbed the ServiceToken Lambda and PUT the response itself,
which CustomResourceProbe already does. The probe takes a hold: the requests a
predicate matches wait before they are answered until the test releases them,
and the test reads when one has arrived. The status events test holds the
Create that way.
An update that drops DeploymentConfiguration from an AWS::ECS::Service now clears it. A dropped CapacityProviderStrategy or ServiceRegistries keeps the stored value, and a declared empty list clears either. A failed stabilisation puts the prior values back, and a deployment configuration the service did not have is put back as none.
Signed-off-by: Oleksandr Nikolaichuk <sekator778@gmail.com>
An AWS::EC2::Instance that names a launch template took the template's
image, type, key and metadata options but never its IamInstanceProfile,
so describe-instances showed no profile. When the instance declares no
profile of its own, it now launches with the template's, resolved the
same way RunInstances resolves it. The instance's own profile still wins.
A stack update that moves the instance to a template version naming
another profile, or none, changes or removes the profile in place, and a
dropped LaunchTemplate removes the profile it supplied. A rollback of an
update that changed the profile, whether the instance or its template
declared it, now puts the previous profile back instead of ending
UPDATE_ROLLBACK_FAILED.
Part of #7603
* fix(cloudformation): keep NAT gateway secondary addresses the stack never declared
* test(cloudformation): keep NAT gateway secondary addresses the stack never declared
* fix(cloudformation): a null NAT gateway secondary property counts as not declared
* test(cloudformation): a null NAT gateway secondary property counts as not declared
AWS returns a stack set's tags and the recorded root and OU deployment targets of a service-managed stack set. Read the same saved targets that ListStackSetAutoDeploymentTargets reports.
Replace the tag map on UpdateStackSet instead of clearing and refilling a map that a concurrent DescribeStackSet may be reading. Copy the request's tags so the published map is independent of later request changes.
Cover both response members, an update interleaved with tag iteration, and request-map isolation with regression tests.
Use the shared account-scoped InMemoryStorageFactory for the added regression tests instead of a private factory copy.
* fix(cloudformation): store stack policies and return them
* test(cloudformation): remove the stack policy test bucket after use
* fix(cloudformation): apply a stack policy with its stack operation
UpdateStack now stores its policy when the update commits, before UPDATE_COMPLETE is published, and CreateStack when execution starts. A policy-only update no longer leaves its change set FAILED. SetStackPolicy checks the stack state again under the stack lock after reading a StackPolicyURL.
* fix(cloudformation): apply a creation policy when the create is claimed
* fix(cloudformation): keep a rejected policy-only update executable
* fix(cloudformation): assign a stack policy when its change set is created
* test(cloudformation): stop the stack policy test's executor
* test(cloudformation): round-trip stack policies through persistent storage
* test(cloudformation): build the stack policy requests on CfnRequests
* test(cloudformation): construct CloudFormationService through one shared fixture
* fix(cloudformation): refuse a missing or malformed StackName in the stack policy actions
SetStackPolicy and GetStackPolicy looked a missing StackName up as the
stack named "null". Both now validate StackName first, as AWS does,
with the checks ContinueUpdateRollback already applies.
A failed stack update left AppSync entities changed or cleared by the update:
the provisioner had no rollbackUpdate, so the stack ended in
UPDATE_ROLLBACK_FAILED with "Rollback is not implemented".
Before an in-place update of a GraphQL API, data source, function, resolver or
API key, the provisioner records the members the update can change or clear.
The service applies an update member by containsKey, so replaying them puts
back both the changed and the cleared values. An update that fails part way
undoes itself through CfnRollback.guarded, and a failed undo keeps the
snapshot for ContinueUpdateRollback.
GraphQLSchema and a replaced AppSync resource are not covered.
tagResource, untagResource and putEnvironmentVariables change the stored API in place while updateGraphqlApi saves a copy, so a copy could overwrite a tag or variable written in between. Every method that writes a store now holds the service monitor, as startSchemaCreation does, and startSchemaCreation checks the API under it too. refreshGraphqlApiUris refreshes the stored API under the monitor instead of putting the instance it read earlier.
* fix(cloudformation): apply KinesisStreamSpecification on AWS::DynamoDB::Table
The property was accepted and ignored, so a stack that declared it got a
table whose item changes never reached the stream.
The declared stream becomes the table's active Kinesis streaming
destination on create and update. Removing a block the previous template
declared turns it off, and a stack that never declared it leaves
destinations set outside it alone. The in-place update snapshot of a
stack that manages the destinations records them, so a failed update
puts them back as they were.
A change of ApproximateCreationDateTimePrecision alone updates the active
destination in place, as CloudFormation does with one
UpdateKinesisStreamingDestination call, so forwarding never stops and
records already captured are still delivered.
A block that is not an object fails template validation, as
TimeToLiveSpecification does, rather than reading as a removed block
that turns forwarding off.
A StreamArn the destination cannot use fails the table as the AWS handler
does, and the table this attempt created is deleted. One under 37
characters fails EnableKinesisStreamingDestination's validation. One that
is not a Kinesis stream ARN, such as the stream name Ref returns, or one
naming a stream that does not exist fails as NotStabilized.
DynamoDbTableAccess gains enable, disable and update operations for the
destination. DynamoDB Local has no Kinesis forwarding, so that backend
leaves the table as it is and logs a warning. CloudFormation still checks
StreamArn there as AWS does; only the forwarding is skipped.
* fix(cloudformation): match Kinesis destinations by their whole stream ARN
A destination was looked up by the last segment of its StreamArn in the
table's account and region, so an ARN for another account, region or
resource type that ended in a local stream's name forwarded to that
stream. KinesisService.describeStreamByArn now finds a stream only by its
exact ARN. NativeDynamoDbTableService uses it, so the public
EnableKinesisStreamingDestination action reports such an ARN as not
found, and CloudFormation fails the table as NotStabilized.
The DynamoDB Local backend looks the stream up the same way before it
skips forwarding, so a template naming a missing stream fails there too.
A declared StreamArn the table already forwards to now goes through the
same template checks as a new one; only the rollback restore skips them.
* fix(ec2): support NAT gateway secondary addresses
* fix(ec2): update a NAT gateway's secondary addresses in place
A CloudFormation update that changed only a NAT gateway's Secondary*
properties replaced the gateway. The replacement was created while the old
gateway still held its Elastic IP or fixed private address, so it came back
failed with Resource.AlreadyAssociated (or InvalidIPAddress.InUse) and the
update failed. The schema does not mark the secondaries create-only, so AWS
changes them in place and the gateway keeps its id.
Ec2Service.updateNatGatewaySecondaryAddresses sets a gateway's secondaries
to the requested ones: kept ones stay, dropped Elastic IPs are handed back,
new ones are checked as CreateNatGateway checks them, and every check runs
before anything changes. The provisioner calls it instead of replacing, and
records the prior secondaries so a rolled-back update puts them back.
* fix(ec2): keep a NAT gateway's picked secondary when listed ones change
The counted slots of an in-place secondary update kept the first secondary
with no Elastic IP and an address the request does not list. With
SecondaryPrivateIpAddresses [A] and a count of 1 changed to [B] and 1, that
was the dropped listed A, while the address the subnet had picked was given
up. Counted addresses always follow the listed ones, so the counted slots now
keep the last such secondaries, in order.
Tests cover a count changed in place (an unrelated change keeps the same
addresses; 1 to 2 keeps the first; 2 to 1 keeps one of them), the picked
address surviving a listed change, and secondary Elastic IPs swapped between
listed addresses or moved to a new one, with DescribeAddresses showing each
held at its new address.
* test(ec2): pin which counted NAT gateway secondary an update keeps
The counted slots keep the last unlisted secondaries, so a count lowered
from 2 to 1 keeps the second address; the test now asserts that, and that
raising the count from 1 to 2 adds a new address in the subnet after the
kept one. The comment no longer claims counted addresses always follow the
listed ones: slot position is the only record of an address's origin, and
across updates a once-listed address can move behind a picked one.
* fix(ec2): read a NAT gateway under the allocation lock before updating its secondaries
The secondary-address update read the gateway before taking the lock that
DeleteNatGateway holds. A delete finishing in between left the update
holding a stale copy, which it then wrote back, re-associating the Elastic
IPs the delete had released and overwriting the association of a gateway
that had since taken the primary one. The gateway is now read again under
the lock, and one that is gone or deleted is refused with NatGatewayNotFound.
* test(cloudformation): read NAT gateway addresses through XmlParser
The secondary-address tests picked addresses out of DescribeNatGateways and
DescribeAddresses with a regular expression and substring checks that
depended on element order. They now select the non-primary items of
natGatewayAddressSet through XmlParser.
* test(ec2): cover a NAT gateway stored as deleted by a racing tag write
CreateTags writes a NAT gateway back under the gateway's tag lock, which
DeleteNatGateway does not take. A tag write that read the gateway before a
delete therefore stores the very record the delete marked deleted, so the
secondary-address update's deleted-state check is reachable. The test pauses
the tag write's put, deletes the gateway, lets the put finish, and asserts
the update refuses the record with NatGatewayNotFound and holds no Elastic
IP for it.
* refactor(ec2): fill a NAT gateway's address slots in one place
CreateNatGateway and the secondary-address update each walked the gateway's
slots the same way: take the listed Elastic IP and address at each
position, assign a free address where none is listed, build the address,
and give back what was assigned if a later slot fails. Both now call
fillNatGatewaySlots. Create passes its primary address as slot 0 and marks
it primary afterwards; the update passes the slots its kept secondaries
already fill. The order addresses are assigned in, the error codes and the
release on failure are unchanged.
* test(ec2): cover NAT gateway lease release and reuse the shared test helpers
No test covered the lease a NAT gateway gives back when its addresses run
out part way, so the shared slot-filling walk could lose its release with
every test green. Two tests now run a /28 subnet out of addresses, one
through CreateNatGateway and one through a secondary-address update, and
verify the lease taken on the VPC network is released and that the update
leaves the gateway as it was.
The concurrent-delete test now builds its service with mockModeService()
and waits for the blocked update with ThreadStates.awaitBlockedOrDone.
* test(ec2): build the small NAT subnet with privateSubnet
* fix(cloudformation): delete a stack whose create is still running only once the create stops
* fix(cloudformation): leave a deferred delete to the execution it waits on and report its failure
* fix(cloudformation): refuse a new execution once a delete has been deferred
* test(cloudformation): wait for stack statuses with the shared CfnStackWaits helper
* feat(cloudformation): provision AWS::EC2::KeyPair with its private key in Parameter Store
AWS::EC2::KeyPair had no provisioner, so a stack stubbed it: the stack
reached CREATE_COMPLETE without creating a key, Ref returned a made-up
id and Fn::GetAtt returned the literal "Key.KeyPairId". A template that
creates a key pair for an instance, as the AWS::EC2::KeyPair reference
shows, got nothing to log in with.
The new provisioner does what that reference describes:
- Without PublicKeyMaterial it calls CreateKeyPair with the template's
KeyType and KeyFormat, so rsa and ed25519 keys and pem and ppk files
all work, and stores the private key in the SecureString parameter
/ec2/keypair/<KeyPairId>. With PublicKeyMaterial it imports the key,
takes the key's type from the material (KeyType is ignored, as
documented) and writes no parameter.
- Ref is the key name; Fn::GetAtt KeyPairId and KeyFingerprint are the
key's own.
- Tags are applied once the key exists and the parameter is written
last, so a step that fails leaves only the key to undo. Deleting a
created key deletes its parameter first, on stack delete, rollback
and replacement cleanup alike; a key or parameter already gone counts
as deleted. A key is deleted by its name, as Cloud Control's
DeleteResource names it; a key deleted outside the stack still has
its parameter deleted with the stack.
- Only AWS::NoValue leaves a property out; an empty string a parameter
supplies is a value, as the same string written literally is. An
empty PublicKeyMaterial fails with the MissingParameter error
ImportKeyPair gives for it.
- Every property is create-only (the registry schema has no update
handler) and KeyName is required. An update that changes another
property under the same name is refused with CloudFormation's
custom-named replacement error. A rename creates the new key, then
deletes the old one with its parameter once the update commits, or
deletes the new one if the update rolls back.
The create-only list is added to create-only-properties.json, so a
change set reports a changed name or type as a replacement, and the
generated resource-type table lists KeyPair.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): delete orphaned key pair parameters on cleanup
Replacement cleanup and rollback delete a displaced or rolled-back
AWS::EC2::KeyPair by name only. When that key had already been deleted
outside the stack, its /ec2/keypair/<KeyPairId> SecureString parameter
was left behind.
Record the id of each created key the resource still owes a delete,
keyed by name, so the cleanup, the rollback and a rollback retry also
delete that key's parameter. Imported keys have no parameter and are
not recorded.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): end a key pair's rollback retry when an update starts
A rollback that could not delete a renamed key pair's replacement leaves
it owed for ContinueUpdateRollback. Once that skipped the resource, a
later update that failed before creating anything rolled back by
retrying that old delete instead of undoing itself, and could end in
UPDATE_ROLLBACK_FAILED.
Call ReplacementCleanup.endRollbackRetry as an update starts, as the
other replacing provisioners do. The replacement stays listed, so the
next committed update or the stack delete still removes it.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudformation): say the rollback retry test pins a helper contract
The test added with the endRollbackRetry call rolls back the same
resource whose update failed. The engine does not do that for a key
pair today: it restores the previous resource and skips its rollback,
so the earlier commit's UPDATE_ROLLBACK_FAILED scenario is not
reachable yet. Say that the test pins the ReplacementCleanup contract
instead.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): clean up partial KeyPair parameter writes
* refactor(cloudformation): share KeyPair create-only tracking
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
A property the previous template declared and the new one drops is now
cleared on update for the EC2 network types: Tags on Subnet,
InternetGateway, RouteTable, NatGateway, EIP and PrefixList, and
MapPublicIpOnLaunch on Subnet, which goes back to false. A property the
stack never declared keeps what was set outside it. A failed update puts
the cleared tags and the flag back from the existing in-place snapshot.
Refs #6606
* fix(cloudformation): transform SAM layer versions
Map packaged layer content to Lambda layers, retain version-specific resource identities, and preserve references and retention behavior. Cover publication, replacement and deletion through CloudFormation.
* fix(cloudformation): preserve typed and inherited SAM layer references
Rewrite captured Globals references, retain typed list references for provisioning, and restrict dependency rewriting to resource attributes. Cover each case in unit regressions and stack creation/update.
* fix(cloudformation): keep Fn::Sub overlay variables out of parameter substitution
A variable map localizes names for the template engine, so resolving a
same-named stack parameter first consumed the placeholder and left the map
dead: Key: !Sub ['${Key}', {Key: 'layer.zip'}] published the parameter's
value instead of the layer package the author named.
* refactor(cloudformation): fold SAM logical-id hashing into one helper
The layer-version and function-version generated ids serialized their hash
input the same way - properties sorted, non-ASCII escaped, DEL escaped, then
the first ten hex digits of the SHA-1 - but as two copies. Extract samHashSuffix
so a generated id is its subject plus one shared suffix. Ids are unchanged.
* fix(cloudformation): deploy SAM layers from original content expressions
The transform resolved ContentUri parameters before copying them onto the
generated AWS::Lambda::LayerVersion, so a parameter value that itself held
a ${...} was published inside a Fn::Sub and CloudFormation substituted it a
second time at deploy. Deploy the bucket and key expressions as written and
let the template engine resolve them once; keep the resolved copy only as
the hash input, so a versioned package still yields a distinct logical id.
* fix(cloudformation): keep Fn::Sub local variables out of layer rewrites
The recursive layer-reference walk re-entered an Fn::Sub node through the
blanket children loop, so it treated a variable map as another expression.
With a local variable literally named Ref whose value was a layer's logical
id, the walk rewrote that literal into the generated id and changed what the
stack deployed. Rewrite only the map's values as intrinsic contexts and skip
the already-handled Fn::Sub node in the walk.
* fix(lambda): read a layer's pinned S3 object version
A SAM layer with a packaged ContentUri.Version, or an
AWS::Lambda::LayerVersion whose Content sets S3ObjectVersion, publishes that
pinned package, but the provisioner fetched the object with a null version
and so read the latest one. If the key changed after publishing, the layer
ended up with different code than the template requested. Pass
S3ObjectVersion through to the S3 read so a pinned package stays pinned.
* fix(cloudformation): resolve a whole ContentUri reference before splitting it
Keeping the original ContentUri expressions on the generated layer means a
ContentUri that is itself a parameter reference arrives as a Ref object with
no Bucket or Key, and the transform rejected the stack. Resolve such a
reference to the location it names and split that, while the object form
keeps its expressions for the template engine to resolve at deploy.
* fix(cloudformation): honor retained resources on stack deletion
* test(cloudformation): assert the unretained sibling bucket is removed
* fix(cloudformation): skip every retained resource, whatever its status
A DELETE_FAILED stack can hold a CREATE_FAILED resource that the delete
never touches, because floci only deletes a failed resource it owns for
rollback. Naming it in RetainResources was accepted but left it
CREATE_FAILED with no DELETE_SKIPPED event. AWS reports every retained
resource DELETE_SKIPPED, so the retain check now runs before the
deletability guard.
* test(cloudformation): build the retain integration test on the shared CFN helpers
Use CfnStackWaits.awaitStatus, which also fails at once on another
terminal status, instead of a private poll, and CfnRequests.cfn for the
Query requests.
* fix(cloudformation): keep SMS_MFA on a user pool update until MFA is turned off
The AWS::Cognito::UserPool reference says that once SMS_MFA is enabled, only
MfaConfiguration OFF turns it off. An update that stopped listing SMS_MFA in
EnabledMfas cleared it. replaceUserPoolMfaConfig now keeps the pool's SMS
setting when none is given and the mode is not OFF.
Closes#7086
* fix(cognito): keep SMS MFA with the pool's current SMS settings
Keeping SMS MFA replayed the settings it was enabled with, so an update that
dropped SMS_MFA and changed SmsAuthenticationMessage or SmsConfiguration put
the old values back over the ones updateUserPool had just applied. The kept
SMS MFA now takes the pool's current message and SMS configuration.
* fix(cloudformation): clear an AppSync property the new template drops on update
An update whose template drops a property the previous template declared now clears it on the five AppSync types, and one the stack never declared keeps the value set outside it. ProvisionContext.droppedProperties names the dropped properties.
* test(cloudformation): move the AppSync removal case into AppSyncCfnIntegrationTest
The case reuses the class's helpers, now built on CfnRequests.cfn, instead of a second copy. Documents the AppSync update rule next to the AWS::NoValue section.
* fix(ec2): report NAT gateways as zonal and honor PrivateIpAddress
The Terraform AWS provider reads network_interface_id, private_ip and
public_ip from a NAT gateway only when it is reported with
availabilityMode zonal. Floci never sent availabilityMode, so all three
stayed null. Every gateway Floci creates sits in one subnet, so the
responses now say zonal.
Floci has no regional NAT gateways. A regional request that named only
its VPC failed on the missing subnet, and one that also named a subnet
got a zonal gateway, through both CreateNatGateway and
AWS::EC2::NatGateway. Both now refuse AvailabilityMode regional with
UnsupportedOperation. Any other value except zonal, such as Regional,
fails with InvalidParameterValue instead of creating a zonal gateway.
Once Terraform reads private_ip back, the gateway has to hold the
address it was asked for. private_ip forces a new gateway, and
CreateNatGateway ignored PrivateIpAddress, so a config that set it
would plan a replacement on every run. CreateNatGateway and
AWS::EC2::NatGateway now give the gateway's interface the requested
address, checked by the same rules as RunInstances: inside the subnet,
not reserved and not in use. A changed PrivateIpAddress replaces the
CloudFormation resource, as it is createOnly. A gateway has its primary
address only, so SecondaryAllocationIds, SecondaryPrivateIpAddresses
and SecondaryPrivateIpAddressCount are refused with
UnsupportedOperation instead of being dropped.
AWS::EC2::NatGateway also sets EniId, the gateway's primary interface,
which Fn::GetAtt resolved to the literal "Nat.EniId" although the
gateway has had a real interface since #5622.
Closes#6767
* fix(ec2): take no VPC network lease for a NAT gateway's requested address
DeleteNatGateway never returns a lease, so the one CreateNatGateway took
for its PrivateIpAddress kept the address from automatic allocation
after the gateway was gone. Check that the address is free the way
CreateNetworkInterface does, without the lease; automatic allocation
already steps around addresses a stored NAT gateway holds.
Ec2NatGatewayAddressIntegrationTest now sends its requests through the
shared Ec2Requests.ec2 instead of its own copy.
* fix(cloudformation): apply EnabledMfas on AWS::Cognito::UserPool
* docs(cloudformation): move the EnabledMfas note to the resource-type table source
* fix(cloudformation): drop the MFA factors EnabledMfas no longer lists on update
* fix(cognito): apply EnabledMfas mode and factors in one write
* fix(cloudformation): roll back EnabledMfas with the rest of the user pool
* fix(cognito): serialize whole-pool writes behind a per-pool lock
replaceUserPoolMfaConfig stores a copy of the pool, so a TagResource that
landed between the copy and the write was lost. Tag and untag locked the
pool instance, which the copy replaces, so they did not exclude it.
Every write that reads a pool and stores it back whole now holds a lock
keyed by the pool id and reads the pool inside it.
* test(cloudformation): ratchet the writable properties each provisioner reads
* test(cloudformation): use colons in the coverage messages and scope the docs paragraph to the corpus
* test(cloudformation): list the writable properties main and the schema added since the ratchet
* feat(redshift): support event history and SNS notifications
* fix(redshift): guard stale delivery failures and prune all event scopes
* feat(cloudformation): provision Redshift event subscriptions
* fix(redshift): scope snapshot events and serialize subscription tag mutations
* feat(cloudformation): provision Redshift event subscriptions
* fix(cloudformation): resolve Redshift subscription list parameters
Use the shared list reader for SourceIds and EventCategories. Cover CommaDelimitedList and List<String> parameters through the AWS SDK and verify concurrent tag requests preserve CloudFormation tag updates.
* fix(redshift): honor event disablement and restore rollback attributes
Check the EventBridge external service key before publishing API events. Snapshot and restore CloudFormation resource attributes alongside subscription state during in-place rollback.
* fix(redshift): drop API event publisher and share subscription setup
Remove RedshiftApiEventPublisher, its handler hook, tests and docs, which are not part of the CloudFormation resource and emit CloudTrail-style events without a trail. Route createSubscription and replaceSubscription through one helper that normalizes the subscription fields.