Documentation

esc
    Account and team / Recipes

    Access policy recipes

    Complete policies for a read-only contractor, finance staff, staging operators, a CI key for one repository and one DNS zone, MFA for changes, office-network only and no deletes in production.

    Each recipe is a policy you can paste into the console's JSON view, POST /iam/policies, pantech iam policies create --file or Terraform. Replace the ids and names with yours, then check it in the simulator before you attach it widely.

    Read-only contractor

    A contractor should see one project's machines and nothing else.

    Members read everything while the baseline is read, so this needs the baseline at none. That affects every member, so first give everyone else their reads back:

    1. Create a team Staff, add your members, and attach pol_pantech_read_only to it.
    2. Set the member baseline to none (owners only).
    3. Invite the contractor as a member (Viewer), and attach this policy to them:
    JSON
    {
      "name": "contractor-project-x",
      "description": "Read the project X machines only",
      "statements": [
        {
          "sid": "ReadProjectX",
          "effect": "allow",
          "actions": ["instances:Read", "volumes:Read", "snapshots:Read", "networks:Read"],
          "resources": ["name:projx-*"]
        }
      ]
    }

    To list exact machines instead, use their ids in resources.

    Finance only

    Finance staff should see invoices and add credit, and never touch infrastructure. Members cannot change infrastructure anyway, so a member with this policy can pay but not build. Attach pol_pantech_billing_manager, or this narrower one:

    JSON
    {
      "name": "finance",
      "statements": [
        {
          "sid": "Billing",
          "effect": "allow",
          "actions": ["billing:Read", "billing:ReadInvoices", "billing:BuyCredit"],
          "resources": ["*"]
        }
      ]
    }

    Add billing:ManagePaymentMethods if they also look after the cards. With the baseline at none, they see only billing.

    The console's Billing pages open for Owners and Admins only, so a member with this policy works through the API, not the console. If they need the console, make them an Admin and attach a policy that denies the actions you don't want them to have: a matching deny applies to Admins too.

    Staging operators

    Developers may restart and resize staging machines, but not delete them or touch production. Attach it to a team of developers who are members:

    JSON
    {
      "name": "staging-operators",
      "description": "Restart and resize staging machines",
      "statements": [
        {
          "sid": "OperateStaging",
          "effect": "allow",
          "actions": ["instances:Read", "instances:Start", "instances:Stop", "instances:Reboot", "instances:Resize"],
          "resources": ["name:staging-*"]
        }
      ]
    }

    A CI key for one repository and one DNS zone

    A deploy pipeline pushes one image and updates one DNS record. Create an API key with write scope and this key policy, so the key can do nothing else even though its creator can:

    JSON
    {
      "statements": [
        {
          "sid": "PushApiImage",
          "effect": "allow",
          "actions": ["registry:Read", "registry:Pull", "registry:Push"],
          "resources": ["crr_06gk3x9tq7m2v8r4y1c5d0zp8w"]
        },
        {
          "sid": "UpdateDeployRecords",
          "effect": "allow",
          "actions": ["dns:Read", "dns:ChangeRecords"],
          "resources": ["dnsz_06gk3x9tq7m2v8r4y1c5d0zp8w"]
        }
      ]
    }

    Add "conditions": {"source_ip": ["<runner-cidr>"]} to each statement, with your CI runners' public range in place of <runner-cidr>, to keep the key to your runners' addresses. For pushing images only, a registry token is simpler.

    Require MFA for changes

    Attach pol_pantech_require_mfa_for_writes to everyone, or to a team. Changes made without two-factor are then refused, for admins too.

    To choose the actions yourself, deny them when the session did not use two-factor:

    JSON
    {
      "name": "mfa-for-changes",
      "statements": [
        {
          "sid": "NoChangesWithoutMFA",
          "effect": "deny",
          "actions": ["*:Create*", "*:Update*", "*:Delete*", "instances:Start", "instances:Stop", "instances:Reboot", "instances:Resize", "instances:Rebuild", "instances:Restore",
                      "dns:ChangeRecords", "dns:Import"],
          "resources": ["*"],
          "conditions": { "mfa": false }
        }
      ]
    }

    A pattern must match the whole action, so *:Create alone would not cover dns:CreateZone; *:Create* does. Add any others from the action catalogue you want covered.

    Office network only

    Members should work only from the office. Put your office's public range in place of <office-cidr> (your network admin or internet provider can give it to you; for one address, write it with /32).

    Conditions cannot say "not from", so allow from the office instead of denying the rest. Set the baseline to none, then give members this in place of their usual policies:

    JSON
    {
      "name": "office-only",
      "statements": [
        {
          "sid": "ReadFromOffice",
          "effect": "allow",
          "actions": ["*:Read"],
          "resources": ["*"],
          "conditions": { "source_ip": ["<office-cidr>"] }
        },
        {
          "sid": "OperateFromOffice",
          "effect": "allow",
          "actions": ["instances:Start", "instances:Stop", "instances:Reboot"],
          "resources": ["*"],
          "conditions": { "source_ip": ["<office-cidr>"] }
        }
      ]
    }

    This works for members. Admins are allowed unless something denies them, so an allow with a condition does not hold them to the office. For API keys, put the same source_ip condition in the key's key policy.

    No deletes in production

    Nobody but an owner should delete production resources. A deny applies to admins too. Attach this to every admin and member, or to a team they are all in:

    JSON
    {
      "name": "no-production-deletes",
      "statements": [
        {
          "sid": "NoProdDeletes",
          "effect": "deny",
          "actions": ["*:Delete*", "instances:Rebuild", "instances:Restore"],
          "resources": ["name:prod-*"]
        }
      ]
    }

    To stop deletes everywhere, attach pol_pantech_deny_delete instead. Owners can still delete, and only owners can attach a policy to an admin.

    Was this page helpful?

    Updated