Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
timeout: cdk.Duration.minutes(1),
environment: {
CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
DISCOVERED_TOPIC_NAME: props.toCrawlTopic.topicArn
}
});
// Grant this application access to the DynamoDB table and SNS topic
props.changelogsTable.grantReadWriteData(rubygemFollower.role);
props.toCrawlTopic.grantPublish(rubygemFollower.role);
// Schedule the follower to run once every minute
this.eventRule = new events.Rule(this, 'check-recent-rubygems', {
schedule: events.Schedule.rate(cdk.Duration.minutes(5)),
targets: [
new targets.LambdaFunction(rubygemFollower)
]
});
}
}
code: lambda.Code.asset('./app/recently-crawled'),
environment: {
FEEDS_TABLE_NAME: props.feedsTable.tableName,
API_BUCKET_NAME: props.apiBucket.bucketName
}
});
// Grant the lambda permission to modify the tables and S3 bucket
props.feedsTable.grantReadWriteData(recentlyCrawled.role);
props.apiBucket.grantReadWrite(recentlyCrawled.role);
// Schedule the recrawler to run once every minute
this.eventRule = new events.Rule(this, 'recrawl-check-schedule', {
schedule: events.Schedule.rate(cdk.Duration.minutes(1)),
targets: [
new targets.LambdaFunction(recentlyCrawled)
]
});
}
}
CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
FEEDS_TABLE_NAME: props.feedsTable.tableName,
WEB_BUCKET_NAME: props.webBucket.bucketName
}
});
// Grant the lambda permission to read the tables
props.feedsTable.grantReadData(regenerateHomepage.role);
props.changelogsTable.grantReadData(regenerateHomepage.role);
props.webBucket.grantReadWrite(regenerateHomepage.role);
// Schedule this lambda to run once a minute
this.eventRule = new events.Rule(this, 'homepage-regeneration-schedule', {
schedule: events.Schedule.rate(cdk.Duration.minutes(1)),
targets: [
new targets.LambdaFunction(regenerateHomepage)
]
});
}
}
timeout: cdk.Duration.minutes(5),
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.Rule(this, 'recrawl-check-schedule', {
schedule: events.Schedule.rate(cdk.Duration.minutes(1)),
targets: [
new targets.LambdaFunction(recrawlLambda)
]
});
}
}
}
});
if (config['output_s3_bucket'] == "default") {
// This is only used for the IAM policy, we leave this as *-* because there is not
// an easy way of figuring out the AWS account from within the CDK
config['output_s3_bucket'] = "aws-athena-query-results-*-*"
}
// Create rule to trigger this be run every 24 hours
new events.Rule(this, "scheduled_run", {
ruleName: "athena_partitioner_for_cloudtrail",
// Run at 10pm EST (midnight UTC) every night
schedule: events.Schedule.expression("cron(0 0 * * ? *)"),
description: "Starts the CloudMapper auditing task every night",
targets: [new targets.LambdaFunction(partitioner)]
});
// Grant access to Athena, Glue, and identifying the regions
partitioner.addToRolePolicy(new iam.PolicyStatement({
resources: ['*'],
actions: [
"athena:StartQueryExecution",
"athena:GetQueryExecution",
"athena:GetQueryResults",
"glue:BatchCreatePartition",
"glue:BatchGetPartition",
"glue:CreateTable",
"glue:CreateDatabase",
"glue:GetDatabase",
"glue:GetTable",
"glue:UpdateTable",
timeout: cdk.Duration.minutes(1),
environment: {
CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
DISCOVERED_TOPIC_NAME: props.toCrawlTopic.topicArn
}
});
// Grant this application access to the DynamoDB table and SNS topic
props.changelogsTable.grantReadWriteData(pypiFollower.role);
props.toCrawlTopic.grantPublish(pypiFollower.role);
// Schedule the follower to run once every minute
this.eventRule = new events.Rule(this, 'check-recent-pypi', {
schedule: events.Schedule.rate(cdk.Duration.minutes(5)),
targets: [
new targets.LambdaFunction(pypiFollower)
]
});
}
}
);
const pullRequestProject = new Project(this, 'PullRequestProject', {
projectName: `${repository.repositoryName}-pull-request`,
source: Source.codeCommit({
repository,
}),
environment: {
buildImage,
computeType,
},
buildSpec,
});
pullRequestProject.onStateChange('PullRequestValidationRule', {
target: new LambdaFunction(codeBuildResultFunction),
});
const rule = repository.onPullRequestStateChange(
'PullRequestChangeRule',
{
eventPattern: {
detail: {
event: [
'pullRequestSourceBranchUpdated',
'pullRequestCreated',
],
},
},
},
);
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment: this.environment,
});
notifier.addToRolePolicy(
new PolicyStatement({
resources: [pipeline.pipelineArn],
actions: [
'codepipeline:GetPipelineState',
'codepipeline:GetPipelineExecution',
],
}),
);
pipeline.onStateChange('SlackPipelineNotifierRule', {
target: new LambdaFunction(notifier),
});
const stageRule = new Rule(this, 'SlackStageNotifierRule');
stageRule.addTarget(new LambdaFunction(notifier));
stageRule.addEventPattern({
source: ['aws.codepipeline'],
resources: [pipeline.pipelineArn],
detailType: ['CodePipeline Stage Execution State Change'],
});
if (stageNames) {
stageRule.addEventPattern({
detail: {
stage: stageNames,
const rule = repository.onPullRequestStateChange(
'PullRequestChangeRule',
{
eventPattern: {
detail: {
event: [
'pullRequestSourceBranchUpdated',
'pullRequestCreated',
],
},
},
},
);
rule.addTarget(new LambdaFunction(pullRequestFunction));
rule.addTarget(
new CodeBuildProject(pullRequestProject, {
event: RuleTargetInput.fromObject({
sourceVersion: EventField.fromPath('$.detail.sourceCommit'),
artifactsOverride: { type: 'NO_ARTIFACTS' },
environmentVariablesOverride: [
{
name: 'pullRequestId',
value: EventField.fromPath(
'$.detail.pullRequestId',
),
type: 'PLAINTEXT',
},
{
name: 'repositoryName',
value: EventField.fromPath(
new PolicyStatement({
resources: [pipeline.pipelineArn],
actions: [
'codepipeline:GetPipelineState',
'codepipeline:GetPipelineExecution',
],
}),
);
pipeline.onStateChange('SlackPipelineNotifierRule', {
target: new LambdaFunction(notifier),
});
const stageRule = new Rule(this, 'SlackStageNotifierRule');
stageRule.addTarget(new LambdaFunction(notifier));
stageRule.addEventPattern({
source: ['aws.codepipeline'],
resources: [pipeline.pipelineArn],
detailType: ['CodePipeline Stage Execution State Change'],
});
if (stageNames) {
stageRule.addEventPattern({
detail: {
stage: stageNames,
},
});
}
}