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: add tags for cloudwatch #133

Merged
merged 2 commits 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
56 changes: 28 additions & 28 deletions src/spaceone/inventory/conf/cloud_service_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@
DEFAULT_VULNERABLE_PORTS = "22,3306"

CLOUD_SERVICE_GROUP_MAP = {
"IAM": "IAMConnectorManager",
"DynamoDB": "DynamoDBConnectorManager",
"Lambda": "LambdaConnectorManager",
"CloudFront": "CloudFrontConnectorManager",
"RDS": "RDSConnectorManager",
"Route53": "Route53ConnectorManager",
"S3": "S3ConnectorManager",
"ElastiCache": "ElastiCacheConnectorManager",
"APIGateway": "APIGatewayConnectorManager",
"DirectConnect": "DirectConnectConnectorManager",
"EFS": "EFSConnectorManager",
"DocumentDB": "DocumentDBConnectorManager",
"ECS": "ECSConnectorManager",
"Redshift": "RedshiftConnectorManager",
"EKS": "EKSConnectorManager",
"SQS": "SQSConnectorManager",
"KMS": "KMSConnectorManager",
"ECR": "ECRConnectorManager",
"CloudTrail": "CloudTrailConnectorManager",
"SNS": "SNSConnectorManager",
"SecretsManager": "SecretsManagerConnectorManager",
"ELB": "ELBConnectorManager",
"VPC": "VPCConnectorManager",
"ACM": "ACMConnectorManager",
"KinesisDataStream": "KinesisDataStreamConnectorManager",
"MSK": "MSKConnectorManager",
"KinesisFirehose": "KinesisFirehoseConnectorManager",
"Lightsail": "LightsailConnectorManager",
# "IAM": "IAMConnectorManager",
# "DynamoDB": "DynamoDBConnectorManager",
# "Lambda": "LambdaConnectorManager",
# "CloudFront": "CloudFrontConnectorManager",
# "RDS": "RDSConnectorManager",
# "Route53": "Route53ConnectorManager",
# "S3": "S3ConnectorManager",
# "ElastiCache": "ElastiCacheConnectorManager",
# "APIGateway": "APIGatewayConnectorManager",
# "DirectConnect": "DirectConnectConnectorManager",
# "EFS": "EFSConnectorManager",
# "DocumentDB": "DocumentDBConnectorManager",
# "ECS": "ECSConnectorManager",
# "Redshift": "RedshiftConnectorManager",
# "EKS": "EKSConnectorManager",
# "SQS": "SQSConnectorManager",
# "KMS": "KMSConnectorManager",
# "ECR": "ECRConnectorManager",
# "CloudTrail": "CloudTrailConnectorManager",
# "SNS": "SNSConnectorManager",
# "SecretsManager": "SecretsManagerConnectorManager",
# "ELB": "ELBConnectorManager",
# "VPC": "VPCConnectorManager",
# "ACM": "ACMConnectorManager",
# "KinesisDataStream": "KinesisDataStreamConnectorManager",
# "MSK": "MSKConnectorManager",
# "KinesisFirehose": "KinesisFirehoseConnectorManager",
# "Lightsail": "LightsailConnectorManager",
"CloudWatch": "CloudWatchConnectorManager",
# Not used services
# "EC2": "EC2ConnectorManager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def request_alarms_data(self, region_name: str) -> List[Table]:
self._set_alarm_conditions(raw_alarm)
self._set_alarm_actions(raw_alarm)
self._set_alarm_history(raw_alarm)
tags = self._get_alarms_tags(raw_alarm.get("AlarmArn"))

alarms_vo = Alarms(raw_alarm, strict=False)
self.alarms.append(alarms_vo)
Expand All @@ -94,6 +95,7 @@ def request_alarms_data(self, region_name: str) -> List[Table]:
"data": alarms_vo,
"name": alarms_vo.name,
"account": self.account_id,
"tags": self.convert_tags_to_dict_type(tags)
}

except Exception as e:
Expand Down Expand Up @@ -177,6 +179,10 @@ def _set_alarm_history(self, raw_alarm: Alarms) -> None:
}
)

def _get_alarms_tags(self, alarm_arn: str):
response = self.client.list_tags_for_resource(ResourceARN=alarm_arn)
return response["Tags"]

@staticmethod
def _convert_int_type(value):
if isinstance(value, float) and value.is_integer():
Expand Down
Loading