Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to set property prefix on Parameter Store property sources #927

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

beccagaspard
Copy link
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Added the ability to specify a property prefix for parameter store property sources. This replicates the functionality recently added for secrets manager property sources (see #621, #622, #630). I pulled heavily from the secrets manager prefix implementation written by @snigdhasjg and @maciejwalkowiak to try to keep the code and documentation consistent 🤓

💡 Motivation and Context

When multiple parameter store paths are imported that contain the same key, properties will be overwritten.

For example:

  • /config/my-db/url = jdbc:mysql://localhost:3306
  • /config/my-db/username = mysql-user
  • /config/another-db/url = jdbc:postgresql://localhost:5432/postgres

spring.config.import=aws-parameterstore:/config/my-db/;/config/another-db/ results in the following properties:

  • url = jdbc:postgresql://localhost:5432/postgres
  • username = mysql-user

Additionally users might want to add a prefix to their parameters for improved readability or to match autoconfig conventions. With the above properties, you can now do

spring.config.import=aws-parameterstore:/config/my-db/?prefix=spring.datasource. resulting in properties:

  • spring.datasource.url = jdbc:mysql://localhost:3306
  • spring.datasource.username = mysql-user

💚 How did you test it?

📝 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

@github-actions github-actions bot added component: parameter-store Parameter Store integration related issue type: documentation Documentation or Samples related issue labels Oct 27, 2023
Copy link
Contributor

@maciejwalkowiak maciejwalkowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @beccagaspard! Fantastic contribution!

@maciejwalkowiak maciejwalkowiak added this to the 3.0.3 milestone Oct 30, 2023
@maciejwalkowiak
Copy link
Contributor

@MatejNedic would you like to take a look before I merge?

@snigdhasjg
Copy link

@maciejwalkowiak @beccagaspard shall we also add this to 2.4.x branch? what do you suggest?

@maciejwalkowiak
Copy link
Contributor

We don't evolve 2.x anymore, unless there is something critical

Copy link
Member

@MatejNedic MatejNedic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…ud/parameterstore/ParameterStorePropertySource.java

Co-authored-by: MatejNedic <matejnedic1@gmail.com>
@maciejwalkowiak maciejwalkowiak merged commit a28a9d7 into awspring:main Nov 3, 2023
4 checks passed
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 type: documentation Documentation or Samples related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants