in TokenVendingLayer/src/main/java/tenant/vendinglayer/TokenVendor.java [60:78]
public TokenVendor() {
// we only download the policies from S3 if the templates don't exist on the
// filesystem already from a previous lambda invocation
if(Files.notExists(templateFilePath)) {
logger.info("Templates zip file not found, downloading from S3...");
S3Client s3 = S3Client.builder().httpClientBuilder(UrlConnectionHttpClient.builder()).build();
s3.getObject(GetObjectRequest.builder().bucket(TEMPLATE_BUCKET).key(TEMPLATE_KEY).build(),
ResponseTransformer.toFile(templateFilePath));
try {
ZipFile zipFile = new ZipFile(templateFilePath.toFile());
zipFile.extractAll(templateDirPath);
logger.info("Templates zip file successfully unzipped.");
} catch (IOException e) {
logger.error("Could not unzip template file.", e);
throw new RuntimeException(e.getMessage());
}
}
this.templateDir = new File(templateDirPath);
}