fix: match AWS Secrets Manager ARNs against ExternalSecret/PushSecret friendly names - #366
Closed
zachbernstein-sdx wants to merge 1 commit into
Conversation
… friendly names
AwsSqs notification source events carry event.Detail.RequestParameters.SecretId
verbatim from CloudTrail, which for PutSecretValue calls is the secret's full
ARN (including the random 6-character suffix Secrets Manager appends), not its
friendly name. Both AWS's own built-in rotation Lambdas and manual
PutSecretValue calls made via the console/CLI with the ARN as --secret-id
populate this field with the ARN.
The ExternalSecret/PushSecret destination handlers' default References()
implementations compared this raw identifier against
spec.dataFrom[].extract.key / spec.data[].remoteRef.key /
spec.data[].match.remoteRef.remoteKey / spec.selector.secret.name using strict
string equality. Since those fields conventionally hold the secret's friendly
name (the common, documented way to configure an ExternalSecret against a
SecretsManager ClusterSecretStore), the comparison never succeeded for
AWS-sourced events. The destination was silently skipped
("skipping object as its not referenced") even though the listener, auth and
event delivery pipeline all worked correctly - so, in practice, any
ExternalSecret backed by AWS Secrets Manager and referenced by friendly name
never got reloaded.
Add internal/util.SecretIdentifierMatches (backed by
SecretIdentifierAliases), which expands an AWS Secrets Manager ARN into its
canonical friendly name before comparing, while still matching a raw
identifier by strict equality otherwise (including when a spec already uses
the full ARN, preserving existing behavior). Wire this into both the
ExternalSecret and PushSecret handlers' _references implementations.
Covered by new unit tests in internal/util and the externalsecret/pushsecret
handler packages, plus the existing internal/controller envtest suite (still
green).
zachbernstein-sdx
deleted the
fix/aws-secretsmanager-arn-reference-matching
branch
July 27, 2026 19:55
Author
|
Superseded by #367 |
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.
Problem
AwsSqsnotification-source events setSecretIdentifierdirectly from CloudTrail'srequestParameters.secretId(internal/listener/sqs/listener.go):For
PutSecretValuecalls this is the secret's full ARN, including the random 6-character suffix Secrets Manager appends to every secret (e.g.arn:aws:secretsmanager:us-east-1:051826739313:secret:platform/ai-gateway/service-secrets-78YXTj). This isn't an edge case — both AWS's own built-in rotation Lambdas and manualPutSecretValuecalls made via the console/CLI with the ARN as--secret-idpopulaterequestParameters.secretIdwith the ARN.The
ExternalSecret/PushSecretdestination handlers' defaultReferences()implementations (internal/handler/externalsecret/handler.go#L152-L179, and the analogous code ininternal/handler/pushsecret/handler.go) compare this raw identifier againstspec.dataFrom[].extract.key/spec.data[].remoteRef.key/spec.data[].match.remoteRef.remoteKey/spec.selector.secret.nameusing strict string equality.Those fields conventionally hold the secret's friendly name — the standard, documented way to configure an
ExternalSecretagainst a SecretsManagerClusterSecretStore(dataFrom.extract.key: platform/ai-gateway/service-secrets). Because the friendly name never string-equals the ARN, the comparison never succeeds for AWS-sourced events. The destination is silently skipped ("skipping object as its not referenced") even though the listener, auth, and event-delivery pipeline are all working correctly — in practice, anyExternalSecretbacked by AWS Secrets Manager and referenced by friendly name never gets reloaded via theAwsSqssource.(We noticed the CRD/config docs describe a
matchStrategywithContains/RegularExpressionoperations that could work around this, but confirmed in both thev0.1.0andv0.2.0release tags thatmatchStrategyis still a stub inprocessor.go— logged and ignored — so it isn't currently usable as a workaround.)Fix
Add
internal/util.SecretIdentifierMatches(backed bySecretIdentifierAliases), which expands an AWS Secrets Manager ARN into its canonical friendly name (per AWS's documented ARN suffix behavior) before comparing, while still matching non-ARN identifiers by strict equality as before — including the case where a spec already stores the full ARN, so existing configurations are unaffected. Wire this into the_referencesimplementations in both theExternalSecretandPushSecrethandlers, replacing the raw==checks.This is scoped narrowly (only identifiers that look like
arn:aws*:secretsmanager:...:secret:<name>-<6-char-suffix>are expanded; everything else falls through to the original exact-match behavior), so it shouldn't change behavior for any other notification source or provider.Testing
internal/util/secretid_test.gocovering standard/GovCloud/China partitions, friendly names that themselves contain hyphenated 6-char segments, non-ARN identifiers, and non-SecretsManager ARNs.internal/handler/externalsecret/handler_test.goand a newinternal/handler/pushsecret/handler_test.goverifying an ExternalSecret/PushSecret configured with a friendly name is now considered referenced when the event identifier is the full ARN.internal/controllerenvtest integration specs (go test ./internal/controller/...viasetup-envtest) — all green, no regressions.Happy to adjust naming/placement of the helper or expand test coverage if maintainers have a preference — opened as draft to get early signal on whether this approach (alias-expansion inside the handler's reference check) matches how you'd want this solved vs., e.g., normalizing at the
AwsSqslistener level or finishing thematchStrategywiring instead.