refactor(cloudformation): move AWS::Logs::LogGroup into its own provisioner - #2756
Open
hectorvent wants to merge 1 commit into
Open
refactor(cloudformation): move AWS::Logs::LogGroup into its own provisioner#2756hectorvent wants to merge 1 commit into
hectorvent wants to merge 1 commit into
Conversation
…sioner Behaviour-preserving move of the log group's provision and delete paths. Unlike the earlier slices this one carries a real update path: the body decides between reconciling in place and replacing, from the prior physical id and the recorded FlociLogGroupNameMode, and it infers that mode from the physical id's shape for stacks persisted before the attribute existed. Uses ctx.priorPhysicalId() rather than reading it back off the StackResource. The two are equal on entry, but the method assigns the new physical id before it finishes, so a context-captured value cannot be invalidated by a later edit to the body. UPDATE_ROLLBACK_RESTORED_ATTR moves to CfnRollback, which exists for exactly this: it was package-private on the monolith and so unreachable from the provisioners package. The monolith's constant now delegates there, leaving CloudFormationService's two references untouched. reconcileLogGroup moves with the slice. isGeneratedName and its prefix helper are copied, because a type that has not migrated yet still calls them, and logsService leaves the monolith entirely. CloudFormationLogGroupProvisionerTest keeps testing through the dispatcher, now with the provisioner registered. That is load-bearing rather than decoration: with an empty registry the type would reach the stub arm and the test would assert against a synthetic id. Going through the dispatcher also covers the plumbing this migration changed, that existingPhysicalId and existingAttributes reach ProvisionContext.
|
| Filename | Overview |
|---|---|
| src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LogsCfnProvisioner.java | Extracts LogGroup create, update, replacement, reconciliation, attribute generation, and delete behavior without an actionable semantic regression. |
| src/main/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationResourceProvisioner.java | Removes the migrated switch and delete arms while retaining registry-first dispatch and the shared rollback constant alias. |
| src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/CfnRollback.java | Exposes the unchanged update-rollback marker value to extracted provisioners. |
| src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/LogsCfnProvisionerTest.java | Adds focused coverage for creation, reconciliation, replacement, rollback marking, attributes, and deletion. |
| src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationLogGroupProvisionerTest.java | Preserves dispatcher-level legacy name-mode coverage with explicit provisioner registration. |
| src/test/resources/cloudformation/supported-resource-types.tsv | Updates the inventory owner from the legacy switch to LogsCfnProvisioner. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[CloudFormation update] --> B[Resource registry]
B --> C[LogsCfnProvisioner]
C --> D{Same physical name exists?}
D -->|Yes| E[Reconcile retention and tags]
D -->|No| F[Create replacement]
F --> G[Delete prior group when present]
E --> H[Store physical ID, ARN, and name mode]
G --> H
Reviews (1): Last reviewed commit: "refactor(cloudformation): move AWS::Logs..." | Re-trigger Greptile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
AWS::Logs::LogGroupintoLogsCfnProvisioner. Behaviour-preserving, but this is thefirst slice carrying a real update path: the body decides between reconciling in place and
replacing, based on the prior physical id and the recorded
FlociLogGroupNameMode, and infers thatmode from the physical id's shape for stacks persisted before the attribute existed.
Monolith 7,315 → 7,208 lines; legacy switch 70 → 69 types. Docs table unchanged, as expected.
Stacked on #2754 → #2744 → #2739. Review those first.
Three things this slice needed that earlier ones did not
UPDATE_ROLLBACK_RESTORED_ATTRmoved toCfnRollback. It was package-private on the monolith,so unreachable from the
provisionerspackage.CfnRollbackexists for exactly this (it was addedto solve the same problem for the IAM role rollback constants). The monolith's constant now
delegates there, so
CloudFormationService's two references are untouched.Uses
ctx.priorPhysicalId()rather than reading it back off theStackResource. The two areequal on entry, but the method assigns the new physical id before it finishes, so a
context-captured value cannot later be invalidated by an edit to the body. This is the first real
use of the accessor added in #2732.
The existing regression test stays pointed at the dispatcher, now with the provisioner
registered. That is load-bearing, not decoration, and I verified it by mutation: dropping the
registration makes both tests fail with
which is the dispatcher's stub arm answering instead of the provisioner. Testing through the
dispatcher also covers the plumbing this migration changes, that
existingPhysicalIdandexistingAttributesreachProvisionContext.reconcileLogGroupmoves with the slice;isGeneratedNameand its prefix helper are copied,because a not-yet-migrated type still calls them.
logsServiceleaves the monolith entirely (itsconstructor parameter stays, unused, until the endgame).
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
N/A for the wire protocol.
aws-logs-loggroup.jsongivesprimaryIdentifierLogGroupNameandread-only
Arn; both are asserted,Arnin the exactarn:aws:logs:<region>:<account>:log-group:<name>:*form AWS uses.The AWS behaviour this preserves is that
LogGroupNameis not updatable in place: a rename createsthe replacement before deleting the original, so a colliding name fails the update without
destroying the existing group.
Checklist
./mvnw testpasses locallyCloudFormation + Cloud Control: 854 tests, 0 failures, 0 errors.
LogsCfnProvisionerTestadds11 covering both update branches, retention set and cleared, tag removal on reconcile, an
unparseable
RetentionInDays, the explicit-name-removed replacement, the generated-name-keptno-op, and the failed-rename case that must leave the original intact and flag the rollback. The
#1965 legacy-name-mode regression test is preserved unchanged apart from the registration line.