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.
With AutoPublishAlias, SAM passes a function's VersionDescription to the
Description of the AWS::Lambda::Version it generates. The transform
dropped it, so a version published from a SAM template never had the
description the template gave it.
The version now takes it as written, leaving an intrinsic function for
CloudFormation to resolve. As in SAM, it stays out of the hash that
names the version, and Globals cannot set it: the transform refuses it
there, as it already refuses AutoPublishCodeSha256.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
A RecordSetGroup writes all its record sets into one hosted zone in a
single ChangeResourceRecordSets batch, so a record set that cannot be
written, such as a name another owner already holds, leaves the zone
unchanged and fails the stack. Each record set keeps what a RecordSet
keeps, including the routing-policy fields SetIdentifier, Weight,
Region, Failover and HealthCheckId; entries an Fn::If resolves to
AWS::NoValue are dropped, and two record sets with one name, type and
set identifier are refused. Ref returns the group's logical ID and
Fn::GetAtt Id the change ID that GetChange reads, as AWS documents.
The zone comes from the group's HostedZoneId or HostedZoneName, or from
its record sets when the group names neither. A record set that repeats
the group's HostedZoneId is refused, as AWS documents, and so is one
that names another zone.
An update in the same zone deletes the records the group wrote and
creates the new ones in one batch. HostedZoneId and HostedZoneName are
create-only, so a change set reports a zone change as a replacement:
the records are written into the new zone, and the old ones are deleted
once the update commits, or kept under UpdateReplacePolicy: Retain. A
failed update puts back the records the group had; after a zone change
the group first points at its old records again, then deletes the new
zone's. If that delete fails, ContinueUpdateRollback retries it and
DeleteStack deletes those records while the rollback is unfinished;
anything else leaves them in their zone, since Route 53 cannot tell
them apart from an identical record another writer puts there later.
Deletes name the values the group wrote, so a record changed outside
the stack fails the delete rather than being removed.
The docs say what a record set group's failed rollback leaves behind.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* fix(cloudformation): relocate SAM schemes without auth defaults
Follow the separate postprocessing request in upstream #6638. Relocate declared OpenAPI security schemes independently of Auth defaults, preserving Swagger and operation requirements.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(sam): centralize OpenAPI security scheme relocation
Keep the defaults helper responsible only for generating AWS_IAM and api_key definitions. Relocate the security scheme map exclusively in the shared final OpenAPI phase, including documents without Auth defaults.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
---------
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
Follow the separate whole-map replacement requested in upstream #6632. Preserve Swagger, no-default behavior, operation requirements and unrelated OpenAPI components.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* feat(lambdamicrovms): version network connectors as AWS does
* fix(lambda): lock connector versions and refresh them after a CFN rollback
Updates, deletes and version reads hold one lock, so two updates cannot
take the same version number.
A CloudFormation rollback restores the connector through an update. On
AWS that makes the next version, and a later Fn::GetAtt returns it. The
resource now keeps that version in LatestVersion and LatestVersionArn.
Read the connector ARN through AwsArnUtils.parse.
AWS refuses LatestVersion, an integer, as a string Output, so the stack
test reads LatestVersionArn only.
* fix(lambda): type the connector LatestVersion attribute as an integer
AWS::Lambda::NetworkConnector declares LatestVersion as an integer. On AWS
a stack whose string Output reads it fails with "Template format error:
Every Value member must be a string.", and Fn::Sub refuses it with
"variable Connector.LatestVersion in Fn::Sub expression does not resolve
to a string".
* chore(lambda): share the connector version ARN and integer attribute helpers
* feat(cloudformation): provision AWS::EC2::PrefixList
An AWS::EC2::PrefixList was stubbed: Ref returned "<LogicalId>-<8 hex>",
Fn::GetAtt the literal "<LogicalId>.<Attribute>", and EC2 held no list, so
a route given its Ref pointed at nothing. Ec2NetworkCfnProvisioner now
creates the customer-managed list through Ec2Service. Ref is its pl- id,
and Fn::GetAtt serves PrefixListId, Arn, OwnerId and Version, the
attributes the registry schema declares.
The schema has no create-only property, and create-only-properties.json
now says so. Without the entry, the engine's name heuristic took
PrefixListName for create-only, so a rename was planned as a replacement
of the list and of the routes and rules that reference it. An update
changes the list in place: its name, capacity, entries and tags. Adding or
removing entries makes a new version and a rename does not, as the EC2 API
reference says. EC2 refuses a request that removes and adds the same CIDR,
which is how a description changes (Terraform's
aws_ec2_managed_prefix_list records the error), so such an entry is added
back by a second ModifyManagedPrefixList call. The first call carries
everything EC2 could refuse, and the capacity the second needs is checked
before the first, so a change EC2 refuses leaves the list as it was. A
rollback puts the prior name, capacity, entries and tags back, and Version
follows the list.
Two updates fail before anything changes: another AddressFamily, which no
EC2 call can change on an existing list, and a new MaxEntries together
with changed Entries, which the CloudFormation and EC2 references both say
cannot change at once. MaxEntries is required to create a list, as the
CloudFormation reference says (aws/aws-cdk#35360 reports the deploy
failing without it); an update that leaves it out keeps the capacity.
Entries and Tags are brought to the template when it, or the previous one,
declares them, so entries or tags no template declared stay. Tags go
through CreateTags after the create, as on the other types in the
provisioner, so EC2 checks them; a tag it refuses fails the create and
removes the new list. A list gone out of band, or a stub an older Floci
left, is replaced by a new one, and a stack delete tolerates only
InvalidPrefixListID.NotFound.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* test(cloudformation): cover AWS::EC2::PrefixList through boto3
A stack's prefix list is created, resized, given new entries and deleted
through the CloudFormation and EC2 clients of the pinned boto3: Ref and
Fn::GetAtt name the list EC2 describes, a resize keeps the version, new
entries make version 2 of the same list, dropping Tags removes them, and
the list is gone after the stack delete.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
* refactor(cloudformation): share optionalInt through ProvisionContext
Ec2NetworkCfnProvisioner and ElbV2CfnProvisioner each carried the same
private optionalInt. An absent, null or AWS::NoValue property stays unset;
a value written into the template, a literal blank included, has to be an
integer; anything else fails with ValidationError "Value of property
<name> must be an integer." It is now ProvisionContext.resolveOptionalInt,
beside resolveOptional, and all seven callers use it: the prefix list's
MaxEntries, the target group's Port and four health check settings, and
the gateway listener's Port.
The two copies differed only in Integer.parseInt against Integer.valueOf
and in building the error through a helper, so neither provisioner
changes behaviour. ProvisionContextTest covers the method directly.
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
---------
Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>