forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyStack.ts
More file actions
31 lines (27 loc) · 697 Bytes
/
Copy pathMyStack.ts
File metadata and controls
31 lines (27 loc) · 697 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
import { StackContext, Queue, Api } from "@serverless-stack/resources";
export function MyStack({ stack }: StackContext) {
// Create Queue
const queue = new Queue(stack, "Queue", {
consumer: "functions/consumer.main",
});
// Create the HTTP API
const api = new Api(stack, "Api", {
defaults: {
function: {
// Pass in the queue to our API
environment: {
queueUrl: queue.queueUrl,
},
},
},
routes: {
"POST /": "functions/lambda.main",
},
});
// Allow the API to publish the queue
api.attachPermissions([queue]);
// Show the API endpoint in the output
stack.addOutputs({
ApiEndpoint: api.url,
});
}