# p0 grant

### **Overview** <a href="#overview" id="overview"></a>

The p0 grant command lets you **request on behalf of another principal** for a principal (user, service account, or group) to a specific resource in your organization's platforms—AWS, Azure AD, GCP, Kubernetes, Okta, PostgreSQL, Snowflake, SSH, and Google Workspace.

Unlike p0 allow (which sets up standing access), p0 grant issues **ephemeral** access requests that:

1. **Trigger** the provisioning workflow in the target system
2. **Optionally wait** until the request is approved or denied
3. **Report** the outcome and exit with a status code

Use p0 grant when another user needs just-in-time access for troubleshooting, one-off tasks, short-lived sessions, or for NHI identities

***

### **Prerequisites** <a href="#prerequisites" id="prerequisites"></a>

* **Logged-in user**
* If you're not logged in or your token expired, p0 grant will prompt you to authenticate.
* **Tenant configuration**

  Confirm \~/.p0/config.json has the correct appUrl for your P0 tenant.
* **Network access**

  Ensure HTTPS egress to https\://\<your-tenant>/o/\<org-slug>/command/.

***

### **Syntax** <a href="#syntax" id="syntax"></a>

```plaintext
p0 grant <provider> <subcommand> [resource args…]
    --to <principal>
    --duration <duration>
    [--reason <text>]
    [-w|--wait]
    [--help]
```

* \<provider>

  One of:

```plaintext
aws, azure-ad, gcloud, k8s, okta, pg, snowflake, ssh, workspace
```

* \<subcommand> & resource args

  Vary by provider (see "Examples" or run p0 grant \<provider> --help)
* `--to <principal>`

  **Required.** Email or service-account identifier to receive access
* `--duration <duration>`

  The requested duration of access (e.g. `4 hours`, `1 day`)
* `--reason <text>`

  *(Optional)* Justification for audit logs
* `-w, --wait`

  *(Optional)* Block until the request is approved/denied (up to 5 minutes)
* `--help`

  Show provider-specific subcommands and options

**Duration formats:**

Human-friendly strings such as 10 minutes, 2 hours, 5 days, 1 week.

***

### **Supported Providers** <a href="#supported-providers" id="supported-providers"></a>

```plaintext
p0 grant aws        Amazon Web Services
p0 grant azure-ad   Entra ID
p0 grant gcloud     Google Cloud
p0 grant k8s        Kubernetes
p0 grant okta       Okta
p0 grant pg         PostgreSQL
p0 grant snowflake  Snowflake
p0 grant ssh        Secure Shell (SSH)
p0 grant workspace  Google Workspace
```

For detailed resource arguments per provider, append --help:

```plaintext
p0 grant aws --help
p0 grant gcloud --help
# …etc.
```

***

### **Examples** <a href="#examples" id="examples"></a>

#### **AWS: Ephemeral IAM Policy on a Resource** <a href="#aws-ephemeral-iam-policy-on-a-resource" id="aws-ephemeral-iam-policy-on-a-resource"></a>

```plaintext
p0 grant aws resource arn:aws:s3:::my-bucket/* ReadOnlyAccess \
  --account 123456789012 \
  --to alice@example.com \
  --duration '1 days'
```

* **Subcommand:** resource \<ARN> \<policy…>
* **Account:** AWS account ID
* **Outcome:** Alice can assume ReadOnlyAccess on my-bucket/\* for up to 1 day.

***

#### **GCP: One-Time IAM Role** <a href="#gcp-one-time-iam-role" id="gcp-one-time-iam-role"></a>

```plaintext
p0 grant gcloud role roles/viewer \
  --project my-gcp-project \
  --to bob@example.com \
  --duration '12 hours'
```

* **Subcommand:** role \<role-name>
* **Project:** GCP project ID
* **Outcome:** Bob gains the viewer role on my-gcp-project for 12 hours.

***

#### **SSH: Temporary Group Membership** <a href="#ssh-temporary-group-membership" id="ssh-temporary-group-membership"></a>

```plaintext
p0 grant ssh group --name devs \
  --to charlie@example.com \
  --duration '4 hours'
```

* **Subcommand:** group --name \<group-name>
* **Outcome:** Charlie is added to the SSH access group devs for 4 hours.
