Describe the feature
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 Information
Originally posted by @dirkgomez in #15712
Acknowledgements
CDK version used
2.151.0
Environment details (OS name and version, etc.)
Windows 11
Describe the feature
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 Information
Originally posted by @dirkgomez in #15712
Acknowledgements
CDK version used
2.151.0
Environment details (OS name and version, etc.)
Windows 11