-
Notifications
You must be signed in to change notification settings - Fork 0
/
awslimitchecker.go
60 lines (53 loc) · 1.69 KB
/
awslimitchecker.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
package awslimitchecker
import (
"fmt"
"github.com/sebasrp/awslimitchecker/internal/services"
)
var SupportedAwsServices = map[string]func() services.Svcquota{
"acm": services.NewAcmChecker,
"autoscaling": services.NewAutoscalingChecker,
"cloudformation": services.NewCloudformationChecker,
"dynamodb": services.NewDynamoDbChecker,
"ebs": services.NewEbsChecker,
"eks": services.NewEksChecker,
"elasticache": services.NewElastiCacheChecker,
"elb": services.NewElbChecker,
"iam": services.NewIamChecker,
"kinesis": services.NewKinesisChecker,
"rds": services.NewRdsChecker,
"s3": services.NewS3Checker,
"sns": services.NewSnsChecker,
}
func GetUsage(awsService string, awsprofile string, region string, overrides []services.AWSQuotaOverride) (ret []services.AWSQuotaInfo) {
_, err := services.InitializeConfig(awsprofile, region)
if err != nil {
fmt.Printf("Unable to create AWS session, %v", err)
return
}
if awsService == "all" {
for _, checker := range SupportedAwsServices {
service := checker()
service.SetQuotasOverride(overrides)
ret = append(ret, service.GetUsage()...)
}
} else if val, ok := SupportedAwsServices[awsService]; ok {
service := val()
service.SetQuotasOverride(overrides)
ret = service.GetUsage()
}
return
}
func GetIamPolicies() (ret []string) {
for _, checker := range SupportedAwsServices {
service := checker()
ret = append(ret, service.GetRequiredPermissions()...)
}
return
}
func IsValidAwsService(service string) bool {
if _, ok := SupportedAwsServices[service]; ok || service == "all" {
return true
} else {
return false
}
}