Skip to content

Commit 296db3c

Browse files
authored
Merge pull request #1 from madhead/feature/JEP
Vote for JEP mentions
2 parents cdff745 + a82262d commit 296db3c

File tree

26 files changed

+16157
-34
lines changed

26 files changed

+16157
-34
lines changed

.deploy/lambda/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.js
2+
*.d.ts
3+
node_modules
4+
5+
.cdk.staging
6+
cdk.out

.deploy/lambda/.npmignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.ts
2+
!*.d.ts
3+
4+
# CDK asset staging directory
5+
.cdk.staging
6+
cdk.out
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
import 'source-map-support/register';
3+
import * as cdk from '@aws-cdk/core';
4+
import { JProfByBotStack } from '../lib/JProfByBotStack';
5+
6+
if (process.env.TELEGRAM_BOT_TOKEN == null) {
7+
throw new Error('Undefined TELEGRAM_BOT_TOKEN')
8+
}
9+
10+
const app = new cdk.App();
11+
new JProfByBotStack(
12+
app,
13+
'JProfByBotStack',
14+
{
15+
telegramToken: process.env.TELEGRAM_BOT_TOKEN,
16+
env: {
17+
region: 'us-east-1'
18+
}
19+
}
20+
);

.deploy/lambda/cdk.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts bin/JProfByBotStack.ts",
3+
"context": {
4+
"@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,
13+
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
14+
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true
15+
}
16+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as cdk from '@aws-cdk/core';
2+
import { Duration } from '@aws-cdk/core';
3+
import { JProfByBotStackProps } from './JProfByBotStackProps';
4+
import lambda = require('@aws-cdk/aws-lambda');
5+
import apigateway = require('@aws-cdk/aws-apigateway');
6+
7+
export class JProfByBotStack extends cdk.Stack {
8+
constructor(scope: cdk.Construct, id: string, props: JProfByBotStackProps) {
9+
super(scope, id, props);
10+
11+
const lambdaWebhook = new lambda.Function(this, 'jprof-by-bot-lambda-webhook', {
12+
functionName: 'jprof-by-bot-lambda-webhook',
13+
runtime: lambda.Runtime.JAVA_11,
14+
timeout: Duration.seconds(30),
15+
memorySize: 1024,
16+
code: lambda.Code.fromAsset('../../runners/lambda/build/libs/jprof_by_bot-runners-lambda-all.jar'),
17+
handler: 'by.jprof.telegram.bot.runners.lambda.JProf',
18+
environment: {
19+
'LOG_THRESHOLD': 'DEBUG',
20+
},
21+
});
22+
23+
const api = new apigateway.RestApi(this, 'jprof-by-bot-api', {
24+
restApiName: 'jprof-by-bot-api',
25+
cloudWatchRole: false,
26+
endpointTypes: [apigateway.EndpointType.REGIONAL],
27+
deployOptions: {
28+
loggingLevel: apigateway.MethodLoggingLevel.INFO,
29+
dataTraceEnabled: true,
30+
metricsEnabled: true,
31+
tracingEnabled: true,
32+
},
33+
});
34+
35+
api.root
36+
.addResource(props.telegramToken.replace(':', '_'))
37+
.addMethod('POST', new apigateway.LambdaIntegration(lambdaWebhook));
38+
39+
new cdk.CfnOutput(this, 'URL', {
40+
value: api.deploymentStage.urlForPath()
41+
});
42+
}
43+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as cdk from '@aws-cdk/core';
2+
3+
export interface JProfByBotStackProps extends cdk.StackProps {
4+
readonly telegramToken: string;
5+
}

0 commit comments

Comments
 (0)