forked from Yuzuki616/AWS-Panel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws.go
39 lines (36 loc) · 802 Bytes
/
aws.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
package aws
import (
"crypto/tls"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"net/http"
"net/url"
)
type Aws struct {
Sess *session.Session
}
func New(Region string, Id string, Secret string, Proxy string) (*Aws, error) {
config := &aws.Config{
Region: aws.String(Region),
Credentials: credentials.NewStaticCredentials(Id, Secret, ""),
}
if Proxy != "" {
config.HTTPClient = &http.Client{
Transport: &http.Transport{
Proxy: func(*http.Request) (*url.URL, error) {
return url.Parse(Proxy)
},
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
}
sess, err := session.NewSession(config)
if err != nil {
return nil, err
}
c := &Aws{
Sess: sess,
}
return c, nil
}