Skip to content

Instantly share code, notes, and snippets.

@nathanpeck
Created April 10, 2019 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanpeck/68a1fe7914951b9c39608f2e7e222747 to your computer and use it in GitHub Desktop.
Save nathanpeck/68a1fe7914951b9c39608f2e7e222747 to your computer and use it in GitHub Desktop.
// Create a lambda that recrawls changelogs discovered in the past
const recrawlLambda = new lambda.Function(this, 'recrawl', {
runtime: lambda.Runtime.NodeJS810,
handler: 'recrawl.handle',
code: lambda.Code.asset('./app/recrawl'),
timeout: 360,
environment: {
CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
DISCOVERED_TOPIC_NAME: props.toCrawlTopic.topicArn
}
});
// Grant the lambda permission to modify the tables
props.changelogsTable.grantReadWriteData(recrawlLambda.role);
props.toCrawlTopic.grantPublish(recrawlLambda.role);
// Schedule the recrawler to run once every minute
this.eventRule = new events.EventRule(this, 'recrawl-check-schedule', {
scheduleExpression: 'rate(1 minute)',
targets: [recrawlLambda]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment