From e03b55be17261ed13ddf421bcf4a804a083a7614 Mon Sep 17 00:00:00 2001 From: Thorsten Ortlepp Date: Fri, 26 Apr 2024 00:30:46 +0200 Subject: added implementation --- .../eu/ortlepp/notificationsender/util/Config.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/eu/ortlepp/notificationsender/util/Config.java (limited to 'src/main/java/eu/ortlepp/notificationsender/util') diff --git a/src/main/java/eu/ortlepp/notificationsender/util/Config.java b/src/main/java/eu/ortlepp/notificationsender/util/Config.java new file mode 100644 index 0000000..139ea24 --- /dev/null +++ b/src/main/java/eu/ortlepp/notificationsender/util/Config.java @@ -0,0 +1,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() {} + +} -- cgit v1.2.3