0

私はしばらくの間、AWSを中心にserverless devをやっていて、SNSのパブ/サブデザインのパターンに入り始めました。私はtypescriptを使用していますが、タイプのサポートは素晴らしいですが、SNSまたはS3トリガーからLambdaに入るイベントのタイプを見つけることができません。これらは機能間の縫い目を実際に非常に安全にするでしょう。私は自分のインターフェースを定義している瞬間、これは面倒です。例えばAWS Lambda SNSトリガイベントタイプ?

interface IAWSSNSTriggerPayload { 
 
    Records: [ 
 
    { 
 
     EventSource: string, 
 
     EventVersion: string, 
 
     EventSubscriptionArn: string, 
 
     Sns: { 
 
     Type: string, 
 
     MessageId: string, 
 
     TopicArn: string, 
 
     Subject: string, 
 
     Message: string, 
 
     Timestamp: string, 
 
     SignatureVersion: string, 
 
     Signature: string, 
 
     SigningCertUrl: string, 
 
     UnsubscribeUrl: string, 
 
     MessageAttributes: {}, 
 
     } 
 
    } 
 
    ] 
 
} 
 

 
export const handler = (event: IAWSSNSTriggerPayload, context, cb) => { 
 
    const response = { 
 
    statusCode: 200, 
 
    body: JSON.stringify({ 
 
     message: 'Go Serverless Webpack (Typescript) v1.0! Your function executed successfully! And from the SNS', 
 
     input: event, 
 
    }), 
 
    }; 
 
    console.log('SNS Received from Lambda Publisher!!!') 
 
    console.log(JSON.stringify(event.Records)) 
 
    cb(null, response); 
 
}

誰もが、私はずっと義務があると思います正しい方向に私を指すことができます。

乾杯。

答えて

関連する問題