Created
April 10, 2019 15:58
-
-
Save nathanpeck/68a1fe7914951b9c39608f2e7e222747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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