Last active
August 7, 2019 05:48
-
-
Save sam-goodwin/77f6650ef67ad93e5aa97cc38458ca2e to your computer and use it in GitHub Desktop.
Vanilla CDK application 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
import cdk = require('@aws-cdk/core'); | |
import lambda = require('@aws-cdk/aws-lambda'); | |
import sns = require('@aws-cdk/aws-sns'); | |
import path = require('path'); | |
const app = new cdk.App(); | |
const stack = new cdk.Stack(app, 'my-stack'); | |
const topic = new sns.Topic(stack, 'MyTopic'); | |
const func = new lambda.Function(stack, 'MyFunction', { | |
runtime: lambda.Runtime.NODEJS_10_X, | |
handler: 'index.handler', | |
code: lambda.Code.asset(path.join(__dirname, 'handlers')), | |
environment: { | |
TOPIC_ARN: topic.topicArn | |
} | |
}); | |
topic.grantPublish(func); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the handler code: https://gist.github.com/sam-goodwin/2681554480c32c0498544eae5765333e