Create IAM Policies in bundle using python

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Create IAM Policies in bundle using python

L0 Member

Hello,

 

I'm trying to create a bunch of IAM policies using Prisma's API,

 

I can create config policies with no issues however when I try to create IAM policies, following Palo Alto's API documentation, I always get 400 error,

 

So probably my payload is bad done, but I find no errors in this code:

def makePolicy(session😞
    url="https://{}.prismacloud.io/policy".format(region)
   
    payload={
        "cloudType": "azure",
        "name": "iam test policy for azure using API",
        "policyType": "IAM",
        "rule": {
            "criteria": "XXXXXXXX-XXXXXX-XXXXXXX",
            "name": "use this rql for testing",
            "parameters": {
                "savedSearch": "true"
            },
            "type": "IAM"
        },
        "severity": "low"
    }
   
    payload=json.dumps(payload)
    headers={
        'Content-Type': 'application/json; charset=UTF-8',
        "Accept": "application/json; charset=UTF-8",
        "x-redlock-auth": session
    }

    response=requests.request('POST',url,headers=headers,data=payload)
    print(response)
    print(response.content)
    return response
 
makePolicy(session())

 

Take in mind I changed the criteria value,

 

I tried with different rql ids, and changing the payload multiple times, but I can't stop receiving 400 error, thing that doesn't happen with config policies,

 

I appreciate any help,

1 REPLY 1

L3 Networker

Hello,

Based on the code snipped you provided you have the basic requirements to this to work using the API.  Please open a support case to have this looked at by out support team.

https://pan.dev/prisma-cloud/api/cspm/add-policy/
{
"cloudType": "aws",
"name": "Config test policy",
"policyType": "config",
"rule": {
"criteria": "e1234567-2798-4d1d-a1b0-52d60d49730b",
"name": "test rule",
"parameters": {
"savedSearch": "true"
},
"type": "Config"
},
"severity": "low"
}

  • 912 Views
  • 1 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!