How to use the @aws-cdk/aws-events-targets.LambdaFunction function in @aws-cdk/aws-events-targets

To help you get started, we’ve selected a few @aws-cdk/aws-events-targets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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)
      ]
    });
  }
}
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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)
      ]
    });
  }
}
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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)
      ]
    });
  }
}
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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)
      ]
    });
  }
}
github duo-labs / cloudtrail-partitioner / lib / cloudtrail_partitioner-stack.js View on Github external
}
    });

    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",
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
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)
      ]
    });
  }
}
github cloudcomponents / cdk-components / packages / cdk-pull-request-check / src / pull_request_check.ts View on Github external
);

        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',
                        ],
                    },
                },
            },
        );
github cloudcomponents / cdk-components / packages / cdk-codepipeline-slack / src / slack-notifier.ts View on Github external
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,
github cloudcomponents / cdk-components / packages / cdk-pull-request-check / src / pull_request_check.ts View on Github external
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(
github cloudcomponents / cdk-components / packages / cdk-codepipeline-slack / src / slack-notifier.ts View on Github external
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,
                },
            });
        }
    }