Пример #1
0
    def current(self):
        try:
            topic_attrs = self.boto_session.client('sns').get_topic_attributes(TopicArn=self.instance_id)['Attributes']
        except self.boto_session.client('sns').exceptions.NotFoundException as e:
            raise InstanceWithIdentifierNotFound(self) from e

        return int(topic_attrs['SubscriptionsConfirmed']) + int(topic_attrs['SubscriptionsPending'])
Пример #2
0
 def current(self):
     try:
         return len(
             self.boto_session.client('iam').list_role_policies(
                 RoleName=self.instance_id)['PolicyNames'])
     except self.boto_session.client(
             'iam').exceptions.NoSuchEntityException as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #3
0
 def maximum(self):
     try:
         return self.boto_session.client('route53').get_hosted_zone_limit(
             Type='MAX_RRSETS_BY_ZONE',
             HostedZoneId=self.instance_id)['Limit']['Value']
     except self.boto_session.client(
             'route53').exceptions.NoSuchHostedZone as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #4
0
 def current(self):
     try:
         return len(
             self.boto_session.client('elbv2').describe_listeners(
                 LoadBalancerArn=self.instance_id)['Listeners'])
     except self.boto_session.client(
             'elbv2').exceptions.LoadBalancerNotFoundException as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #5
0
 def current(self) -> int:
     try:
         return len(
             self.boto_session.client('elbv2').describe_target_groups(
                 LoadBalancerArn=self.instance_id)['TargetGroups'])
     except self.boto_session.client(
             'elbv2').exceptions.LoadBalancerNotFoundException as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #6
0
 def current(self):
     try:
         return self.boto_session.client('route53').get_hosted_zone_limit(
             Type='MAX_VPCS_ASSOCIATED_BY_ZONE',
             HostedZoneId=self.instance_id)['Count']
     except self.boto_session.client(
             'route53').exceptions.NoSuchHostedZone as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #7
0
 def current(self):
     try:
         return len(
             self.boto_session.client('elb').describe_load_balancers(
                 LoadBalancerNames=[self.instance_id])
             ['LoadBalancerDescriptions'][0]['ListenerDescriptions'])
     except self.boto_session.client(
             'elb').exceptions.AccessPointNotFoundException as e:
         raise InstanceWithIdentifierNotFound(self) from e
Пример #8
0
 def current(self) -> int:
     acls = get_all_network_acls(self.boto_session)
     if self.instance_id in [acl['NetworkAclId'] for acl in acls]:
         return len(
             next(
                 filter(lambda acl: self.instance_id == acl['NetworkAclId'],
                        acls))['Entries'])
     else:
         raise InstanceWithIdentifierNotFound(self)
Пример #9
0
 def current(self) -> int:
     try:
         vpc = get_vpc_by_id(self.boto_session, self.instance_id)
         return len(
             list(
                 filter(
                     lambda cbas: cbas['CidrBlockState']['State'] ==
                     'associated', vpc['CidrBlockAssociationSet'])))
     except KeyError:
         raise InstanceWithIdentifierNotFound(self)
Пример #10
0
 def current(self) -> int:
     if check_if_vpc_exists(self.boto_session, self.instance_id):
         return len(
             self.boto_session.client('ec2').describe_network_acls(
                 Filters=[{
                     'Name': 'vpc-id',
                     'Values': [self.instance_id]
                 }])['NetworkAcls'])
     else:
         raise InstanceWithIdentifierNotFound(self)
Пример #11
0
 def current(self):
     if check_if_vpc_exists(self.boto_session, self.instance_id):
         return len(
             self.boto_session.client('ec2').describe_route_tables(
                 Filters=[{
                     'Name': 'vpc-id',
                     'Values': [self.instance_id]
                 }])['RouteTables'])
     else:
         raise InstanceWithIdentifierNotFound(self)
Пример #12
0
 def current(self):
     try:
         rt = get_rt_by_id(self.boto_session, self.instance_id)
         return len(rt['Routes'])
     except KeyError:
         raise InstanceWithIdentifierNotFound(self)
Пример #13
0
 def current(self):
     try:
         sg = get_sg_by_id(self.boto_session, self.instance_id)
         return len(sg['IpPermissions']) + len(sg['IpPermissionsEgress'])
     except KeyError:
         raise InstanceWithIdentifierNotFound(self)