forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyStack.js
More file actions
33 lines (28 loc) · 797 Bytes
/
Copy pathMyStack.js
File metadata and controls
33 lines (28 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as sst from "@serverless-stack/resources";
export default class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Create Topic
const topic = new sst.Topic(this, "Ordered", {
subscribers: ["src/receipt.main", "src/shipping.main"],
});
// Create the HTTP API
const api = new sst.Api(this, "Api", {
defaultFunctionProps: {
// Pass in the topic to our API
environment: {
topicArn: topic.snsTopic.topicArn,
},
},
routes: {
"POST /order": "src/order.main",
},
});
// Allow the API to publish the topic
api.attachPermissions([topic]);
// Show the API endpoint in the output
this.addOutputs({
ApiEndpoint: api.url,
});
}
}