Accessing AWS Lambda environment variables in Java code

后端 未结 3 1207
面向向阳花
面向向阳花 2021-01-01 08:28

The AWS has introduced Environment variables for accessing in the Lambda function. I could not find any documentation which shows how to access the environment variables fro

相关标签:
3条回答
  • 2021-01-01 09:04

    I am using this -

    System.getenv("VAR_NAME");
    

    This works pretty well.

    0 讨论(0)
  • 2021-01-01 09:05

    If You are using Spring Core then PropertySourcesPlaceholderConfigurer class can be initialized as a part of Configuration and then @Value("${RESOURCE_URL}") annotation can be used to access environment variables.

    @Bean
    public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
        return new PropertySourcesPlaceholderConfigurer();
    }
    
    @Value("${RESOURCE_URL}")
    private String url;
    
    0 讨论(0)
  • 2021-01-01 09:09

    you can get them with:

    System.getenv("NAME_OF_YOUR_ENV_VARIABLE")
    
    0 讨论(0)
提交回复
热议问题