Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save flochaz/f3fb3ee38c2b28963d89115eec9317fe to your computer and use it in GitHub Desktop.
Save flochaz/f3fb3ee38c2b28963d89115eec9317fe to your computer and use it in GitHub Desktop.
new AwsCustomResource(this, "trigger", AwsCustomResourceProps.builder()
.logRetention(options.logRetention != null ? options.logRetention : RetentionDays.ONE_DAY)
.onUpdate(AwsSdkCall.builder()
.service("Lambda")
.action("invoke")
.physicalResourceId(PhysicalResourceId.of("flywayTrigger"))
.parameters(Map.of(
"FunctionName", flywayServiceLambda.getFunctionName(),
"InvocationType", "RequestResponse",
"Payload", "{" +
"\"flywayRequest\":{\"flywayMethod\": \"migrate\"}," +
" \"assetHash\": \"" + ((Asset) migrationFilesDeployment.getNode().findChild("Asset1")).getAssetHash()+ "\"}"
)).build())
.policy(AwsCustomResourcePolicy.fromStatements(List.of(PolicyStatement.Builder.create()
.actions(List.of("lambda:InvokeFunction"))
.resources(List.of(flywayServiceLambda.getFunctionArn()))
.build())))
.build());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment