@@ -9,12 +9,12 @@ import path = require('path');
99import { PolicyStatement , Policy } from 'aws-cdk-lib/aws-iam' ;
1010import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs' ;
1111import { Duration } from 'aws-cdk-lib' ;
12- import { DISCORD_APP_ID } from '../minecloud_configs/MineCloud-Configs' ;
1312import { Bucket } from 'aws-cdk-lib/aws-s3' ;
1413
1514export interface DiscordInteractionsEndpointConstructProps {
1615 instanceId : string ;
1716 ec2Region : string ;
17+ discordAppId : string ;
1818 discordPublicKey : string ;
1919 backUpBucket : Bucket ;
2020}
@@ -31,44 +31,46 @@ export class DiscordInteractionsEndpointConstruct extends Construct {
3131 ) {
3232 super ( scope , id ) ;
3333
34- this . discordInteractionsEndpoint = new NodejsFunction (
34+ this . discordCommandProcesser = new NodejsFunction (
3535 this ,
36- `${ STACK_PREFIX } _discord_interactions_endpoint_lambda ` ,
36+ `${ STACK_PREFIX } _discord_command_processor_lambda ` ,
3737 {
38- functionName : `${ STACK_PREFIX } _discord_interactions_endpoint_lambda ` ,
38+ functionName : `${ STACK_PREFIX } _discord_command_processor_lambda ` ,
3939 runtime : Runtime . NODEJS_18_X ,
4040 handler : 'index.handler' ,
4141 entry : path . join (
4242 __dirname ,
43- '/../lambda/discord_interactions_endpoint /index.ts'
43+ '/../lambda/discord_command_processer /index.ts'
4444 ) ,
4545 environment : {
46- PUBLIC_KEY : props . discordPublicKey
46+ INSTANCE_ID : props . instanceId ,
47+ EC2_REGION : props . ec2Region ,
48+ APP_ID : props . discordAppId ,
49+ BACKUP_BUCKET_NAME : props . backUpBucket . bucketName
4750 } ,
48- memorySize : 1024 // To reduce cold start time
51+ timeout : Duration . seconds ( 15 )
4952 }
5053 ) ;
5154
52- this . discordCommandProcesser = new NodejsFunction (
55+ this . discordInteractionsEndpoint = new NodejsFunction (
5356 this ,
54- `${ STACK_PREFIX } _discord_command_processor_lambda ` ,
57+ `${ STACK_PREFIX } _discord_interactions_endpoint_lambda ` ,
5558 {
56- functionName : `${ STACK_PREFIX } _discord_command_processor_lambda ` ,
59+ functionName : `${ STACK_PREFIX } _discord_interactions_endpoint_lambda ` ,
5760 runtime : Runtime . NODEJS_18_X ,
5861 handler : 'index.handler' ,
5962 entry : path . join (
6063 __dirname ,
61- '/../lambda/discord_command_processer /index.ts'
64+ '/../lambda/discord_interactions_endpoint /index.ts'
6265 ) ,
6366 environment : {
64- INSTANCE_ID : props . instanceId ,
65- EC2_REGION : props . ec2Region ,
66- APP_ID : DISCORD_APP_ID ,
67- BACKUP_BUCKET_NAME : props . backUpBucket . bucketName
67+ PUBLIC_KEY : props . discordPublicKey ,
68+ DISCORD_COMMAND_PROCESSOR_FUNCTION_NAME : this . discordCommandProcesser . functionName
6869 } ,
69- timeout : Duration . seconds ( 15 )
70+ memorySize : 1024 // To reduce cold start time
7071 }
7172 ) ;
73+
7274 this . discordCommandProcesser . grantInvoke ( this . discordInteractionsEndpoint ) ;
7375 props . backUpBucket . grantReadWrite ( this . discordCommandProcesser ) ;
7476
0 commit comments