Skip to content

Instantly share code, notes, and snippets.

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", "{" +
aws lambda invoke --cli-binary-format raw-in-base64-out \
--payload '{ "flywayRequest": {"flywayMethod": "migrate" }}' \
--function-name FlywayLambdaS3
Function flywayServiceLambda = new Function(
this,
"runner",
FunctionProps.builder()
.environment(
Map.of(
"S3_BUCKET", migrationFilesBucket.getBucketName(),
"DB_CONNECTION_STRING", String.format("jdbc:mysql://{}/{}", options.databaseInstance.getDbInstanceEndpointAddress(), options.getDatabaseName()),
"DB_SECRET", options.databaseInstance.getSecret().getSecretFullArn()))
.runtime(Runtime.JAVA_11)
@NotNull ISource sqlFilesAsset = Source.asset(options.migrationScriptsFolderAbsolutePath);
Bucket migrationFilesBucket = new Bucket(this, "MigrationFilesBucket");
BucketDeployment migrationFilesDeployment = BucketDeployment.Builder
.create(this, "DeploySQLMigrationFiles")
.sources(List.of(sqlFilesAsset))
.destinationBucket(migrationFilesBucket)
.build();
String change001File = "../ApiHandlers/scripts/com/ilmlf/db/001.sql";
String change001Script = new String(Files.readAllBytes(Paths.get(scriptFile)));
String change002File = "../ApiHandlers/scripts/com/ilmlf/db/002.sql";
String change002Script = new String(Files.readAllBytes(Paths.get(scriptFile)));
CustomResource change001to002 = new CustomResource(
this,
"change-001",
CustomResourceProps.builder()
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());
@flochaz
flochaz / aws-sso-scim-create-user-auth0-post-login.js
Created August 3, 2021 07:32
Auth0 Post Login Action AWS SSO SCIM createUser implementation
const axios = require('axios');
/**
* @param {Event} event - Login event
*/
exports.onExecutePostLogin = async (event, api) => {
console.log(`creating user`);
const createUserResponse = await axios.post(
`https://scim.us-west-2.amazonaws.com/${event.secrets.TENANT_ID}/scim/v2/Users`,
{
#########
# WARNING WARNING WARNING
# WARNING WARNING WARNING
# WARNING WARNING WARNING
# WARNING WARNING WARNING
# WARNING WARNING WARNING
# this file is generated dynamically from /etc/aide/aide.conf and the files
# in /etc/aide/aide.conf.d
# Any changes you make here will be lost.
# WARNING WARNING WARNING
### Keybase proof
I hereby claim:
* I am flochaz on github.
* I am fchazal (https://keybase.io/fchazal) on keybase.
* I have a public key ASDozIA_q6wVt0Fy9KnDbu9g3GoQuM5ymp7tTrQAg2Mfcgo
To claim this, I am signing this object: