gizmo
gizmo copied to clipboard
Connecting to subscriber results in 404
While trying to run the sqs-sub pubsub example, I keep encountering this error:
InvalidAddress: The address https://sqs.us-east-1.amazonaws.com/ is not valid for this endpoint. status code: 404, request id: 14c12121-5d1c-5583-a35d-73d68936cbf6dmcdonald@dmcdonald-mbp15:~/go/src/dmcdonald/pubsubspike/
This traces to the s.sqs.GetQueueUrl
call. I tried calling this api method myself with the following code, and got success:
cfg := aws.NewConfig().WithCredentials(
awscredentials.NewEnvCredentials(),
).WithRegion(region)
sqsClient := sqs.New(session.New(cfg))
if resp, err := sqsClient.GetQueueUrl(&sqs.GetQueueUrlInput{QueueName: &queueName}); err != nil {
fmt.Printf("failed to get queue url: \n%v\n", err)
} else {
fmt.Println(resp)
}
I'm using the same permissions, region and queuename with both the gizmo example and my own test code.
The error response indicates possibly a permissions issue, but I can't seem to reproduce it outside of the gizmo codebase. Any suggestions on how to troubleshoot this further?
I came across the same issue with the example code and you're correct that it is to do with permissions and how this is handled in the example code base.
Firstly, you'll either want to remove the AccessKey
and SecretKeyfrom the config.json. In my opinion these should either be handled by
awsclior through the envars:
AWS_ACCESS_KEY_IDand
AWS_SECRET_ACCESS_KEY`. Checkout this page for more info about handling AWS credentials.
Secondly, you'll need to add your AccountId to config.json
. e.g.: "QueueOwnerAccountId":"123456789012"
This worked for me so hopefully will help.