Sunday, June 6, 2021

AWS CDK简介

 CDK是用多种语言实现的打包工具。


下面介绍是type script (类似于Node.js)

按这几个步骤初试


Step Function

Glue

可以用json来实现state,而不是用new tasks.GlueStartJobRun. 这是因为有些功能并不支持如GlueStartJobRun.sync. 


const stateJson = {

  Type: 'Task',

  Resource: 'arn:aws:states:::dynamodb:putItem',

  Parameters: {

    TableName: table.tableName,

    Item: {

      id: {

        S: 'MyEntry',

      },

    },

  },

  ResultPath: null,

};


Lambda

CDK中step function中的lambda支持payload参数

new tasks.LambdaInvoke(this, 'Invoke with payload field in the state input', {

     lambdaFunction: fn,

      payload: sfn.TaskInput.fromObject({

            "execution.$": "$$.Excution.Id",

            "catalogId": sfn.JsonPath.stringAt('$.catalogId'),

      }),


});


API gateway

https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigateway-readme.html#integration-targets

No comments:

Post a Comment