Skip to content

Commit

Permalink
Merge pull request #3 from RenovoSolutions/trigger
Browse files Browse the repository at this point in the history
Add trigger event (every Monday)
  • Loading branch information
bmiller08 authored Oct 11, 2021
2 parents 54b9f32 + a25530c commit f467d40
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 58 deletions.
32 changes: 21 additions & 11 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ const { AwsCdkConstructLibrary, ProjectType, NpmAccess } = require('projen');
const project = new AwsCdkConstructLibrary({
author: 'Renovo Solutions',
authorAddress: 'webmaster+cdk@renovo1.com',
cdkVersion: '1.126.0',
cdkVersion: '1.127.0',
defaultReleaseBranch: 'master',
name: '@renovosolutions/cdk-library-certbot',
description: 'AWS CDK Construct Library to manage Lets Encrypt certificate renewals with Certbot',
repositoryUrl: 'https://github.com/RenovoSolutions/cdk-library-certbot.git',
cdkDependencies: [
'@aws-cdk/core',
'@aws-cdk/aws-lambda',
'@aws-cdk/aws-lambda-python',
'@aws-cdk/aws-s3',
'@aws-cdk/aws-events',
'@aws-cdk/aws-events-targets',
],
projectType: ProjectType.LIB,
releaseToNpm: true,
Expand Down
20 changes: 11 additions & 9 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as path from 'path';
import * as events from '@aws-cdk/aws-events';
import * as targets from '@aws-cdk/aws-events-targets';
import * as lambda from '@aws-cdk/aws-lambda';
import * as s3 from '@aws-cdk/aws-s3';
import * as cdk from '@aws-cdk/core';
Expand Down Expand Up @@ -102,5 +104,10 @@ export class Certbot extends cdk.Construct {
},
layers: props.layers,
});

new events.Rule(this, 'trigger', {
schedule: events.Schedule.cron({ minute: '0', hour: '0', weekDay: '1' }),
targets: [new targets.LambdaFunction(this.handler)],
});
}
}
7 changes: 4 additions & 3 deletions test/certbot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect as expectCDK, countResources } from '@aws-cdk/assert';
import * as cdk from '@aws-cdk/core';
import { Certbot } from '../src/index';

test('Simple test', () => {
test('Default', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'TestStack');

Expand All @@ -12,5 +12,6 @@ test('Simple test', () => {
});

expectCDK(stack).to(countResources('AWS::Lambda::Function', 1));

});
expectCDK(stack).to(countResources('AWS::Events::Rule', 1));
expectCDK(stack).to(countResources('AWS::S3::Bucket', 1));
});
4 changes: 2 additions & 2 deletions tsconfig.eslint.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tsconfig.jest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f467d40

Please sign in to comment.