Enabling AWS SES in serverless.yml

I just atarted using It was easy to set up sending text messages by adding the “SNS:Publish” attribute the the “provider” portion of serverless,yml, but my guess at adding “SES:Publish” didn’t do the same magic:

provider:
  name: aws
  runtime: nodejs6.10
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:*
        - SNS:Publish
        - SES:Publish
      Resource: "*"

Do I need to set this up manually?

Thanks in advance. Having a blast with serverless so far!

-Owen

What error message are you getting?

I think your problem is that while sns:Publish is a valid action, ses:Publis is not.
You probably want ses:SendEmail.

Check out the Cloudonaut IAM reference for all the possible actions.

1 Like

the error was *Missing final ‘@domain

My bad: I had googled this and went down the wrong path. Turns out it was just missing proper email in the “Source” attribute.


var AWS = require('aws-sdk');

function sendEmail(subjectText, bodyText, bodyHTML) {
  
  /* The following example sends a formatted email: */
  AWS.config.region = 'us-east-1';
  var ses = new AWS.SES();
  var params = {
    Destination: {
       ToAddresses: [
          "owendall@agile-innovations.net"
       ]
      }, 
    Message: {
     Body: {
       Html: {
       Charset: "UTF-8", 
       Data: bodyHTML
      }, 
      Text: {
       Charset: "UTF-8", 
       Data: bodyText
      }
     },
     Subject: {
      Charset: "UTF-8", 
      Data: subjectText
      }
    },  
    Source: "owendall@agile-innovations.net",
     Tags: [
       {
         Name: 'source', /* required */
         Value: 'AWS' /* required */
       },
       /* more items */
     ]
   };
 
 ses.sendEmail(params, function(err, data) {
   if (err) console.log(err, err.stack); // an error occurred
   else     console.log("Sent email");           // successful response

 })
}

this worked after following the required process with AWS to verify the email address in the “Destination” object.

1 Like