Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SLACK_BOT_TOKEN: slackBotToken,
SLACK_SIGNING_SECRET: slackSigningSecret,
SLACK_CHANNEL: slackChannel || '',
SLACK_CHANNEL_ID: slackChannelId || '',
};
if (slackBotName) {
this.environment.SLACK_BOT_NAME = slackBotName;
}
if (slackBotIcon) {
this.environment.SLACK_BOT_ICON = slackBotIcon;
}
const notifier = new Function(scope, 'SlackNotifierFunction', {
runtime: Runtime.NODEJS_10_X,
handler: 'lib/notifier.handler',
code: Code.asset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment: this.environment,
});
notifier.addToRolePolicy(
new PolicyStatement({
resources: [pipeline.pipelineArn],
actions: [
'codepipeline:GetPipelineState',
'codepipeline:GetPipelineExecution',
],
}),
);
code: Code.asset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment,
},
);
const topic = new Topic(scope, 'SlackApprovalTopic');
topic.grantPublish(options.role);
topic.addSubscription(new LambdaSubscription(approvalRequester));
const approvalHandler = new Function(
scope,
'SlackApprovalHandlerFunction',
{
runtime: Runtime.NODEJS_10_X,
handler: 'lib/approval-handler.handler',
code: Code.fromAsset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment,
},
);
const api = new RestApi(scope, 'SlackApprovalApi');
api.root.addProxy({
defaultIntegration: new LambdaIntegration(approvalHandler),
});
approvalHandler.addToRolePolicy(
new PolicyStatement({
actions: ['codepipeline:PutApprovalResult'],
public constructor(
scope: Construct,
id: string,
props: ContentfulWebhookProps,
) {
super(scope, id);
const handler = new SingletonFunction(this, 'CustomResourceHandler', {
uuid: '91f2075f-b950-4743-a66b-ee0f6febf50d',
runtime: Runtime.NODEJS_10_X,
code: Code.fromAsset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
handler: 'lib/contentful-webhook.handler',
lambdaPurpose: 'Custom::ContentfulWebhook',
timeout: Duration.minutes(15),
});
new CustomResource(this, 'CustomResource', {
provider: CustomResourceProvider.lambda(handler),
resourceType: 'Custom::ContentfulWebhook',
properties: {
...props,
},
});
}
public constructor(
parent: Construct,
id: string,
props: GithubWebhookProps,
) {
super(parent, id);
const handler = new SingletonFunction(this, 'CustomResourceHandler', {
uuid: '83CBF3EB-7B62-44F2-8C67-8441E4C1232E',
runtime: Runtime.NODEJS_10_X,
code: Code.fromAsset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
handler: 'lib/github-webhook.handler',
lambdaPurpose: 'Custom::GithubWebhook',
timeout: Duration.minutes(15),
});
const {
githubApiToken,
githubRepoUrl,
payloadUrl,
events,
logLevel,
} = props;
options: ActionBindOptions,
): ActionConfig {
const environment = {
SLACK_BOT_TOKEN: this.props.slackBotToken,
SLACK_SIGNING_SECRET: this.props.slackSigningSecret,
SLACK_CHANNEL: this.props.slackChannel as string,
SLACK_CHANNEL_ID: this.props.slackChannelId as string,
SLACK_BOT_NAME: this.props.slackBotName || 'buildbot',
SLACK_BOT_ICON: this.props.slackBotIcon || ':robot_face:',
};
const approvalRequester = new Function(
scope,
'SlackApprovalRequesterFunction',
{
runtime: Runtime.NODEJS_10_X,
handler: 'lib/approval-requester.handler',
code: Code.asset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment,
},
);
const topic = new Topic(scope, 'SlackApprovalTopic');
topic.grantPublish(options.role);
topic.addSubscription(new LambdaSubscription(approvalRequester));
const approvalHandler = new Function(
scope,
'SlackApprovalHandlerFunction',
{
public constructor(
scope: Construct,
id: string,
props: StripeWebhookProps,
) {
super(scope, id);
const handler = new SingletonFunction(this, 'CustomResourceHandler', {
uuid: 'e9db3870-d793-4cd2-96a9-efe2e318ebbc',
runtime: Runtime.NODEJS_10_X,
code: Code.fromAsset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
handler: 'lib/stripe-webhook.handler',
lambdaPurpose: 'Custom::StripeWebhook',
timeout: Duration.minutes(15),
});
new CustomResource(this, 'CustomResource', {
provider: CustomResourceProvider.lambda(handler),
resourceType: 'Custom::StripeWebhook',
properties: {
...props,
},
});
}