def test_igw(self): self.assertEqual( utils.resource_format( { 'InternetGatewayId': 'igw-x', 'Attachments': [] }, 'aws.internet-gateway'), 'id: igw-x attachments: 0')
def test_eip(self): self.assertEqual( utils.resource_format( { 'PublicIp': '8.8.8.8', 'Domain': 'vpc', 'AllocationId': 'eipxyz' }, 'network-addr'), 'ip: 8.8.8.8 id: eipxyz scope: vpc')
def test_efs(self): self.assertEqual( utils.resource_format( { 'Name': 'abc', 'FileSystemId': 'fsid', 'LifeCycleState': 'available' }, 'efs'), 'name: abc id: fsid state: available')
def test_nat(self): self.assertEqual( utils.resource_format( { 'NatGatewayId': 'nat-xyz', 'State': 'available', 'VpcId': 'vpc-123' }, 'nat-gateway'), 'id: nat-xyz state: available vpc: vpc-123')
def test_service_quota_none_usagemetric(self): self.assertEqual( utils.resource_format( { "ServiceName": "AWS Cloud Map", "QuotaName": "Namespaces per Region", "c7n:MatchedFilters": ["UsageMetric"] }, "service-quota", ), "ServiceName: AWS Cloud Map QuotaName: Namespaces per Region\n")
def test_alb(self): self.assertEqual( utils.resource_format( {'LoadBalancerArn': 'arn:aws:elasticloadbalancing:us-east-1:367930536793:' 'loadbalancer/app/dev/1234567890', 'AvailabilityZones': [], 'Scheme': 'internal'}, 'app-elb'), 'arn: arn:aws:elasticloadbalancing:us-east-1:367930536793:' 'loadbalancer/app/dev/1234567890' ' zones: 0 scheme: internal')
def test_rds_cluster(self): self.assertEqual( utils.resource_format( { 'DBClusterIdentifier': 'database-2', 'Engine': 'mysql-aurora', 'EngineVersion': '5.7.mysql_aurora.2.07.2', 'AllocatedStorage': '1' }, 'rds-cluster'), 'database-2 mysql-aurora-5.7.mysql_aurora.2.07.2 1', )
def test_service_quota(self): self.assertEqual( utils.resource_format( { "ServiceName": "Amazon EC2 Auto Scaling", "QuotaName": "Auto Scaling groups per region", "c7n:UsageMetric": { "metric": 54, "quota": 200 }, }, "service-quota", ), "ServiceName: Amazon EC2 Auto Scaling QuotaName: Auto Scaling groups per region " "Quota: 200 Usage: 54\n")
def test_cloudtrail(self): self.assertEqual( utils.resource_format( { "Name": "trail-x", "S3BucketName": "trail-x-bucket", "IncludeGlobalServiceEvents": True, "IsMultiRegionTrail": False, "HomeRegion": "eu-west-2", "TrailARN": "arn:aws:cloudtrail:eu-west-2:123456789012:trail/trail-x", "LogFileValidationEnabled": True, "HasCustomEventSelectors": False, "HasInsightSelectors": False, "IsOrganizationTrail": False, "Tags": [], }, "aws.cloudtrail", ), "trail-x", )
def test_s3(self): self.assertEqual( utils.resource_format( {'Name': 'bucket-x'}, 'aws.s3'), 'bucket-x')
def test_igw(self): self.assertEqual( utils.resource_format( {'InternetGatewayId': 'igw-x', 'Attachments': []}, 'internet-gateway'), 'id: igw-x attachments: 0')
def test_nat(self): self.assertEqual( utils.resource_format( {'NatGatewayId': 'nat-xyz', 'State': 'available', 'VpcId': 'vpc-123'}, 'nat-gateway'), 'id: nat-xyz state: available vpc: vpc-123')
def test_eip(self): self.assertEqual( utils.resource_format( {'PublicIp': '8.8.8.8', 'Domain': 'vpc', 'AllocationId': 'eipxyz'}, 'network-addr'), 'ip: 8.8.8.8 id: eipxyz scope: vpc')
def test_efs(self): self.assertEqual( utils.resource_format( {'Name': 'abc', 'FileSystemId': 'fsid', 'LifeCycleState': 'available'}, 'efs'), 'name: abc id: fsid state: available')