This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Resource } from "sst"; | ||
import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; | ||
|
||
const client = new SESv2Client(); | ||
|
||
export const sender = async () => { | ||
await client.send( | ||
new SendEmailCommand({ | ||
FromEmailAddress: Resource.MyEmail.sender, | ||
Destination: { | ||
ToAddresses: [Resource.MyEmail.sender], | ||
}, | ||
Content: { | ||
Simple: { | ||
Subject: { | ||
Data: "Hello World!", | ||
}, | ||
Body: { | ||
Text: { | ||
Data: "Sent from my SST app.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
return { | ||
statusCode: 200, | ||
body: "Sent!", | ||
}; | ||
}; | ||
|
||
export const notification = async (event: any) => { | ||
console.log(JSON.stringify(event, null, 2)); | ||
return { | ||
statusCode: 200, | ||
body: "Received!", | ||
}; | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ export default $config({ | |
|
||
const vpc = addVpc(); | ||
const bucket = addBucket(); | ||
//const email = addEmail(); | ||
//const apiv1 = addApiV1(); | ||
//const apiv2 = addApiV2(); | ||
//const app = addFunction(); | ||
|
@@ -32,6 +33,33 @@ export default $config({ | |
return bucket; | ||
} | ||
|
||
function addEmail() { | ||
const topic = new sst.aws.SnsTopic("MyTopic"); | ||
topic.subscribe("functions/email/index.notification"); | ||
|
||
const email = new sst.aws.Email("MyEmail", { | ||
sender: "[email protected]", | ||
events: [ | ||
{ | ||
name: "notif", | ||
types: ["delivery"], | ||
topic: topic.arn, | ||
}, | ||
], | ||
}); | ||
|
||
const sender = new sst.aws.Function("MyApi", { | ||
handler: "functions/email/index.sender", | ||
link: [email], | ||
url: true, | ||
}); | ||
|
||
ret.emailSend = sender.url; | ||
ret.email = email.sender; | ||
ret.emailConfig = email.configSet; | ||
return ret; | ||
} | ||
|
||
function addCron() { | ||
const cron = new sst.aws.Cron("MyCron", { | ||
schedule: "rate(1 minute)", | ||
|
This file contains 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
This file contains 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