Skip to content

Commit

Permalink
Merge pull request #131 from jinyoungmoonDEV/master
Browse files Browse the repository at this point in the history
fix: fix bugs...
  • Loading branch information
jinyoungmoonDEV authored Jan 10, 2025
2 parents 2d4fac6 + 668e3dc commit ec3fcbc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,21 @@ def _set_alarm_actions(self, raw_alarm: Alarms) -> None:
raw_alarm["actions_enabled"] = "Actions enabled"

for action in alarm_actions:
action_service = self._extract_arn_service(action)
action_type = None
action_description = None
action_config = None

if "sns" in action.lower():
if action_service == "sns":
action_type = "Notification"
arn = action.split(":")[-1]
action_description = f"When in alarm, send message to topic \"{arn}\""
action_config = ""
elif "lambda" in action.lower():
elif action_service == "lambda":
# lambda_client = boto3.client("lambda", region_name=self.region_name, verify=BOTO3_HTTPS_VERIFIED)
# lambda_response = lambda_client.get_function(FunctionName=action.split(':')[-1])
pass
elif "ec2" in action.lower():
elif action_service == "ec2":
# ec2_client = boto3.client("ec2", region_name=self.region_name, verify=BOTO3_HTTPS_VERIFIED)
# ec2_response = ec2_client.describe_instances(InstanceIds=action.split(':')[-1])
pass
Expand Down Expand Up @@ -181,3 +182,8 @@ def _convert_int_type(value):
if isinstance(value, float) and value.is_integer():
return int(value)
return value

@staticmethod
def _extract_arn_service(arn: str) -> str:
match = re.search(r"^arn:[\w\-]+:([\w\-]+):", arn)
return match.group(1)
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class AdministrativeOverride(Model):
class TargetHealthInfo(Model):
target = ModelType(Target, deserialize_from="Target")
health_check_port = IntType(deserialize_from="HealthCheckPort")
health_check_port_display = StringType(deserialize_from="HealthCheckPort")
target_health = ModelType(TargetHealth, deserialize_from="TargetHealth")
anomaly_detection = ModelType(AnomalyDetection, deserialize_from="AnomalyDetection")
administrative_override = ModelType(AdministrativeOverride, deserialize_from="AdministrativeOverride")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@
"Target Health", "data.targets_health",
fields=[
TextDyField.data_source("ID", "target.id"),
TextDyField.data_source("Port", "target.port_display"),
TextDyField.data_source("HealthCheckPort", "health_check_port_display"),
TextDyField.data_source("AvailabilityZone", "target.availability_zone"),
TextDyField.data_source("HealthCheckPort", "health_check_port"),
EnumDyField.data_source(
"State",
"target_health.state",
Expand Down

0 comments on commit ec3fcbc

Please sign in to comment.