Created
July 31, 2019 01:54
-
-
Save sam-goodwin/2681554480c32c0498544eae5765333e to your computer and use it in GitHub Desktop.
Vanilla CDK handler example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the CDK application: https://gist.github.com/sam-goodwin/77f6650ef67ad93e5aa97cc38458ca2e