Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in the README does not work #3

Open
ababkin opened this issue Aug 30, 2015 · 6 comments
Open

Example in the README does not work #3

ababkin opened this issue Aug 30, 2015 · 6 comments

Comments

@ababkin
Copy link

ababkin commented Aug 30, 2015

I would really like to see a simple example of sending a SNS message using AWS credentials in environment variables. (It's trivial to get them from the environment, but i cannot figure out how to put them into aws-sns)

The existing example below does not work.
It looks like creds is not used anywhere.

Getting this error (which makes sense, because credentials are not passed correctly)

SnsErrorResponse {snsErrorStatusCode = Status {statusCode = 403, statusMessage = "Forbidden"}, snsErrorCode = "InvalidClientTokenId", snsErrorMessage = "The security token included in the request is invalid", snsErrorResource = Nothing, snsErrorHostId = Nothing, snsErrorAccessKeyId = Nothing, snsErrorStringToSign = Nothing}
import Aws
import Aws.Core
import Aws.General
import Aws.Sns
import Data.IORef

cfg <- Aws.baseConfiguration
creds <- Credentials "access-key-id" "secret-access-key" `fmap` newIORef []
let snsCfg = SnsConfiguration HTTPS UsWest2
simpleAws cfg snsCfg $ ListTopics Nothing
@ababkin
Copy link
Author

ababkin commented Aug 30, 2015

Tried the following variation with no luck (what i successfully use with the aws package for S3)

notify :: Text -> RIO ()
notify s =
  liftIO $ do
    cfg <- Aws.baseConfiguration
    maybeCreds <- Aws.loadCredentialsFromEnv
    case maybeCreds of
      Nothing ->
        putStrLn "Please set the environment variables AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_SECRET"
      Just creds -> do
        let snsCfg = SnsConfiguration HTTPS UsEast1
        print =<< simpleAws cfg{credentials = creds} snsCfg (ListTopics Nothing)

@larskuhtz
Copy link
Member

Thanks a lot for reporting these issues (and the other issues). I don't
have time to work on it this week. I will look into these issues later
next week. I hope that's still early enough.

On 2015-08-30 16:06, Alex Babkin wrote:

Tried the following variation with no luck (what i successfully use with the aws package for S3)

notify :: Text -> RIO ()
notify s =
liftIO $ do
cfg <- Aws.baseConfiguration
maybeCreds <- Aws.loadCredentialsFromEnv
case maybeCreds of
Nothing ->
putStrLn "Please set the environment variables AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_SECRET"
Just creds -> do
let snsCfg = SnsConfiguration HTTPS UsEast1
print =<< simpleAws cfg{credentials = creds} snsCfg (ListTopics Nothing)

Reply to this email directly or view it on GitHub [1].

Links:

[1]
#3 (comment)

@ababkin
Copy link
Author

ababkin commented Sep 5, 2015

Thanks for the response Lars. No real rush.

@greyson
Copy link

greyson commented Jun 25, 2017

I'm recieving the same error in what should be production code. I'm neck-deep in this right now and would be willing to make the modifications to make it work if I knew where to look.

@ababkin
Copy link
Author

ababkin commented Jun 25, 2017

@greyson - looks like this repo is no longer maintained
I'd suggest using amazonka instead: https://github.com/brendanhay/amazonka
Thats what I use now with great results
Cheers!

@greyson
Copy link

greyson commented Jun 25, 2017

@ababkin Thanks. And Ouch; that means I'll want to rewrite my Yesod/AWS integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants