|
2 | 2 |
|
3 | 3 | The application may need to send email notifications to users. This document describes how to configure notifications. The notification setup process will: |
4 | 4 |
|
5 | | -1. Configure Amazon SES (Simple Email Service) for sending emails |
6 | | -2. Set up the necessary environment variables for the application service |
| 5 | +1. Create an AWS Pinpoint application for managing notifications |
| 6 | +2. Configure Amazon SES (Simple Email Service) for sending emails |
| 7 | +3. Set up the necessary environment variables for the application service |
7 | 8 |
|
8 | 9 | ## Requirements |
9 | 10 |
|
@@ -31,35 +32,28 @@ make infra-update-app-service APP_NAME=<APP_NAME> ENVIRONMENT=<ENVIRONMENT> |
31 | 32 |
|
32 | 33 | ## 4. Send a test email |
33 | 34 |
|
34 | | -To send a test notification using the AWS CLI, first get the from email address for the environment you want to test. |
| 35 | +To send a test notification using the AWS CLI, first get the application id for the Pinpoint application/project for the environment you want to test. |
35 | 36 |
|
36 | 37 | ```bash |
37 | 38 | bin/terraform-init "infra/<APP_NAME>/service" "<ENVIRONMENT>" |
38 | | -FROM_EMAIL="$(terraform -chdir=infra/<APP_NAME>/service output -raw ses_from_email)" |
| 39 | +APPLICATION_ID="$(terraform -chdir=infra/<APP_NAME>/service output -raw pinpoint_app_id)" |
39 | 40 | ``` |
40 | 41 |
|
41 | 42 | Then run the following command, replacing `<RECIPIENT_EMAIL>` with the email address you want to send to: |
42 | 43 |
|
43 | 44 | ```bash |
44 | | -aws sesv2 send-email \ |
45 | | - --from-email-address "$FROM_EMAIL" \ |
46 | | - --destination "ToAddresses=<RECIPIENT_EMAIL>" \ |
47 | | - --content '{ |
48 | | - "Simple": { |
49 | | - "Subject": { |
50 | | - "Data": "Test notification", |
51 | | - "Charset": "UTF-8" |
52 | | - }, |
53 | | - "Body": { |
54 | | - "Text": { |
55 | | - "Data": "This is a message from the future", |
56 | | - "Charset": "UTF-8" |
57 | | - }, |
58 | | - "Html": { |
59 | | - "Data": "This is a message from the future", |
60 | | - "Charset": "UTF-8" |
61 | | - } |
| 45 | +aws pinpoint send-messages --application-id "$APPLICATION_ID" --message-request '{ |
| 46 | + "Addresses": { |
| 47 | + "<RECIPIENT_EMAIL>": { "ChannelType": "EMAIL" } |
| 48 | + }, |
| 49 | + "MessageConfiguration": { |
| 50 | + "EmailMessage": { |
| 51 | + "SimpleEmail": { |
| 52 | + "Subject": { "Data": "Test notification", "Charset": "UTF-8" }, |
| 53 | + "TextPart": { "Data": "This is a message from the future", "Charset": "UTF-8" }, |
| 54 | + "HtmlPart": { "Data": "This is a message from the future", "Charset": "UTF-8" } |
62 | 55 | } |
63 | | - } |
64 | | - }' |
| 56 | + } |
| 57 | + } |
| 58 | +}' |
65 | 59 | ``` |
0 commit comments