@@ -312,13 +312,26 @@ func (rm *resourceManager) EnsureTags(
312312{{- end }}
313313}
314314
315- // FilterAWSTags ignores tags that have keys that start with " aws:"
316- // is needed to ensure the controller does not attempt to remove
317- // tags set by AWS. This function needs to be called after each Read
318- // operation.
319- // Eg. resources created with cloudformation have tags that cannot be
320- //removed by an ACK controller
321- func (rm *resourceManager) FilterSystemTags(res acktypes.AWSResource) {
315+ // FilterSystemTags removes system-managed tags from the resource's tag collection
316+ // to prevent the controller from attempting to manage them. This includes:
317+ // - Tags with keys starting with " aws:" (AWS-managed system tags)
318+ // - Tags specified via the --resource-tags startup flag (controller-level tags)
319+ // - Tags injected by AWS services (e.g., CloudFormation, EKS, etc.)
320+ //
321+ // This filtering is essential because:
322+ // 1. AWS services automatically add system tags that cannot be modified by users
323+ // 2. Attempting to remove these tags would result in API errors
324+ // 3. The controller should only manage user-defined tags, not system tags
325+ //
326+ // Must be called after each Read operation to ensure the resource state
327+ // reflects only manageable tags. This prevents unnecessary update attempts
328+ // and maintains consistency between desired and actual resource state.
329+ //
330+ // Example system tags that are filtered:
331+ // - aws:cloudformation:stack-name (CloudFormation)
332+ // - aws:eks:cluster-name (EKS)
333+ // - services.k8s.aws/* (Kubernetes-managed)
334+ func (rm *resourceManager) FilterSystemTags(res acktypes.AWSResource, systemTags []string) {
322335{{- if $hookCode := Hook .CRD " filter_tags" }}
323336{{ $hookCode }}
324337{{ else }}
@@ -342,7 +355,7 @@ func (rm *resourceManager) FilterSystemTags(res acktypes.AWSResource) {
342355{{ end -}}
343356 existingTags = r.ko.Spec.{{ $tagField.Path }}
344357 resourceTags, tagKeyOrder := convertToOrderedACKTags(existingTags)
345- ignoreSystemTags(resourceTags)
358+ ignoreSystemTags(resourceTags, systemTags )
346359{{ GoCodeInitializeNestedStructField .CRD " r.ko" $tagField " svcapitypes" 1 -}}
347360 r.ko.Spec.{{ $tagField.Path }} = fromACKTags(resourceTags, tagKeyOrder)
348361{{- end }}
0 commit comments