Example #1
0
def create_rule_lookup(client, module):
    try:
        rules = list_rules_with_backoff(client)
        return dict((rule['Name'], rule) for rule in rules)
    except (botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg='Could not list rules')
Example #2
0
def list_rules(client, module):
    if client.__class__.__name__ == 'WAF':
        try:
            return list_rules_with_backoff(client)
        except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
            module.fail_json_aws(e, msg='Could not list WAF rules')
    elif client.__class__.__name__ == 'WAFRegional':
        try:
            return list_regional_rules_with_backoff(client)
        except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
            module.fail_json_aws(e, msg='Could not list WAF Regional rules')
Example #3
0
def create_rule_lookup(client, module):
    if client.__class__.__name__ == 'WAF':
        try:
            rules = list_rules_with_backoff(client)
            return dict((rule['Name'], rule) for rule in rules)
        except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
            module.fail_json_aws(e, msg='Could not list rules')
    elif client.__class__.__name__ == 'WAFRegional':
        try:
            rules = list_regional_rules_with_backoff(client)
            return dict((rule['Name'], rule) for rule in rules)
        except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
            module.fail_json_aws(e, msg='Could not list regional rules')
 def find_condition_in_rules(self, condition_set_id):
     rules_in_use = []
     try:
         all_rules = list_rules_with_backoff(self.client)
     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
         self.module.fail_json_aws(e, msg='Could not list rules')
     for rule in all_rules:
         try:
             rule_details = get_rule_with_backoff(self.client, rule['RuleId'])
         except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
             self.module.fail_json_aws(e, msg='Could not get rule details')
         if condition_set_id in [predicate['DataId'] for predicate in rule_details['Predicates']]:
             rules_in_use.append(rule_details['Name'])
     return rules_in_use
 def find_condition_in_rules(self, condition_set_id):
     rules_in_use = []
     try:
         if self.client.__class__.__name__ == 'WAF':
             all_rules = list_rules_with_backoff(self.client)
         elif self.client.__class__.__name__ == 'WAFRegional':
             all_rules = list_regional_rules_with_backoff(self.client)
     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
         self.module.fail_json_aws(e, msg='Could not list rules')
     for rule in all_rules:
         try:
             rule_details = get_rule_with_backoff(self.client, rule['RuleId'])
         except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
             self.module.fail_json_aws(e, msg='Could not get rule details')
         if condition_set_id in [predicate['DataId'] for predicate in rule_details['Predicates']]:
             rules_in_use.append(rule_details['Name'])
     return rules_in_use
Example #6
0
def list_rules(client, module):
    try:
        return list_rules_with_backoff(client)
    except (botocore.exceptions.ClientError,
            botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg='Could not list WAF rules')
Example #7
0
def create_rule_lookup(client, module):
    try:
        rules = list_rules_with_backoff(client)
        return dict((rule['Name'], rule) for rule in rules)
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg='Could not list rules')
Example #8
0
def list_rules(client, module):
    try:
        return list_rules_with_backoff(client)
    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
        module.fail_json_aws(e, msg='Could not list WAF rules')