@@ -2,10 +2,9 @@ import { StackProps, Stack, CfnOutput, Duration } from "aws-cdk-lib";
2
2
import { EventBus , Rule } from "aws-cdk-lib/aws-events" ;
3
3
import {
4
4
LambdaFunction ,
5
- SfnStateMachine ,
6
5
} from "aws-cdk-lib/aws-events-targets" ;
7
6
import { Architecture , FunctionUrlAuthType , Runtime } from "aws-cdk-lib/aws-lambda" ;
8
- import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs" ;
7
+ import { NodejsFunction , NodejsFunctionProps } from "aws-cdk-lib/aws-lambda-nodejs" ;
9
8
import { Secret } from "aws-cdk-lib/aws-secretsmanager" ;
10
9
import { Construct } from "constructs" ;
11
10
import { join } from "path" ;
@@ -78,9 +77,9 @@ export class BlogCrosspostingAutomationStack extends Stack {
78
77
secretName
79
78
) ;
80
79
81
- const lambdaProps = {
80
+ const lambdaProps : NodejsFunctionProps = {
82
81
architecture : Architecture . ARM_64 ,
83
- memory : 1024 ,
82
+ memorySize : 1024 ,
84
83
timeout : Duration . minutes ( 5 ) ,
85
84
runtime : Runtime . NODEJS_18_X ,
86
85
environment : {
@@ -105,6 +104,7 @@ export class BlogCrosspostingAutomationStack extends Stack {
105
104
eventBus,
106
105
sendApiRequestFn,
107
106
table,
107
+ canonical,
108
108
} ;
109
109
if ( devTo ?. devOrganizationId ) {
110
110
const parseDevFn = new NodejsFunction ( this , `ParseDevToFn` , {
@@ -114,7 +114,7 @@ export class BlogCrosspostingAutomationStack extends Stack {
114
114
parseDevFn . addEnvironment ( "CANONICAL" , canonical ) ;
115
115
parseDevFn . addEnvironment ( "DEV_ORG_ID" , devTo . devOrganizationId ) ;
116
116
if ( amplify ) {
117
- parseDevFn . addEnvironment ( "BLOG_BASE_URL " , amplify . blogBaseUrl ) ;
117
+ parseDevFn . addEnvironment ( "AMPLIFY_BASE_URL " , amplify . blogBaseUrl ) ;
118
118
}
119
119
crossPostStepFunctionProps . devTo = {
120
120
fn : parseDevFn ! ,
@@ -127,7 +127,7 @@ export class BlogCrosspostingAutomationStack extends Stack {
127
127
} ) ;
128
128
parseHashnodeFn . addEnvironment ( "CANONICAL" , canonical ) ;
129
129
if ( amplify ) {
130
- parseHashnodeFn . addEnvironment ( "BLOG_BASE_URL " , amplify . blogBaseUrl ) ;
130
+ parseHashnodeFn . addEnvironment ( "AMPLIFY_BASE_URL " , amplify . blogBaseUrl ) ;
131
131
}
132
132
if ( hashnode . hashnodePublicationId ) {
133
133
parseHashnodeFn . addEnvironment (
@@ -147,7 +147,7 @@ export class BlogCrosspostingAutomationStack extends Stack {
147
147
} ) ;
148
148
parseMediumFn . addEnvironment ( "CANONICAL" , canonical ) ;
149
149
if ( amplify ) {
150
- parseMediumFn . addEnvironment ( "BLOG_BASE_URL " , amplify . blogBaseUrl ) ;
150
+ parseMediumFn . addEnvironment ( "AMPLIFY_BASE_URL " , amplify . blogBaseUrl ) ;
151
151
}
152
152
crossPostStepFunctionProps . medium = {
153
153
fn : parseMediumFn ! ,
@@ -187,7 +187,6 @@ export class BlogCrosspostingAutomationStack extends Stack {
187
187
) ;
188
188
}
189
189
secret . grantRead ( identifyNewContentFn ) ;
190
- eventBus . grantPutEventsTo ( identifyNewContentFn ) ;
191
190
192
191
if ( amplify ?. amplifyProjectId ) {
193
192
new Rule ( this , `NewArticlesRule` , {
@@ -228,16 +227,8 @@ export class BlogCrosspostingAutomationStack extends Stack {
228
227
}
229
228
230
229
const { stateMachine } = new CrossPostStepFunction ( this , `CrossPostStepFn` , crossPostStepFunctionProps ) ;
230
+ stateMachine . grantStartExecution ( identifyNewContentFn ) ;
231
231
table . grantReadWriteData ( stateMachine ) ;
232
232
eventBus . grantPutEventsTo ( stateMachine ) ;
233
-
234
- new Rule ( this , "CrossPostMachineRule" , {
235
- eventBus,
236
- eventPattern : {
237
- source : [ `cross-post` ] ,
238
- detailType : [ "process-new-content" ] ,
239
- } ,
240
- targets : [ new SfnStateMachine ( stateMachine , { } ) ] ,
241
- } ) ;
242
233
}
243
234
}
0 commit comments