Access Environment Variables in Sprint boot application.yaml

I have some Environment variables that I need to access in my sprint boot application and also in the application.yaml file. https://www.serverless.com/blog/serverless-secrets-api-keys has the way to access in Javascript and phython and does not have any information about java. Can somebody please help

@JaspreetChhabra I would suggest not to tie your environment values into serverless.yaml but rather be environment specific and have the values stored in either your CICD (if its not a secret or PII) or consider cloud specific secret storage - like SSM

If you have that in ur CICD, lie github actions, you have to create environment or repo secrets, and access that in the workflow like this,
$ {{ secret.KEY_OF_UR_CHOICE }}
this is injected to the serverless and now to inject them to the lambda workload, use the “environment” spec as specified by serverless.yml
This allows the environment variable to be used in springboot or in application.yaml as you desire. Please refer the springboot documentation on how to use them

If you are storing them in secret manager service like SSM, then you are bound to access them only using the API , so it depends on whether u are allowed to use aws cli in your cicd and fetch them or only restricted to use the API inside springboot code in which case, using the environment variable in application.yaml is not possible.
Hope this helps