/
provider.go
74 lines (66 loc) · 1.38 KB
/
provider.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package aws
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/apigateway"
"github.com/aws/aws-sdk-go-v2/service/lambda"
)
type Provider struct {
fclient *lambda.Client
gclient *apigateway.Client
region string
roleArn *string
ctx context.Context
}
func New(accessKey, secretKey, region, roleArn string) (*Provider, error) {
creds := aws.NewCredentialsCache(credentials.NewStaticCredentialsProvider(accessKey, secretKey, ""))
return &Provider{
fclient: lambda.New(lambda.Options{
Region: region,
Credentials: creds,
}),
gclient: apigateway.New(apigateway.Options{
Region: region,
Credentials: creds,
}),
region: region,
roleArn: aws.String(roleArn),
ctx: context.TODO(),
}, nil
}
func (p *Provider) Name() string {
return "aws"
}
func (p *Provider) Region() string {
return p.region
}
func Regions() []string {
return []string{
"us-east-2",
"us-east-1",
"us-west-1",
"us-west-2",
"af-south-1",
"ap-east-1",
"ap-southeast-3",
"ap-south-1",
"ap-northeast-3",
"ap-northeast-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-northeast-1",
"ca-central-1",
"eu-central-1",
"eu-west-1",
"eu-west-2",
"eu-south-1",
"eu-west-3",
"eu-north-1",
"me-south-1",
"me-central-1",
"sa-east-1",
"us-gov-east-1",
"us-gov-west-1",
}
}