The event targets module has implemented a couple of event targets but is missing some, one of which is scheduling a Redshift query.
Use Case
Schedule RedShift queries.
Proposed Solution
Cloudformation already allows for this, here's my current implementation which isn't yet very CDKish:
const redshiftClusterArn = ...
const redshiftRole = new iam.Role(this, 'RedshiftEventRole', {
assumedBy: new iam.CompositePrincipal(new iam.ServicePrincipal('events.amazonaws.com'), new iam.AccountRootPrincipal()),
managedPolicies: [iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonRedshiftDataFullAccess')],
});
redshiftRole.addToPolicy(
new iam.PolicyStatement({
resources: [redshiftClusterArn],
actions: [
'sts:AssumeRole',
],
}),
);
const redshiftSecret = ...
redshiftSecret.grantRead(redshiftRole);
const loader = new events.Rule(this, 'eventRule', {
schedule: events.Schedule.expression('cron(2 */1 * * ? *)'),
});
const cfnLoader = loader.node.defaultChild as events.CfnRule;
cfnLoader.targets = [{
arn: `${redshiftClusterArn}`,
roleArn: redshiftRole.roleArn,
id: 'loader',
redshiftDataParameters: {
database: 'databasename',
sql: 'call myprocedure()',
secretManagerArn: redshiftSecret.secretArn,
},
}];
Other
This is a 🚀 Feature Request
The event targets module has implemented a couple of event targets but is missing some, one of which is scheduling a Redshift query.
Use Case
Schedule RedShift queries.
Proposed Solution
Cloudformation already allows for this, here's my current implementation which isn't yet very CDKish:
Other
This is a 🚀 Feature Request