Is there any google API to check and count number of Armor Policies rules defined under a project. i have to count number of custom rules so that once it crosses the quota limit that is 20 then it should throw an error.

I Have to write a ansible script for the same to throw error msg if it crosses maximum quota for advanced custom rules

just like this is the one,

  • name: Call google API to check number of Armor Policies defined under this project

uri:

url: "https://www.googleapis.com/compute/v1/projects/{{ client_project }}/global/securityPolicies"

method: GET

validate_certs: yes

status_code:

  • 200

return_content: yes

headers:

Authorization: Bearer {{ oauthcmd.stdout }}

Content-Type: "application/json"

register: list_policy_out

tags: network

  • name: Check for the Armor Policies count

assert:

that:

  • "{{ list_policy_out.json['items'] | length < 11 }}"

fail_msg: "armor policies limit reached"

In the same-way , is there any Google API to check the number of rules defined under this project

and its url , please

google API to check and count number of Armor Policies rules defined under a project.

1

There are 1 answers

1
Dave On

You can issue a gCloud command, gcloud compute project-info describe --project PROJECT_NAME and pull the number from the metric: SECURITY_POLICY_CEVAL_RULES stanza. It will list the current project quota and the number of rules in use.

There is a beta feature you could try to pull the quota for the specific resource.