Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix bugs... #131

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading