Skip to content

Strip the Parameter Store path only from the start of parameter names - #1715

Open
sharanggupta wants to merge 1 commit into
awspring:mainfrom
sharanggupta:parameter-store-strip-path-prefix-once
Open

sharanggupta wants to merge 1 commit into
awspring:mainfrom
sharanggupta:parameter-store-strip-path-prefix-once

Conversation

@sharanggupta

Copy link
Copy Markdown

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

ParameterStorePropertySource derives each property name by removing the parameter path from the parameter name. It used String.replace, which removes every occurrence of the path, not only the leading one:

Import Parameter Property before Property after
aws-parameterstore:/ /config/myservice/key1 configmyservicekey1 config.myservice.key1
aws-parameterstore:/config/myservice/ /config/myservice/legacy/config/myservice/key1 legacykey1 legacy.config.myservice.key1

With the root path every / disappeared, so nested parameters could not bind to anything sensible. The path is now removed only when it is the start of the name.

Names that contain the path only at the start, which is the usual case, resolve exactly as before. A path without a trailing / also behaves as before (see #1406 and #1714 for the warning about that case). The ?prefix= and ?extension= handling is unchanged.

Behaviour change to be aware of: an application that imports the root path, or that has parameter names repeating the path, and that relied on the mangled names above (for example ${configmyservicekey1}) will see those properties under the corrected names instead.

💡 Motivation and Context

I found this while working on #1406 in the same class. I did not find an existing issue for it.

💚 How did you test it?

Test first: the two new ParameterStorePropertySourceTest cases failed before the change with configmyservicekey1 and legacykey1, and pass with it. ./mvnw -pl spring-cloud-aws-parameter-store -am verify passes, including Spotless.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

None planned.

ParameterStorePropertySource removed the parameter path from each
parameter name with String.replace, which removes every occurrence of the
path. With the root path, `aws-parameterstore:/`, every '/' was removed,
so `/config/myservice/key1` became `configmyservicekey1` instead of
`config.myservice.key1`. A name that repeats the path, such as
`/config/myservice/legacy/config/myservice/key1` under
`/config/myservice/`, lost the inner occurrence as well and became
`legacykey1`.

Remove the path only when it is the leading part of the name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: parameter-store Parameter Store integration related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant