mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(cloudformation): validate prefix list entries before update diffing (#6725)
This commit is contained in:
1 parent
a4ef9eaa6a
commit
d58ce5c31c
4 files changed
+72
-6
No files matched your search
+5
-3
@@ -702,6 +702,9 @@ public class Ec2NetworkCfnProvisioner implements CfnResourceProvisioner {
|
||||
throw new AwsException("ValidationError", PREFIX_LIST + " cannot change the AddressFamily of prefix list "
|
||||
+ existing.getPrefixListId() + " from " + existing.getAddressFamily() + " to " + family, 400);
|
||||
}
|
||||
if (entries != null) {
|
||||
entries.forEach(entry -> ec2Service.validatePrefixListEntry(entry, family));
|
||||
}
|
||||
List<PrefixListEntry> desired = entries != null ? entries
|
||||
: ctx.previouslyDeclared("Entries") ? List.of() : existing.currentEntries();
|
||||
EntryChanges changes = EntryChanges.between(existing.currentEntries(), desired);
|
||||
@@ -800,9 +803,8 @@ public class Ec2NetworkCfnProvisioner implements CfnResourceProvisioner {
|
||||
/**
|
||||
* What takes a prefix list from its current entries to the desired ones: the entries to add and the
|
||||
* CIDRs to remove, with an entry whose block is both removed and added back (a changed description)
|
||||
* kept apart as a CIDR to {@code redescribe} and an entry to {@code readd}. An entry matches when its
|
||||
* CIDR is the same block and its description is the same, so a CIDR written with host bits does not
|
||||
* read as a change.
|
||||
* kept apart as a CIDR to {@code redescribe} and an entry to {@code readd}. Validated entries match
|
||||
* when their CIDRs identify the same block and their descriptions are the same.
|
||||
*/
|
||||
private record EntryChanges(List<PrefixListEntry> add, List<String> remove, List<String> redescribe,
|
||||
List<PrefixListEntry> readd) {
|
||||
|
||||
@@ -2076,7 +2076,8 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePrefixListEntry(PrefixListEntry entry, String addressFamily) {
|
||||
/** Validates an entry before a consumer computes or applies a prefix-list update. */
|
||||
public void validatePrefixListEntry(PrefixListEntry entry, String addressFamily) {
|
||||
if (entry.getCidr() == null || entry.getCidr().isBlank()) {
|
||||
throw new AwsException("MissingParameter", "Every prefix list entry must specify a Cidr.", 400);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user