Exemplo n.º 1
0
 def test_igw(self):
     self.assertEqual(
         utils.resource_format(
             {
                 'InternetGatewayId': 'igw-x',
                 'Attachments': []
             }, 'aws.internet-gateway'), 'id: igw-x  attachments: 0')
Exemplo n.º 2
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')
Exemplo n.º 3
0
 def test_efs(self):
     self.assertEqual(
         utils.resource_format(
             {
                 'Name': 'abc',
                 'FileSystemId': 'fsid',
                 'LifeCycleState': 'available'
             }, 'efs'), 'name: abc  id: fsid  state: available')
Exemplo n.º 4
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')
Exemplo n.º 5
0
 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")
Exemplo n.º 6
0
 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')
Exemplo n.º 7
0
 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')
Exemplo n.º 8
0
 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',
     )
Exemplo n.º 9
0
 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")
Exemplo n.º 10
0
 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",
     )
Exemplo n.º 11
0
 def test_s3(self):
     self.assertEqual(
         utils.resource_format(
             {'Name': 'bucket-x'}, 'aws.s3'),
         'bucket-x')
Exemplo n.º 12
0
 def test_igw(self):
     self.assertEqual(
         utils.resource_format(
             {'InternetGatewayId': 'igw-x', 'Attachments': []},
             'internet-gateway'),
         'id: igw-x  attachments: 0')
Exemplo n.º 13
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')
Exemplo n.º 14
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')
Exemplo n.º 15
0
 def test_efs(self):
     self.assertEqual(
         utils.resource_format(
             {'Name': 'abc', 'FileSystemId': 'fsid', 'LifeCycleState': 'available'},
             'efs'),
         'name: abc  id: fsid  state: available')