@@ -2,77 +2,104 @@ package health
2
2
3
3
import "strings"
4
4
5
+ const (
6
+ AWSResourceTypeEBS string = "ebs"
7
+ AWSResourceTypeEC2 string = "ec2"
8
+ AWSResourceTypeEKS string = "eks"
9
+ AWSResourceTypeELB string = "elb"
10
+ AWSResourceTypeRDS string = "rds"
11
+ AWSResourceTypeVPC string = "vpc"
12
+ AWSResourceTypeSubnet string = "subnet"
13
+ )
14
+
5
15
// MapAWSStatus maps an AWS resource's statuses to a Health Code
6
- func MapAWSStatus (status string ) string {
7
- if s , found := awsStatusMap [strings .ToLower (status )]; found {
8
- return string (s )
16
+ func MapAWSStatus (status string , resourceType string ) string {
17
+ if resourceStatuses , found := awsStatusMap [resourceType ]; found {
18
+ if v , found := resourceStatuses [strings .ToLower (status )]; found {
19
+ return string (v )
20
+ }
9
21
}
10
22
11
23
return string (HealthStatusUnknown )
12
24
}
13
25
14
- var awsStatusMap = map [string ]HealthStatusCode {
15
- "available" : HealthStatusHealthy ,
16
- "pending" : HealthStatusPending ,
17
- "running" : HealthStatusHealthy ,
18
- "shutting-down" : HealthStatusDeleting ,
19
- "stopped" : HealthStatusSuspended ,
20
- "stopping" : HealthStatusDeleting ,
21
- "terminated" : HealthStatusDeleted ,
26
+ var awsStatusMap = map [string ]map [string ]HealthStatusCode {
27
+ AWSResourceTypeEC2 : {
28
+ "pending" : HealthStatusPending ,
29
+ "running" : HealthStatusHealthy ,
30
+ "shutting-down" : HealthStatusDeleting ,
31
+ "stopped" : HealthStatusStopped ,
32
+ "stopping" : HealthStatusStopping ,
33
+ "terminated" : HealthStatusDeleted ,
34
+ },
35
+
36
+ AWSResourceTypeEKS : {
37
+ "creating" : HealthStatusCreating ,
38
+ "active" : HealthStatusHealthy ,
39
+ "deleting" : HealthStatusDeleting ,
40
+ "failed" : HealthStatusError ,
41
+ "updating" : HealthStatusUpdating ,
42
+ "pending" : HealthStatusPending ,
43
+ },
44
+
45
+ AWSResourceTypeEBS : {
46
+ "creating" : HealthStatusCreating ,
47
+ "available" : HealthStatusStopped ,
48
+ "in-use" : HealthStatusHealthy ,
49
+ "deleting" : HealthStatusDeleting ,
50
+ "deleted" : HealthStatusDeleted ,
51
+ "error" : HealthStatusError ,
52
+ },
22
53
23
- // EKS
24
- "creating" : HealthStatusCreating ,
25
- "active" : HealthStatusHealthy ,
26
- "deleting" : HealthStatusDeleting ,
27
- "failed" : HealthStatusError ,
28
- "updating" : HealthStatusUpdating ,
29
- // "pending": HealthStatusPending,
54
+ AWSResourceTypeRDS : {
55
+ "available" : HealthStatusHealthy ,
56
+ "billed" : HealthStatusHealthy ,
57
+ "backing-up" : HealthStatusMaintenance ,
58
+ "configuring-enhanced-monitoring" : HealthStatusMaintenance ,
59
+ "configuring-iam-database-auth" : HealthStatusMaintenance ,
60
+ "configuring-log-exports" : HealthStatusMaintenance ,
61
+ "converting-to-vpc" : HealthStatusUpdating ,
62
+ "creating" : HealthStatusCreating ,
63
+ "delete-precheck" : HealthStatusMaintenance ,
64
+ "deleting" : HealthStatusDeleting ,
65
+ "failed" : HealthStatusUnhealthy ,
66
+ "inaccessible-encryption-credentials" : HealthStatusInaccesible ,
67
+ "inaccessible-encryption-credentials-recoverable" : HealthStatusInaccesible ,
68
+ "incompatible-network" : HealthStatusUnhealthy ,
69
+ "incompatible-option-group" : HealthStatusUnhealthy ,
70
+ "incompatible-parameters" : HealthStatusUnhealthy ,
71
+ "incompatible-restore" : HealthStatusUnhealthy ,
72
+ "insufficient-capacity" : HealthStatusUnhealthy ,
73
+ "maintenance" : HealthStatusMaintenance ,
74
+ "modifying" : HealthStatusUpdating ,
75
+ "moving-to-vpc" : HealthStatusMaintenance ,
76
+ "rebooting" : HealthStatusStopping ,
77
+ "resetting-master-credentials" : HealthStatusMaintenance ,
78
+ "renaming" : HealthStatusMaintenance ,
79
+ "restore-error" : HealthStatusError ,
80
+ "starting" : HealthStatusProgressing ,
81
+ "stopped" : HealthStatusStopped ,
82
+ "stopping" : HealthStatusStopping ,
83
+ "storage-config-upgrade" : HealthStatusUpdating ,
84
+ "storage-full" : HealthStatusUnhealthy ,
85
+ "storage-optimization" : HealthStatusMaintenance ,
86
+ "upgrading" : HealthStatusUpdating ,
87
+ },
30
88
31
- // EBS
32
- // "creating": HealthStatusCreating,
33
- // "available": HealthStatusUpdating,
34
- "in-use" : HealthStatusHealthy ,
35
- // "deleting": HealthStatusDeleting,
36
- "deleted" : HealthStatusDeleted ,
37
- "error" : HealthStatusError ,
89
+ AWSResourceTypeELB : {
90
+ "active" : HealthStatusHealthy ,
91
+ "provisioning" : HealthStatusProgressing ,
92
+ "active_impaired" : HealthStatusWarning ,
93
+ "failed" : HealthStatusError ,
94
+ },
38
95
39
- // RDS Status
40
- // "available": HealthStatusHealthy,
41
- "billed" : HealthStatusHealthy ,
42
- "backing-up" : HealthStatusMaintenance ,
43
- "configuring-enhanced-monitoring" : HealthStatusMaintenance ,
44
- "configuring-iam-database-auth" : HealthStatusMaintenance ,
45
- "configuring-log-exports" : HealthStatusMaintenance ,
46
- "converting-to-vpc" : HealthStatusUpdating ,
47
- // "creating": HealthStatusCreating,
48
- "delete-precheck" : HealthStatusMaintenance ,
49
- // "deleting": HealthStatusDeleting,
50
- // "failed": HealthStatusUnhealthy,
51
- "inaccessible-encryption-credentials" : HealthStatusInaccesible ,
52
- "inaccessible-encryption-credentials-recoverable" : HealthStatusInaccesible ,
53
- "incompatible-network" : HealthStatusUnhealthy ,
54
- "incompatible-option-group" : HealthStatusUnhealthy ,
55
- "incompatible-parameters" : HealthStatusUnhealthy ,
56
- "incompatible-restore" : HealthStatusUnhealthy ,
57
- "insufficient-capacity" : HealthStatusUnhealthy ,
58
- "maintenance" : HealthStatusMaintenance ,
59
- "modifying" : HealthStatusUpdating ,
60
- "moving-to-vpc" : HealthStatusMaintenance ,
61
- "rebooting" : HealthStatusStopping ,
62
- "resetting-master-credentials" : HealthStatusMaintenance ,
63
- "renaming" : HealthStatusMaintenance ,
64
- "restore-error" : HealthStatusError ,
65
- "starting" : HealthStatusProgressing ,
66
- // "stopped": HealthStatusSuspended,
67
- // "stopping": HealthStatusStopping,
68
- "storage-config-upgrade" : HealthStatusUpdating ,
69
- "storage-full" : HealthStatusUnhealthy ,
70
- "storage-optimization" : HealthStatusMaintenance ,
71
- "upgrading" : HealthStatusUpdating ,
96
+ AWSResourceTypeVPC : {
97
+ "pending" : HealthStatusPending ,
98
+ "available" : HealthStatusHealthy ,
99
+ },
72
100
73
- // ELB
74
- // "active": HealthStatusHealthy,
75
- "provisioning" : HealthStatusProgressing ,
76
- "active_impaired" : HealthStatusWarning ,
77
- // "failed": HealthStatusError,
101
+ AWSResourceTypeSubnet : {
102
+ "pending" : HealthStatusPending ,
103
+ "available" : HealthStatusHealthy ,
104
+ },
78
105
}
0 commit comments