-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqs.go
46 lines (40 loc) · 881 Bytes
/
sqs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package config
import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sqs"
)
const access = ""
const secret = ""
const region = ""
func GetSession() *session.Session {
return session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{
Region: aws.String(region),
Credentials: credentials.NewStaticCredentials(
access,
secret,
"",
),
},
}))
}
func GetSQSClient() *sqs.SQS {
awsSession := GetSession()
return sqs.New(awsSession)
}
func GetQueueUrl(queueName string) string {
svc := GetSQSClient()
params := &sqs.GetQueueUrlInput{
QueueName: aws.String(queueName),
}
log.Println(params)
res, err := svc.GetQueueUrl(params)
if err != nil {
log.Println(err.Error())
return ""
}
return *res.QueueUrl
}