Skip to content

Instantly share code, notes, and snippets.

@sam-goodwin
Last active August 7, 2019 05:48
Show Gist options
  • Save sam-goodwin/77f6650ef67ad93e5aa97cc38458ca2e to your computer and use it in GitHub Desktop.
Save sam-goodwin/77f6650ef67ad93e5aa97cc38458ca2e to your computer and use it in GitHub Desktop.
Vanilla CDK application example
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);
@sam-goodwin
Copy link
Author

sam-goodwin commented Jul 31, 2019

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