From 133db019c568a70b077160ff1ce5c4b66d75daa9 Mon Sep 17 00:00:00 2001 From: Jake Lee Kennedy Date: Thu, 5 Dec 2024 15:10:17 +0000 Subject: [PATCH] dev now does have a parameter store key --- common/app/common/CommercialBundle.scala | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/common/app/common/CommercialBundle.scala b/common/app/common/CommercialBundle.scala index acc5bee6d44..f0694bf6189 100644 --- a/common/app/common/CommercialBundle.scala +++ b/common/app/common/CommercialBundle.scala @@ -11,22 +11,17 @@ object CommercialBundle { private lazy val parameterStore = new ParameterStore(Environment.awsRegion) private val cacheDuration: FiniteDuration = 1.minute - private val stage = Environment.stage + private val stage = Environment.stage.toLowerCase() + private val bundlePathKey = s"/frontend/$stage/commercial.bundlePath" + + // when running locally Configuration.assets.path is set to "assets/" to serve local assets, but the commercial bundle no longer lives there, so we need to override it + private val basePath = + if (stage == "dev") "https://assets.guim.co.uk/" else Configuration.assets.path private var cachedBundlePath: String = bundlePathFromParameterStore private var cachedTimestamp: Instant = Instant.now() - // when running locally Configuration.assets.path is set to "assets/" to serve local assets, but the commercial bundle no longer lives there, so we need to override it - private val basePath = - if (stage.equalsIgnoreCase("dev")) "https://assets-code.guim.co.uk/" else Configuration.assets.path - - private def bundlePathFromParameterStore: String = { - if (stage == "CODE") - parameterStore.get("/frontend/CODE/commercial.bundlePath") - else - // for PROD and DEV to use the same bundle path - parameterStore.get("/frontend/commercial.bundlePath") - } + private def bundlePathFromParameterStore: String = parameterStore.get(bundlePathKey) private def bundlePath: String = { if (Instant.now().isAfter(cachedTimestamp.plus(cacheDuration.toMillis))) {