Hey there, thanks for creating SST which is awesom...
# sst
l
Hey there, thanks for creating SST which is awesome! I’m trying to work out how AWS CDK works together with SST and just found that
sst start
command not watching the code changes anymore if the code located under
src/notes
folder. Initially followed the graphql-appsync example which was working fine. Just wondering whether SST supports that? Or maybe something wrong with my setup? Thanks
Here’s the code for integrating CDK with SST
Copy code
```
import * as sst from "@serverless-stack/resources";
import * as appsync from '@aws-cdk/aws-appsync';
import * as lambda from '@aws-cdk/aws-lambda';
import * as db from '@aws-cdk/aws-dynamodb';
export class AppsyncSstStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const api = new appsync.GraphqlApi(this, `${scope.stage}-AppSyncApi`, {
      name: `${scope.stage}-AppSyncApi`,
      schema: appsync.Schema.fromAsset('graphql/schema.graphql'),
    })

    const noteTable = new db.Table(this, 'Notes', {
      partitionKey: { name: 'id', type: db.AttributeType.STRING },
    })

    const notesQueryHandler = new lambda.Function(this, 'QueryDataHandler', {
      runtime: lambda.Runtime.NODEJS_14_X,
      code: lambda.Code.fromAsset('src/notes'),
      handler: 'index.handler',
      environment: {
        NOTES_TABLE: noteTable.tableName,
      },
    })
    noteTable.grantFullAccess(notesQueryHandler)

    const notesDataSource = api.addLambdaDataSource("notesDataSrouce", notesQueryHandler);
    notesDataSource.createResolver({
      typeName: 'Query',
      fieldName: 'getNoteById'
    })
  }
}
```
From
sst-debug.log
, with above code, the code under
src/notes
doesn’t seem to be watched. Well for the graphql-appsync example code, can see
lambda-watcher-state
in the log with
"entryPointsData":{"./src/notes/main.handler"
looks like code watch only works for sst lambda, but not for cdk?
@Frank can I get some help please? Thanks 😊
f
Hey @Longyang Zhang, yeah live debugging only works with
sst.Function
. You can try defining your Lambda function above like this:
Copy code
const notesQueryHandler = new sst.Function(this, 'QueryDataHandler', {
      runtime: lambda.Runtime.NODEJS_14_X,
      handler: 'src/notes/index.handler',
      environment: {
        NOTES_TABLE: noteTable.tableName,
      },
    })
Give it a try.
l
Thank you! Will have a try later