Created
October 26, 2021 13:33
-
-
Save flochaz/d038c989052f359d7b8beaa7214d5d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createCustomResourceToPopulateDb(ApiStackProps props, Role lambdaRdsProxyRoleWithPw) throws IOException { | |
// See https://docs.aws.amazon.com/cdk/api/latest/java/software/amazon/awscdk/customresources/package-summary.html for details on writing a Lambda function | |
// and providers | |
Function dbPopulatorHandler = | |
defaultLambdaRdsProxy("PopulateFarmDb", props, lambdaRdsProxyRoleWithPw); | |
Provider dbPopulatorProvider = | |
new Provider( | |
this, | |
"InvokePopulateDataProvider", | |
ProviderProps.builder().onEventHandler(dbPopulatorHandler).build()); | |
String scriptFile = "../ApiHandlers/scripts/com/ilmlf/db/dbinit.sql"; | |
String sqlScript = new String(Files.readAllBytes(Paths.get(scriptFile))); | |
CustomResource initCustomResource = new CustomResource( | |
this, | |
"PopulateDataProviderv22", | |
CustomResourceProps.builder() | |
.serviceToken(dbPopulatorProvider.getServiceToken()) | |
.resourceType("Custom::PopulateDataProvider") | |
.properties(Map.of("SqlScript",sqlScript)) | |
.build()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment