mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
* fix(cloudformation): keep unchanged VPCs and security groups on stack update provision() re-runs for every resource on every UpdateStack, changed or not. Ec2VpcCfnProvisioner called createVpc() and provisionSecurityGroup() called createSecurityGroup() unconditionally, so an untouched VPC or security group was re-created under a fresh id on every update - silently orphaning every subnet, route table and group that referenced the old one. The security group case hid behind the VPC one: because the VPC id changed too, the (name, vpcId) duplicate check never fired, so the stack still reported UPDATE_COMPLETE while leaking a second group. Both now reuse the resource the stack already points at. A changed CidrBlock (VPC) or a changed GroupName (security group) is still treated as a replacement, and a resource deleted out of band still falls back to create. Adds CfnUnchangedResourceUpdateIntegrationTest, which asserts physical-id retention across an update for VPC, security group, S3 bucket, SQS, SNS, log group, ECR, KMS alias and Kinesis. Asserting UPDATE_COMPLETE alone is not enough - a re-created resource passes that while breaking every reference to it. * fix(cloudformation): reconcile a reused security group's inline rules Reusing an unchanged security group instead of re-creating it exposed a second bug in the same arm: authorizeSecurityGroupIngress/Egress append without a duplicate check, and the inline SecurityGroupIngress/SecurityGroupEgress loops run on every provision pass. A reused group therefore accumulated another copy of every inline rule on each UpdateStack. Re-creating the group had masked this, since each update authorized onto a brand new group. Clear the rule sets the template declares before re-authorizing, which also drops rules the template no longer lists. A set the template does not declare is left alone, so a group keeps its default egress. Also narrows reuse: GroupName, GroupDescription and VpcId are immutable on a security group, so a template that changes one wants a new group rather than an edit to this one. Only the GroupName check was exercised before. Adds securityGroupInlineRulesAreNotDuplicatedByAnUpdate, which asserts the group still describes each inline rule exactly once after an update. Verified non-vacuous: without the revoke it fails with the rule present twice. * test(cloudformation): focused provisioner coverage for AWS::EC2::VPC Mirrors S3CfnProvisionerTest: mocks only Ec2Service and pins the create path's Fn::GetAtt keys (VpcId, CidrBlock, DefaultSecurityGroup) alongside the three update outcomes - reuse when nothing changed, replacement on a changed CidrBlock, and a fresh create when the VPC is gone from the backend. The integration test asserts physical-id retention end to end but cannot show which service call was made; this pins that createVpc is not called at all on an unchanged update. * fix(cloudformation): authorize only the inline rules a group is missing Clearing the declared rule sets before re-authorizing fixed the duplication but introduced a worse defect: a group can also carry rules from standalone AWS::EC2::SecurityGroupIngress/Egress resources, and the revoke took those with it, so an unrelated stack update silently closed ports another resource owns. A rule rejected mid-authorize also left the prior set already deleted, with nothing to restore it. Reconciliation is now additive. Each declared rule is authorized only when the group does not already carry it, compared on a canonical key since IpPermission and its range types define no equals. Nothing is revoked, so neither failure mode is reachable. The trade-off is explicit: a rule dropped from the template is no longer revoked. Doing that safely needs the provisioner to record which rules it authorized, which this arm cannot do while it lives in the legacy monolith. Also compares the VpcId a template would actually resolve to rather than the raw property. createSecurityGroup resolves an omitted VpcId to the region's default VPC, so the stored group always has one - comparing against a null property let a template that drops VpcId keep a group in the VPC it had named. Adds anUpdateLeavesRulesOwnedByStandaloneResourcesAlone. Verified non-vacuous: restoring the revoke fails it with the standalone rule gone. * fix(cloudformation): branch AWS::EC2::VPC on the context's prior id provision() serves create and update, and assigns the new physical id onto the resource as it runs, so deciding create-vs-update by reading that id back flips mid-method. AGENTS.md step 4 asks for ctx.isUpdate()/ctx.priorPhysicalId() instead, and the Scheduler provisioner shed the same pattern in #2985. The two agree on today's call path, since the engine seeds both from the same existing id, so this is the convention rather than a live defect. The test was the part that had it wrong: it built a create-path context and set the prior id only on the resource, so it passed either way. Pinned by anIdOnTheResourceAloneDoesNotCountAsAnUpdate, which provisions a resource carrying an id under a create context and fails when the VPC is looked up for reuse instead of created. * fix(cloudformation): match a security group rule that names its peer A rule naming its peer through SourceSecurityGroupName was re-authorized on every update. Ec2Service.resolveGroupReferences fills in groupId on the pair as it records the rule, the declaration toIpPermission hands back on the next pass carries only the name, and the duplicate key preferred the id whenever one was present, so the two forms never matched and the group accumulated another copy of the rule each time. Both sides now resolve a bare name to its group id before keying, the same lookup the service performs, confined to the group's own VPC because names are unique per VPC. A name matching nothing there stays a name, which is also what the service does, so an unresolvable peer still compares equal to itself. Pinned by aRuleNamingItsPeerByNameIsNotDuplicatedByAnUpdate, which reports the rule twice when the resolution is dropped. Its DependsOn is load-bearing: the peer has to exist when the rule is first authorized, or the stored pair keeps the unresolved name and both sides agree for the wrong reason. Also moves a doc comment back onto the test it describes. * test(cloudformation): parse the describe body with XmlParser The physical-id helper pulled LogicalResourceId/PhysicalResourceId pairs out of the DescribeStackResources response with a regex, which the repo rules forbid for XML. extractGroups on "member" gives the same pairs as a map per resource, so the member is picked by its logical id rather than by matching across tags.