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) · 766 Bytes
/
Copy pathMyStack.js
File metadata and controls
33 lines (28 loc) · 766 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 Queue
const queue = new sst.Queue(this, "Queue", {
consumer: "src/consumer.main",
});
// Create the HTTP API
const api = new sst.Api(this, "Api", {
defaultFunctionProps: {
// Pass in the queue to our API
environment: {
queueUrl: queue.sqsQueue.queueUrl,
},
},
routes: {
"POST /": "src/lambda.main",
},
});
// Allow the API to publish the queue
api.attachPermissions([queue]);
// Show the API endpoint in the output
this.addOutputs({
ApiEndpoint: api.url,
});
}
}