humanmade/aws-ses-wp-mail

Fails to use key & secret on local dev environment

Closed this issue · 5 comments

Simply specifying the key & secret doesn't work on a local dev environment. You have to either:

a) Have a credentials file in the web server users home directory .aws/credentials

b) Pass a credentials object in the params:

$params['credentials'] => array(
  'key' => $this->key,
  'secret' => $this->secret,
  'token' => '' // Need to fetch a token to use email service, via StsClient
);

Question is do we add code to fetch the token or rely solely on the credentials file approach? Right now the defines don't do anything.

Doh, my bad I think!

@joehoyle no worries! Super easy to miss, I was digging through the SDK for a while to find out what it was doing! I have the AWS CLI on my laptop rather than the VM so probably why I hit this problem. What do you think re. fetching the token? I can put some time into it.

Hmm this is the first I've heard about this token, this isn't required for other AWS Services, is this something SES specific?

I think so. It's the first time I've come across it too. I may be missing something but just going off what the error messages say. You should be able to reproduce it by moving your ~/.aws folder temporarily and adding the key & secret & region constants

I just ran into this today when installing this plugin for the first time in production. I went with option B (but didn't need the token) to get the creds to verify. Found the answer on StackOverflow then came here. I changed line 178 of inc/class-ses.php to read:

          if ( $this->key && $this->secret ) {
                $params['credentials']['key'] = $this->key;
                $params['credentials']['secret'] = $this->secret;
                }