aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/eu/ortlepp/notificationsender/util/Config.java
blob: 139ea245ebe7bf56f7526d0ea437ba979a8cb6db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package eu.ortlepp.notificationsender.util;

import software.amazon.awssdk.regions.Region;

/**
 * Required configuration values read from environment variables.
 */
public final class Config {

  /**
   * The region of the SNS topic. The Name of the environment variable is REGION.
   * Value example: eu-central-1
   */
  public static final Region REGION;

  /**
   * The ARN of the SNS topic. The Name of the environment variable is ARN.
   * Value example: arn:aws:sns:eu-central-1:123456789:Topic-Name
   */
  public static final String ARN;


  static {
    REGION = Region.of(getEnvVar("REGION"));
    ARN = getEnvVar("ARN");
  }


  private static String getEnvVar(final String key) {
    String value =  System.getenv(key);
    if (value == null) {
      throw new RuntimeException("environment variable not set: " + key);
    }
    return value;
  }


  private Config() {}

}