-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
48 lines (39 loc) · 952 Bytes
/
factory.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
47
48
package awsclient
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/ssm"
)
type Factory struct {
sess *session.Session
}
func NewFactory() (*Factory, error) {
sess, err := session.NewSession()
if err != nil {
return nil, err
}
return &Factory{
sess: sess,
}, nil
}
func (f *Factory) Region() string {
return *f.sess.Config.Region
}
func (f *Factory) SSM() SSM {
return SSM(ssm.New(f.sess))
}
func (f *Factory) S3() S3 {
return S3(s3.New(f.sess))
}
func (f *Factory) DynamoDB() DynamoDB {
return DynamoDB(dynamodb.New(f.sess))
}
func (f *Factory) CloudWatchLogs() CloudWatchLogs {
return CloudWatchLogs(cloudwatchlogs.New(f.sess))
}
func (f *Factory) Kinesis() Kinesis {
return Kinesis(kinesis.New(f.sess))
}