Dynamodb 使用 aws CDK 定义并部署到 localstack:
new Table(this, 'idlist-staging', {
tableName: 'idlist-staging',
readCapacity: 1,
writeCapacity: 1,
partitionKey: { name: 'external_id', type: AttributeType.STRING },
pointInTimeRecovery: true,
removalPolicy: RemovalPolicy.DESTROY,
billingMode: BillingMode.PROVISIONED
});
本地堆栈上的状态机具有以下条目:
"Deletion": {
"Type": "Task",
"Resource": "arn:aws:states:::dynamodb:deleteItem",
"Parameters": {
"TableName": "idlist-staging",
"Key": {
"external_id": {
"S.$": "$.exid"
}
}
},
"Next": "Confirmation",
"ResultPath": null
},
按要求更新:构造状态机的 cdk 代码:
const machine = new CfnStateMachine(this, smId, {
stateMachineName: 'sync-machine-staging',
// role already has Effect.Allow on dynamodb put/get/delet + db arn
roleArn: role.roleArn,
definitionString: JSON.stringify(
stateMachineDefinition,
),
});
引用 dynamodb 表的正确方法是什么?我们是否仍将arn:aws:states:::dynamodb:deleteItem
其用作资源和idlist-staging
表,因为一旦状态机更新为引用 dynamodb,cdk 将不会部署。CDK 在从 step 函数中删除引用时部署。
任何有关如何解决此问题或调试此问题的帮助表示赞赏。