Skip to content

Commit 39e387c

Browse files
committed
CDK deployment scripts
1 parent beaff20 commit 39e387c

File tree

16 files changed

+4101
-3826
lines changed

16 files changed

+4101
-3826
lines changed

.deploy/lambda/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
*.js
2-
!jest.config.js
32
*.d.ts
43
node_modules
54

6-
# CDK asset staging directory
75
.cdk.staging
86
cdk.out

.deploy/lambda/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.
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/bin/lambda.ts

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

.deploy/lambda/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app": "npx ts-node --prefer-ts-exts bin/lambda.ts",
2+
"app": "npx ts-node --prefer-ts-exts bin/JProfByBotStack.ts",
33
"context": {
44
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
55
"@aws-cdk/core:enableStackNameDuplicates": "true",

.deploy/lambda/jest.config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
}
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+
}

.deploy/lambda/lib/lambda-stack.ts

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

0 commit comments

Comments
 (0)