Account and team / Writing policies
Writing access policies
Statements, actions with wildcards, resources by id or by name, the source_ip and mfa conditions, Pantech's managed policies, and key policies on API keys.
A policy has a name, an optional description, and 1 to 20 statements. You write it in the console's statement editor or its JSON view, with the API, the CLI or Terraform. In the examples, <office-cidr> stands for your office's public address range.
{
"name": "staging-operators",
"description": "Restart and resize staging machines",
"statements": [
{
"sid": "RestartStaging",
"effect": "allow",
"actions": ["instances:Read", "instances:Start", "instances:Stop", "instances:Reboot", "instances:Resize"],
"resources": ["name:staging-*"],
"conditions": { "source_ip": ["<office-cidr>"], "mfa": false }
}
]
}A policy does nothing until it is attached to a member or a team.
Statements
| Field | |
|---|---|
sid | Optional. A label for the statement, 1 to 64 letters, digits, _ or -, unique in the policy. The simulator names it |
effect | allow or deny. A matching deny always wins over an allow |
actions | 1 to 50 actions |
resources | 1 to 50 resources |
conditions | Optional. Every condition given must hold for the statement to match. See conditions |
A statement matches a request when the action is in actions, the resource is in resources, and every condition holds.
Actions
An action is <service>:<verb>, such as instances:Stop. The action catalogue lists every one, and GET /iam/actions returns the same list with a description of each.
* matches any run of characters in the action, so it can stand for a whole service, a verb in every service, or everything:
| Pattern | Matches |
|---|---|
instances:Stop | Stopping a virtual machine |
instances:* | Everything on virtual machines |
*:Read | Reading anything |
*:Delete | Every action whose verb is exactly Delete |
*:Delete* | Delete and every verb that starts with it, such as dns:DeleteZone and registry:DeleteImage |
* | Every action |
The pattern must match the whole action, so *:Delete does not cover dns:DeleteZone. Actions are matched exactly as written, capitals included.
An action that is not in the catalogue, or a wildcard that matches no action, is refused with INVALID_POLICY, so a typo cannot quietly match nothing.
Resources
A resource is one of:
*: every resource.- A resource's id, such as
vm_06gk3x9tq7m2v8r4y1c5d0zp8w,dnsz_…orcrr_…. An id that names nothing is accepted and simply matches nothing. name:<glob>: every resource whose name matches, 1 to 253 characters aftername:.*matches any run of characters and?one character. Matching ignores case, soname:staging-*matchesStaging-API.
"resources": ["vm_06gk3x9tq7m2v8r4y1c5d0zp8w", "name:staging-*", "name:qa-??"]An id stays with one resource even if it is renamed. A name glob follows names, so it also covers resources created later with a matching name.
Creating things
Some actions have no resource yet: creating a machine, billing:BuyCredit. They match only *, or a name: glob tested against the name being created. So this lets someone create machines, but only with names that start with staging-:
{ "effect": "allow", "actions": ["instances:Create"], "resources": ["name:staging-*"] }Conditions
| Condition | The statement matches only when |
|---|---|
source_ip | The request comes from an address in one of 1 to 20 IPv4 or IPv6 CIDRs, such as your office's IPv4 range (<office-cidr>) or an IPv6 range (<office-ipv6-cidr>). A single address is taken as its /32 or /128 |
mfa | true: the person signed in with two-factor. false: they did not |
The address is the one Pantech sees the request come from, the same one rate limits use. If it cannot be told, an allow with source_ip does not apply and a deny with source_ip does: a doubt never grants access and never lifts a deny.
API keys never count as signed in with two-factor. A statement with "mfa": true never applies to a key, and one with "mfa": false always does. So a deny with "mfa": false stops keys too; see require MFA for changes.
Conditions narrow a statement; they cannot widen one. There is no "not": to keep members to one network, allow from that network rather than denying the rest. See office network only.
Managed policies
Pantech keeps a set of policies you can attach as they are. They cannot be changed or deleted, and their statements are listed with GET /iam/policies?managed=true.
| Policy | For |
|---|---|
pol_pantech_read_only | Every Read action (*:Read). Give it to members before setting the baseline to none |
pol_pantech_developer | Reading everything, and creating, changing, starting, stopping and resizing machines, volumes, snapshots, databases, Kubernetes clusters, functions and buckets without deleting them; pushing and pulling images; changing DNS records |
pol_pantech_network_admin | Reading everything, and managing VPC networks, subnets, security groups, firewall rules, public IPs, port forwarding and load balancers |
pol_pantech_database_admin | Reading everything, and managing managed databases |
pol_pantech_dns_manager | Reading everything, and managing DNS zones and records |
pol_pantech_domain_manager | Reading everything, and registering, renewing, transferring in and managing domains, contacts included. Not transferring a domain out |
pol_pantech_compute_admin | Reading everything, and managing virtual machines, volumes, snapshots and SSH keys, deletes included |
pol_pantech_kubernetes_admin | Reading everything, and managing Kubernetes clusters, node pools and workloads |
pol_pantech_object_storage_admin | Reading everything, and managing buckets, objects, access keys and the organization's Block All Public Access setting |
pol_pantech_functions_admin | Reading everything, and managing serverless functions: creating, deploying and rolling back, changing settings, keys, logs, test calls, schedules, and deleting |
pol_pantech_email_manager | Reading everything, and managing sending domains, SMTP keys and suppressions, sending email and buying email packs |
pol_pantech_certificate_manager | Reading everything, and requesting, importing, exporting, revoking and deleting TLS certificates |
pol_pantech_migrate_manager | Reading everything, and moving workloads with Pantech Migrate: connecting clouds, scanning, planning, copying servers, moving Kubernetes and importing databases and buckets. What a move creates on Pantech needs its own permission too, such as pol_pantech_developer |
pol_pantech_registry_push | Pushing and pulling container images |
pol_pantech_registry_pull | Pulling container images |
pol_pantech_billing_manager | Billing and invoices, buying credit, and payment methods |
pol_pantech_support | Viewing and opening support tickets |
pol_pantech_deny_delete | A deny on every delete, and everything else that erases data or lets a domain leave (rebuild, restore, export a certificate, get a domain's auth code…), for anyone it is attached to, admins included |
pol_pantech_require_mfa_for_writes | A deny on every action that is not a read, when the session did not use two-factor. API keys never use two-factor, so with it a key can only read |
Key policies
An API key can carry its own key policy: a list of allow statements, set when the key is created. In the console, open Organization › API keys, press Create API key and turn on Restrict this key.
A key policy only narrows. The key may do what its creator may, within its scope, and what its key policy allows. Deny statements are not accepted in a key policy, because there is nothing for one to take away that leaving it out does not. A key with a key policy cannot change teams, policies, attachments or the baseline at all.
{
"key_policy": {
"statements": [
{ "effect": "allow", "actions": ["registry:Pull", "registry:Push"], "resources": ["crr_06gk3x9tq7m2v8r4y1c5d0zp8w"] },
{ "effect": "allow", "actions": ["dns:Read", "dns:ChangeRecords"], "resources": ["dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w"] }
]
}
}The console's list of API keys shows which keys are restricted, and GET /me called with a key returns its key_policy (null when it has none). A source_ip condition in a key policy is a good way to keep a CI key to your runners' addresses.
Validation
A policy is checked when it is saved. Mistakes are 422 INVALID_POLICY, with an errors entry naming each field, such as statements[0].actions[2], statements[1].resources[0] or statements[0].conditions.source_ip[3].
Changing a policy replaces it whole. Send If-Match with the version you read, and a change made by someone else in the meantime is refused with 412 VERSION_CONFLICT instead of being overwritten.