Skip to content

Commit

Permalink
feat: aws statuses mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Jan 30, 2024
1 parent f1a2cf2 commit 27dd8b5
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ const (
HealthStatusMissing HealthStatusCode = "Missing"

HealthStatusCreating = "Creating"
HealthStatusDeleted = "Deleted"
HealthStatusDeleting = "Deleting"
HealthStatusError = "Error"
HealthStatusInaccesible = "Inaccesible"
HealthStatusInfo = "Info"
HealthStatusPending = "Pending"
HealthStatusMaintenance = "Maintenance"
HealthStatusScaling = "Scaling"
HealthStatusUnhealthy = "Unhealthy"
HealthStatusUpdating = "Updating"
HealthStatusWarning = "Warning"
HealthStatusStopping = "Stopping"
)

// Implements custom health assessment that overrides built-in assessment
Expand Down
78 changes: 78 additions & 0 deletions pkg/health/health_aws.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package health

import "strings"

// MapAWSStatus maps an AWS resource's statuses to a Health Code
func MapAWSStatus(status string) string {
if s, found := awsStatusMap[strings.ToLower(status)]; found {
return string(s)
}

return string(HealthStatusUnknown)
}

var awsStatusMap = map[string]HealthStatusCode{
"available": HealthStatusHealthy,
"pending": HealthStatusPending,
"running": HealthStatusHealthy,
"shutting-down": HealthStatusDeleting,
"stopped": HealthStatusSuspended,
"stopping": HealthStatusDeleting,
"terminated": HealthStatusDeleted,

// EKS
"creating": HealthStatusCreating,
"active": HealthStatusHealthy,
"deleting": HealthStatusDeleting,
"failed": HealthStatusError,
"updating": HealthStatusUpdating,
// "pending": HealthStatusPending,

// EBS
// "creating": HealthStatusCreating,
// "available": HealthStatusUpdating,
"in-use": HealthStatusHealthy,
// "deleting": HealthStatusDeleting,
"deleted": HealthStatusDeleted,
"error": HealthStatusError,

// RDS Status
// "available": HealthStatusHealthy,
"billed": HealthStatusHealthy,
"backing-up": HealthStatusMaintenance,
"configuring-enhanced-monitoring": HealthStatusMaintenance,
"configuring-iam-database-auth": HealthStatusMaintenance,
"configuring-log-exports": HealthStatusMaintenance,
"converting-to-vpc": HealthStatusUpdating,
// "creating": HealthStatusCreating,
"delete-precheck": HealthStatusMaintenance,
// "deleting": HealthStatusDeleting,
// "failed": HealthStatusUnhealthy,
"inaccessible-encryption-credentials": HealthStatusInaccesible,
"inaccessible-encryption-credentials-recoverable": HealthStatusInaccesible,
"incompatible-network": HealthStatusUnhealthy,
"incompatible-option-group": HealthStatusUnhealthy,
"incompatible-parameters": HealthStatusUnhealthy,
"incompatible-restore": HealthStatusUnhealthy,
"insufficient-capacity": HealthStatusUnhealthy,
"maintenance": HealthStatusMaintenance,
"modifying": HealthStatusUpdating,
"moving-to-vpc": HealthStatusMaintenance,
"rebooting": HealthStatusStopping,
"resetting-master-credentials": HealthStatusMaintenance,
"renaming": HealthStatusMaintenance,
"restore-error": HealthStatusError,
"starting": HealthStatusProgressing,
// "stopped": HealthStatusSuspended,
// "stopping": HealthStatusStopping,
"storage-config-upgrade": HealthStatusUpdating,
"storage-full": HealthStatusUnhealthy,
"storage-optimization": HealthStatusMaintenance,
"upgrading": HealthStatusUpdating,

// ELB
// "active": HealthStatusHealthy,
"provisioning": HealthStatusProgressing,
"active_impaired": HealthStatusWarning,
// "failed": HealthStatusError,
}

0 comments on commit 27dd8b5

Please sign in to comment.