Skip to content

Commit 7f1e80e

Browse files
committed
Integrate CR feedback - use prefixListID as the only filter
1 parent 05a6d92 commit 7f1e80e

File tree

7 files changed

+23
-38
lines changed

7 files changed

+23
-38
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ api_directory_checksum: b558bf9c1a38a2d20a3521ab1048281ad80d5b29
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: 32b9b52f3a9103c18e42ef8de5494bd046da56eb
10+
file_checksum: e585554e1f3218c74b5ed72bc84804c2604a617c
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ operations:
233233
resource_name: LaunchTemplate
234234
DescribeLaunchTemplates:
235235
custom_check_required_fields_missing_method: checkForMissingRequiredFields
236+
DescribeManagedPrefixLists:
237+
custom_check_required_fields_missing_method: checkForMissingRequiredFields
236238
CreateNatGateway:
237239
output_wrapper_field_path: NatGateway
238240
CreateNetworkAcl:

generator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ operations:
233233
resource_name: LaunchTemplate
234234
DescribeLaunchTemplates:
235235
custom_check_required_fields_missing_method: checkForMissingRequiredFields
236+
DescribeManagedPrefixLists:
237+
custom_check_required_fields_missing_method: checkForMissingRequiredFields
236238
CreateNatGateway:
237239
output_wrapper_field_path: NatGateway
238240
CreateNetworkAcl:

pkg/resource/managed_prefix_list/hooks.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,10 @@ func (rm *resourceManager) customUpdateManagedPrefixList(
181181

182182
return desired, nil
183183
}
184+
185+
// checkForMissingRequiredFields validates that PrefixListID is present in Status
186+
// before attempting a read. Prefix list names are not unique in AWS, so we require
187+
// the ID for safe lookups.
188+
func (rm *resourceManager) checkForMissingRequiredFields(r *resource) bool {
189+
return r.ko.Status.PrefixListID == nil
190+
}

pkg/resource/managed_prefix_list/sdk.go

Lines changed: 5 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
// If we have a PrefixListID, use it to filter the describe call
1+
// Prefix list names are not unique in AWS, so we must filter by ID
2+
// If we don't have a PrefixListID yet, the resource hasn't been created
23
if r.ko.Status.PrefixListID != nil {
34
input.PrefixListIds = []string{*r.ko.Status.PrefixListID}
4-
} else if r.ko.Spec.PrefixListName != nil {
5-
// If we don't have an ID yet, filter by both owner ID and prefix list name
6-
// This prevents matching against AWS-managed prefix lists
7-
// and other user-owned prefix lists with different names
8-
filters := []svcsdktypes.Filter{
9-
{
10-
Name: aws.String("owner-id"),
11-
Values: []string{string(rm.awsAccountID)},
12-
},
13-
{
14-
Name: aws.String("prefix-list-name"),
15-
Values: []string{*r.ko.Spec.PrefixListName},
16-
},
17-
}
18-
input.Filters = filters
195
}
206

templates/hooks/managed_prefix_list/sdk_read_many_post_set_output.go.tpl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// Get the entries separately
1+
{{ $CRD := .CRD }}
2+
{{ $SDKAPI := .SDKAPI }}
3+
4+
// Get the entries separately - DON'T overwrite Spec.Entries
25
if ko.Status.PrefixListID != nil {
36
entriesResp, err := rm.sdkapi.GetManagedPrefixListEntries(
47
ctx,
@@ -27,5 +30,3 @@
2730
ko.Spec.Entries = nil
2831
}
2932
}
30-
31-

0 commit comments

Comments
 (0)