Prisma Cloud: API Exception Error for running IAM config query
2989
Created On 04/24/24 18:53 PM - Last Modified 04/24/24 19:04 PM
Symptom
Receiving error message when trying to use API to post a search IAM config query (RQL).
Environment
- Prisma Cloud IAM policy
- API endpoint
Cause
- Prisma Cloud uses different API endpoints for the Cloud-Resource query and for the IAM config query.
Resolution
- For the cloud.resource query the API endpoint will be,
{{api-endpoint}}/search/config
- But for the IAM config query, the API endpoint will be,
{{api-endpoint}}/iam/api/v4/search/permission
Additional Information
- The following link does not cover details for the IAM config RQL query.
"Perform Config Search"
https://pan.dev/prisma-cloud/api/cspm/search-config/
Examples of API calls using Postman:
- Cloud.resource RQL
POST: https://{{api-endpoint}}/search/config
Body:
{
"heuristicSearch": true,
"query": "config from cloud.resource where cloud.type = 'aws' AND api.name = 'aws-s3api-get-bucket-acl' AND json.rule = "acl.grantsAsList[?(@.grantee=='AllUsers')].permission contains ReadAcp or acl.grantsAsList[?(@.grantee=='AllUsers')].permission contains FullControl",
"timeRange": {
"type": "to_now",
"value": "epoch"
},
"limit": 100,
"withResourceJson": false
}
- IAM config RQL
POST: https://{{api-endpoint}}/iam/api/v4/search/permission
Body:
{
"query": "config from iam where dest.cloud.type = 'AWS' and source.public = true AND dest.cloud.service.name = 's3' AND dest.cloud.resource.type = 'bucket' AND grantedby.cloud.policy.condition ( 'aws:SourceArn' ) does not exist AND grantedby.cloud.policy.condition ( 'aws:VpcSourceIp' ) does not exist AND grantedby.cloud.policy.condition ( 'aws:username' ) does not exist AND grantedby.cloud.policy.condition ( 'aws:userid' ) does not exist AND grantedby.cloud.policy.condition ( 'aws:ResourceAccount' ) does not exist"
}