def _create_dynamodb_sections(names, tags): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('dynamodb_names', names) config.add_service_tags('dynamodb_tags', tags) fake_dynamodb_client = FakeDynamoDBClient() fake_cloudwatch_client = FakeCloudwatchClient() dynamodb_limits_distributor = ResultDistributor() dynamodb_summary_distributor = ResultDistributor() dynamodb_limits = DynamoDBLimits(fake_dynamodb_client, region, config, dynamodb_limits_distributor) dynamodb_summary = DynamoDBSummary(fake_dynamodb_client, region, config, dynamodb_summary_distributor) dynamodb_table = DynamoDBTable(fake_cloudwatch_client, region, config) dynamodb_limits_distributor.add(dynamodb_summary) dynamodb_summary_distributor.add(dynamodb_table) return { 'dynamodb_limits': dynamodb_limits, 'dynamodb_summary': dynamodb_summary, 'dynamodb_table': dynamodb_table, }
def _create_s3_sections(names, tags): # on_time is somehow not feeded from here to S3Limits, so use monkey patch... monkeypatch.setattr(agent_aws, "NOW", dt.strptime('2020-09-28 15:30 UTC', '%Y-%m-%d %H:%M %Z')) region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('s3_names', names) config.add_service_tags('s3_tags', tags) fake_s3_client = FakeS3Client() fake_cloudwatch_client = FakeCloudwatchClient() s3_limits_distributor = ResultDistributor() s3_summary_distributor = ResultDistributor() s3_limits = S3Limits(fake_s3_client, region, config, s3_limits_distributor) s3_summary = S3Summary(fake_s3_client, region, config, s3_summary_distributor) s3 = S3(fake_cloudwatch_client, region, config) s3_requests = S3Requests(fake_cloudwatch_client, region, config) s3_limits_distributor.add(s3_summary) s3_summary_distributor.add(s3) s3_summary_distributor.add(s3_requests) return s3_limits, s3_summary, s3, s3_requests
def _create_elb_sections(names, tags): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('elb_names', names) config.add_service_tags('elb_tags', tags) fake_elb_client = FakeELBClient() fake_cloudwatch_client = FakeCloudwatchClient() elb_limits_distributor = ResultDistributor() elb_summary_distributor = ResultDistributor() elb_limits = ELBLimits(fake_elb_client, region, config, elb_limits_distributor) elb_summary = ELBSummaryGeneric(fake_elb_client, region, config, elb_summary_distributor, resource='elb') elb_labels = ELBLabelsGeneric(fake_elb_client, region, config, resource='elb') elb_health = ELBHealth(fake_elb_client, region, config) elb = ELB(fake_cloudwatch_client, region, config) elb_limits_distributor.add(elb_summary) elb_summary_distributor.add(elb_labels) elb_summary_distributor.add(elb_health) elb_summary_distributor.add(elb) return elb_limits, elb_summary, elb_labels, elb_health, elb
def _create_ec2_sections(names, tags): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('ec2_names', names) config.add_service_tags('ec2_tags', tags) fake_ec2_client = FakeEC2Client() fake_cloudwatch_client = FakeCloudwatchClient() fake_service_quotas_client = FakeServiceQuotasClient() ec2_limits_distributor = ResultDistributor() ec2_summary_distributor = ResultDistributor() ec2_limits = EC2Limits(fake_ec2_client, region, config, ec2_limits_distributor, fake_service_quotas_client) ec2_summary = EC2Summary(fake_ec2_client, region, config, ec2_summary_distributor) ec2_labels = EC2Labels(fake_ec2_client, region, config) ec2_security_groups = EC2SecurityGroups(fake_ec2_client, region, config) ec2 = EC2(fake_cloudwatch_client, region, config) ec2_limits_distributor.add(ec2_summary) ec2_summary_distributor.add(ec2_labels) ec2_summary_distributor.add(ec2_security_groups) ec2_summary_distributor.add(ec2) return ec2_limits, ec2_summary, ec2_labels, ec2_security_groups, ec2
def _create_elbv2_sections(names, tags): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('elbv2_names', names) config.add_service_tags('elbv2_tags', tags) fake_elbv2_client = FakeELBv2Client() fake_cloudwatch_client = FakeCloudwatchClient() elbv2_limits_distributor = ResultDistributor() elbv2_summary_distributor = ResultDistributor() elbv2_limits = ELBv2Limits(fake_elbv2_client, region, config, elbv2_limits_distributor) elbv2_summary = ELBSummaryGeneric(fake_elbv2_client, region, config, elbv2_summary_distributor, resource='elbv2') elbv2_labels = ELBLabelsGeneric(fake_elbv2_client, region, config, resource='elbv2') elbv2_target_groups = ELBv2TargetGroups(fake_elbv2_client, region, config) elbv2_application = ELBv2Application(fake_cloudwatch_client, region, config) elbv2_network = ELBv2Network(fake_cloudwatch_client, region, config) elbv2_limits_distributor.add(elbv2_summary) elbv2_summary_distributor.add(elbv2_labels) elbv2_summary_distributor.add(elbv2_target_groups) elbv2_summary_distributor.add(elbv2_application) elbv2_summary_distributor.add(elbv2_network) return elbv2_limits, elbv2_summary, elbv2_labels, elbv2_target_groups, elbv2_application, elbv2_network
def _create_ebs_sections(names, tags): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('ebs_names', names) config.add_service_tags('ebs_tags', tags) config.add_single_service_config('ec2_names', None) config.add_service_tags('ec2_tags', (None, None)) fake_ec2_client = FakeEC2Client() fake_cloudwatch_client = FakeCloudwatchClient() ec2_summary_distributor = ResultDistributor() ebs_limits_distributor = ResultDistributor() ebs_summary_distributor = ResultDistributor() ec2_summary = EC2Summary(fake_ec2_client, region, config, ec2_summary_distributor) ebs_limits = EBSLimits(fake_ec2_client, region, config, ebs_limits_distributor) ebs_summary = EBSSummary(fake_ec2_client, region, config, ebs_summary_distributor) ebs = EBS(fake_cloudwatch_client, region, config) ec2_summary_distributor.add(ebs_summary) ebs_limits_distributor.add(ebs_summary) ebs_summary_distributor.add(ebs) return ec2_summary, ebs_limits, ebs_summary, ebs
def _create_cloudwatch_alarms_sections(alarm_names): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('cloudwatch_alarms', alarm_names) fake_cloudwatch_client = FakeCloudwatchClient() cloudwatch_alarms_limits_distributor = ResultDistributor() cloudwatch_alarms_limits = CloudwatchAlarmsLimits(fake_cloudwatch_client, region, config, cloudwatch_alarms_limits_distributor) cloudwatch_alarms = CloudwatchAlarms(fake_cloudwatch_client, region, config) cloudwatch_alarms_limits_distributor.add(cloudwatch_alarms) return cloudwatch_alarms_limits, cloudwatch_alarms
def _create_rds_sections(): region = 'region' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('rds_names', None) config.add_service_tags('rds_tags', (None, None)) fake_rds_client = FakeRDSClient() fake_cloudwatch_client = FakeCloudwatchClient() rds_summary_distributor = ResultDistributor() rds_limits = RDSLimits(FakeRDSClient(), region, config) rds_summary = RDSSummary(fake_rds_client, region, config, rds_summary_distributor) rds = RDS(fake_cloudwatch_client, region, config) rds_summary_distributor.add(rds) return rds_limits, rds_summary, rds
def _create_glacier_sections(names, tags): region = 'eu-central-1' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('glacier_names', names) config.add_service_tags('glacier_tags', tags) fake_glacier_client = FakeGlacierClient() fake_cloudwatch_client = FakeCloudwatchClient() glacier_limits_distributor = ResultDistributor() glacier_summary_distributor = ResultDistributor() glacier_limits = GlacierLimits(fake_glacier_client, region, config, glacier_limits_distributor) glacier_summary = GlacierSummary(fake_glacier_client, region, config, glacier_summary_distributor) glacier = Glacier(fake_cloudwatch_client, region, config) glacier_limits_distributor.add(glacier_summary) glacier_summary_distributor.add(glacier) return glacier_limits, glacier_summary, glacier
def _create_s3_sections(names, tags): region = 'region' config = AWSConfig('hostname', (None, None)) config.add_single_service_config('s3_names', names) config.add_service_tags('s3_tags', tags) fake_s3_client = FakeS3Client() fake_cloudwatch_client = FakeCloudwatchClient() s3_limits_distributor = ResultDistributor() s3_summary_distributor = ResultDistributor() s3_limits = S3Limits(fake_s3_client, region, config, s3_limits_distributor) s3_summary = S3Summary(fake_s3_client, region, config, s3_summary_distributor) s3 = S3(fake_cloudwatch_client, region, config) s3_requests = S3Requests(fake_cloudwatch_client, region, config) s3_limits_distributor.add(s3_summary) s3_summary_distributor.add(s3) s3_summary_distributor.add(s3_requests) return s3_limits, s3_summary, s3, s3_requests
def create_sections(names, tags, is_regional): if is_regional: region = 'region' scope = 'REGIONAL' else: region = 'us-east-1' scope = 'CLOUDFRONT' config = AWSConfig('hostname', [], (None, None)) config.add_single_service_config('wafv2_names', names) config.add_service_tags('wafv2_tags', tags) fake_wafv2_client = FakeWAFV2Client() fake_cloudwatch_client = FakeCloudwatchClient() wafv2_limits_distributor = ResultDistributor() wafv2_summary_distributor = ResultDistributor() wafv2_limits = WAFV2Limits(fake_wafv2_client, region, config, scope, distributor=wafv2_limits_distributor) wafv2_summary = WAFV2Summary(fake_wafv2_client, region, config, scope, distributor=wafv2_summary_distributor) wafv2_web_acl = WAFV2WebACL(fake_cloudwatch_client, region, config, is_regional) wafv2_limits_distributor.add(wafv2_summary) wafv2_summary_distributor.add(wafv2_web_acl) return { 'wafv2_limits': wafv2_limits, 'wafv2_summary': wafv2_summary, 'wafv2_web_acl': wafv2_web_acl, }