dcloud iam policies simulate

Test whether a user, role or draft policy allows an action, and why

IAM iam:SimulatePrincipalPolicyRead

Give `principal` ({type: user|role, id}), `policyDocuments` (JSON strings, not saved), or both — drafts are then evaluated as if attached. A principal needs iam:SimulatePrincipalPolicy on it, drafts need iam:SimulateCustomPolicy. The answer names the deciding statement, its policy and how that policy reaches the principal (directly, group, role). `context` sets condition keys (sourceIp, multiFactorAuthPresent, currentTime, requestedRegion, availabilityZone, requestProject, resourceProject); a key left out is unknown, as it would be for a request that does not carry it. Bucket policies of S3 are not included.

Synopsis

dcloud iam policies simulate --action action --resource resource [flags]

Flags

  • --principalOptional

    object

    The user or role to test, as {type: user|role, id}; omitted: only policyDocuments are evaluated

    Constraints: JSON

  • --policy-documentsOptional

    array of string

    Policy documents (JSON text) that are not saved: with a principal, evaluated as if attached to it; without one, on their own

    Constraints: 2-65536 chars

  • --actionRequired

    string

    The one action to test, e.g. ec2:StartInstances (not a pattern)

    Constraints: 3-128 chars, /^[a-z0-9-]+:[A-Za-z0-9]+$/

  • --resourceRequired

    string

    The resource name (RN) the request would act on, or *

    Constraints: 1-1024 chars, /^(\*|rn:(?:dcloud|ews):[^\s]*)$/

  • --contextOptional

    object

    Condition keys of the imagined request: sourceIp, multiFactorAuthPresent, currentTime (default now), requestedRegion (default your region), availabilityZone; a key left out is unknown

    Constraints: JSON

Example

dcloud iam policies simulate --action example --resource example

Generated from the API description, the same one the API checks requests against and the CLI is built from.