From 4d4abee01f18f8a78d42401c3f20518f53ac0d45 Mon Sep 17 00:00:00 2001 From: Gareth McShane Date: Wed, 16 Oct 2024 14:58:25 +1100 Subject: [PATCH 1/2] add the advisor-check classes to support.py --- c7n/resources/support.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/c7n/resources/support.py b/c7n/resources/support.py index 5031c87d6c4..f836d88f7cf 100644 --- a/c7n/resources/support.py +++ b/c7n/resources/support.py @@ -1,7 +1,7 @@ # Copyright The Cloud Custodian Authors. # SPDX-License-Identifier: Apache-2.0 from c7n.manager import resources -from c7n.query import QueryResourceManager, TypeInfo +from c7n.query import QueryResourceManager, TypeInfo, DescribeSource from c7n.utils import local_session, get_support_region @@ -22,3 +22,32 @@ class resource_type(TypeInfo): def get_client(self): region = get_support_region(self) return local_session(self.session_factory).client('support', region_name=region) + + +class DescribeAdvisorCheck(DescribeSource): + def resources(self, query): + if not query: + query = {'language': 'en'} + return super().resources(query) + + +@resources.register("advisor-check") +class AdvisorCheck(QueryResourceManager): + + class resource_type(TypeInfo): + service = "support" + enum_spec = ('describe_trusted_advisor_checks', 'checks', None) + detail_spec = ( + 'describe_trusted_advisor_check_result', + 'checkId', + 'id', + 'result', + ) + arn_type = "checks" + arn_service = "trustedadvisor" + name = id = "checkId" + universal_taggable = object() + + source_mapping = { + "describe": DescribeAdvisorCheck, + } From 0d5ad0e41e8f9761ddd77eb990a0142df3d3988c Mon Sep 17 00:00:00 2001 From: Gareth McShane Date: Wed, 16 Oct 2024 14:58:40 +1100 Subject: [PATCH 2/2] add the advisor-check to the resource map --- c7n/resources/resource_map.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/c7n/resources/resource_map.py b/c7n/resources/resource_map.py index c8b85df2dbc..661f69331b4 100644 --- a/c7n/resources/resource_map.py +++ b/c7n/resources/resource_map.py @@ -5,6 +5,7 @@ "aws.acm-certificate": "c7n.resources.acm.Certificate", "aws.airflow": "c7n.resources.airflow.ApacheAirflow", "aws.alarm": "c7n.resources.cw.Alarm", + "aws.advisor-check": "c7n.resources.support.AdvisorCheck", "aws.ami": "c7n.resources.ami.AMI", "aws.apigwv2": "c7n.resources.apigw.ApiGwV2", "aws.apigw-domain-name": "c7n.resources.apigw.CustomDomainName", @@ -71,7 +72,8 @@ "aws.eks-nodegroup": "c7n.resources.eks.NodeGroup", "aws.elasticbeanstalk": "c7n.resources.elasticbeanstalk.ElasticBeanstalk", "aws.elasticbeanstalk-environment": ( - "c7n.resources.elasticbeanstalk.ElasticBeanstalkEnvironment"), + "c7n.resources.elasticbeanstalk.ElasticBeanstalkEnvironment" + ), "aws.elasticache-group": "c7n.resources.elasticache.ElastiCacheReplicationGroup", "aws.elasticsearch": "c7n.resources.elasticsearch.ElasticSearchDomain", "aws.elasticsearch-reserved": "c7n.resources.elasticsearch.ReservedInstances", @@ -225,5 +227,5 @@ "aws.waf-regional": "c7n.resources.waf.RegionalWAF", "aws.workspaces": "c7n.resources.workspaces.Workspace", "aws.workspaces-directory": "c7n.resources.workspaces.WorkspaceDirectory", - "aws.workspaces-image": "c7n.resources.workspaces.WorkspaceImage" + "aws.workspaces-image": "c7n.resources.workspaces.WorkspaceImage", }