Created
July 22, 2023 17:36
-
-
Save ocakhasan/053c35a9f0e9a231bb7846b4d9cfa6db to your computer and use it in GitHub Desktop.
Local SQS Queue Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"log" | |
"github.com/aws/aws-sdk-go-v2/aws" | |
"github.com/aws/aws-sdk-go-v2/config" | |
"github.com/aws/aws-sdk-go-v2/service/sqs" | |
) | |
type localResolver struct{} | |
func (l localResolver) ResolveEndpoint(service, region string, options ...interface{}) (aws.Endpoint, error) { | |
return aws.Endpoint{ | |
URL: "http://localhost:9324", | |
SigningRegion: "eu-west-1", | |
}, nil | |
} | |
func main() { | |
cfg, err := config.LoadDefaultConfig(context.Background()) | |
if err != nil { | |
log.Fatal(err) | |
} | |
cfg.EndpointResolverWithOptions = localResolver{} | |
sqsClient := sqs.NewFromConfig(cfg) | |
res, err := sqsClient.ListQueues(context.Background(), &sqs.ListQueuesInput{ | |
MaxResults: aws.Int32(10), | |
NextToken: nil, | |
QueueNamePrefix: nil, | |
}) | |
if err != nil { | |
log.Printf("error while listing the queues") | |
} | |
for _, queue := range res.QueueUrls { | |
log.Println(queue) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code for the blog post of Local SQS Setup With Golang