Skip to content

Instantly share code, notes, and snippets.

@sam-goodwin
Created July 31, 2019 01:54
Show Gist options
  • Save sam-goodwin/2681554480c32c0498544eae5765333e to your computer and use it in GitHub Desktop.
Save sam-goodwin/2681554480c32c0498544eae5765333e to your computer and use it in GitHub Desktop.
Vanilla CDK handler example
// manually create the AWS client, look up environment variables etc.
const AWS = require('aws-sdk');
const sns = new AWS.SNS();
const topicArn = process.env.TOPIC_ARN;
if (!topicArn) {
throw new Error('TOPIC_ARN must be defined');
}
export async function handler() {
await sns.publish({
// serialization is manual
Message: JSON.stringify({
key: 'some key',
count: 1,
timestamp: new Date().toISOString()
}),
// topic ARN must be defined manually also
TopicArn: topicArn
})
}
@sam-goodwin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment