AWS email via roles


  • kills Dumbledore

    Anyone used SES via AWS?

    Running locally on my machine with a credentials file, I can send emails no problem.

    On the server, we don't want to have to keep the secret key on the server, so have given the server an IAM role with rights to send email and raw email.

    I can send an email via powershell on the server without providing credentials

    Send-SESEmail -Source "xxxxxxxxxx" -Destination_ToAddress "xxxxxxxxxxx" -Text_Data "This is a test from SES using powershell" -Subject_Data "SES test powershell" -Region "eu-west-1" 
    

    Using equivalent code from the website code fails

    Dim rawMessage As New RawMessage
    
    Using stream As MemoryStream = MailMessageToMemoryStream(message)
        rawMessage.Data = stream
    End Using
    
    Dim request As New SendRawEmailRequest(rawMessage)
    request.Destinations = New List(Of String) From {receiver}
    request.Source = sender
    
    Using client As New AmazonSimpleEmailServiceClient(RegionEndpoint.EUWest1)
        Dim response As SendRawEmailResponse = client.SendRawEmail(request)
        Dim s As String = response.MessageId
    End Using
    
    Unable to find credentials    
    Exception 1 of 4:  System.InvalidOperationException: The app.config/web.config files for the application did not contain credential information
    


  • Disclaimer: I have no idea what I'm talking about.

    The docs for the AmazonSimpleEmailServiceClientconstructor you're using say

    Constructs AmazonSimpleEmailServiceClient with the credentials loaded from the application's default configuration

    Try using another constructor, the one which signature is AmazonSimpleEmailServiceClient(AWSCredentials, RegionEndpoint), with null as credentials.


  • kills Dumbledore

    @zecc That's so crazy it just might work...


  • kills Dumbledore

    That's crazy, it doesn't work



  • I also have no idea what I'm talking about but maybe one of the subclasses of AWSCredentials would do what you need.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.