Automatically populate PropertySource with instance metadata when running within an EC2-based environment
:loudspeaker: Type of change
- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
:scroll: Description
A new package added to the autoconfigure project (with test classes) to populate a PropertySource whenever IMDS is present, which occurs on EC2, ElasticBeanstalk, ECS, EKS, etc. Auto configuration silently ignores the absence of IMDS. A starter pom is added, docs are updated.
:bulb: Motivation and Context
Issue addressed is: https://github.com/awspring/spring-cloud-aws/issues/954 There are various times when an application needs to know its IP address, availability zone, region, mac address, etc. All this is available via IMDS. This feature simply adds these properties to the Environment when available.
:green_heart: How did you test it?
Three new classes, three new JUnit tests. Plus I created a sample application using the libraries for a sanity test.
:pencil: Checklist
- [ x] I reviewed submitted code
- [x ] I added tests to verify changes
- [x ] I updated reference documentation to reflect the change
- [ x] All tests passing
- [x ] No breaking changes
:crystal_ball: Next steps
Others may wish to expand this to retrieve dynamic data, user data, set a common prefix, etc. May want to use a ConfigProperties only to cause the one and only property to be documented.
Thanks @kennyk65 for a PR! We need an integration test for that. Until Localstack supports metadata endpoint (https://github.com/localstack/localstack/issues/8911) we would need to mock it - ideally with WireMock, to make sure whole flow works as expected.