Skip to content

Commit 37f3d99

Browse files
committed
Update CDK to 2.x
1 parent d5b710e commit 37f3d99

File tree

13 files changed

+4957
-10816
lines changed

13 files changed

+4957
-10816
lines changed

.deploy/README.adoc

Lines changed: 0 additions & 8 deletions
This file was deleted.

.deploy/lambda/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
*.js
2+
!jest.config.js
23
*.d.ts
34
node_modules
45

6+
# CDK asset staging directory
57
.cdk.staging
68
cdk.out
9+
10+
junit.xml

.deploy/lambda/README.adoc

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
= https://t.me/jprof_by_bot[@jprof_by_bot]
1+
= .deploy / AWS Lambda
22

3-
Official Telegram bot of Java Professionals BY community.
3+
A https://aws.amazon.com/cdk[CDK] script to deploy the bot into a serverless environment:
44

5-
== What is this bot for?
6-
7-
* Tracks http://openjdk.java.net/jeps/0[JEPs] popularity
8-
* Tracks popularity of YouTube videos from Java-related channels
9-
* Warns users when they mention Kotlin
10-
* Allows users to pin messages
11-
* Allows users to create polls with reply buttons (just like https://t.me/like[`@like`] bot)
12-
13-
So, it just brings some fun and interactivity in our chat.
14-
15-
== Contributing
16-
17-
Here are the most important rules if you want to make a contribution:
18-
19-
* Split the code into modules based on features
20-
* Stick to the technologies that can fit into AWS free tier
21-
22-
The rest could be found in link:./.github/CONTRIBUTING.md[the contributing guide].
5+
* https://aws.amazon.com/api-gateway[API Gateway] is used as an HTTP ingestor
6+
* The webhook is implemented as an https://aws.amazon.com/lambda[AWS Lambda]
7+
* https://aws.amazon.com/dynamodb[DynamoDB] is used for data storage
8+
* https://aws.amazon.com/step-functions[Step Functions] are used for scheduling things in future

.deploy/lambda/bin/JProfByBotStack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
3-
import * as cdk from '@aws-cdk/core';
3+
import * as cdk from 'aws-cdk-lib';
44
import {JProfByBotStack} from '../lib/JProfByBotStack';
55

66
if (process.env.TOKEN_TELEGRAM_BOT == null) {

.deploy/lambda/cdk.json

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
{
22
"app": "npx ts-node --prefer-ts-exts bin/JProfByBotStack.ts",
3+
"watch": {
4+
"include": [
5+
"**"
6+
],
7+
"exclude": [
8+
"README.adoc",
9+
"cdk*.json",
10+
"**/*.d.ts",
11+
"**/*.js",
12+
"tsconfig.json",
13+
"package*.json",
14+
"yarn.lock",
15+
"node_modules",
16+
"test"
17+
]
18+
},
319
"context": {
420
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
5-
"@aws-cdk/core:enableStackNameDuplicates": "true",
6-
"aws-cdk:enableDiffNoFail": "true",
7-
"@aws-cdk/core:stackRelativeExports": "true",
8-
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
9-
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
10-
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
11-
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
12-
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
21+
"@aws-cdk/core:stackRelativeExports": true,
1322
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
14-
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true
23+
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
24+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
25+
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true,
26+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
27+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
28+
"@aws-cdk/core:checkSecretUsage": true,
29+
"@aws-cdk/aws-iam:minimizePolicies": true,
30+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
31+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
32+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
33+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
34+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
35+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
36+
"@aws-cdk/core:enablePartitionLiterals": true,
37+
"@aws-cdk/core:target-partitions": [
38+
"aws",
39+
"aws-cn"
40+
]
1541
}
1642
}

.deploy/lambda/jest.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
testMatch: ['**/*.test.ts'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest'
7+
},
8+
reporters: [
9+
'default',
10+
'jest-junit',
11+
],
12+
};

.deploy/lambda/lib/JProfByBotStack.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import * as cdk from '@aws-cdk/core';
2-
import {JProfByBotStackProps} from './JProfByBotStackProps';
3-
import * as dynamodb from '@aws-cdk/aws-dynamodb';
4-
import * as lambda from '@aws-cdk/aws-lambda';
5-
import * as apigateway from '@aws-cdk/aws-apigateway';
6-
import * as sfn from '@aws-cdk/aws-stepfunctions';
7-
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';
1+
import * as cdk from 'aws-cdk-lib';
2+
import {Construct} from 'constructs';
3+
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
4+
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
5+
import * as lambda from 'aws-cdk-lib/aws-lambda';
6+
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
7+
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
8+
import {JProfByBotStackProps} from "./JProfByBotStackProps";
89

910
export class JProfByBotStack extends cdk.Stack {
10-
constructor(scope: cdk.Construct, id: string, props: JProfByBotStackProps) {
11+
constructor(scope: Construct, id: string, props: JProfByBotStackProps) {
1112
super(scope, id, props);
1213

1314
const votesTable = new dynamodb.Table(this, 'jprof-by-bot-table-votes', {

.deploy/lambda/lib/JProfByBotStackProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as cdk from '@aws-cdk/core';
1+
import * as cdk from 'aws-cdk-lib';
22

33
export interface JProfByBotStackProps extends cdk.StackProps {
44
readonly telegramToken: string;

0 commit comments

Comments
 (0)