Documentation

esc
    Reference / Teams and policies

    Teams and access policies with Terraform

    The pantechdynamics_team, pantechdynamics_team_membership, pantechdynamics_access_policy, pantechdynamics_access_policy_attachment and pantechdynamics_access_settings resources and their data sources, with examples.

    Keep your teams and access policies in code with the Terraform provider. The provider's key must belong to an owner or admin. Changes that act on an admin need an owner's key.

    ResourceWhat it is
    pantechdynamics_teamA team
    pantechdynamics_team_membershipOne member in one team
    pantechdynamics_access_policyA policy and its statements
    pantechdynamics_access_policy_attachmentA policy attached to a member or a team
    pantechdynamics_access_settingsThe organization's member baseline, once per organization
    Data sourceWhat it reads
    pantechdynamics_access_policyA policy, yours or a managed pol_pantech_… one, by id or name
    pantechdynamics_iam_actionsEvery action a policy can name, optionally for one service
    pantechdynamics_access_policy_documentA policy's JSON built from statement blocks, without calling the API

    pantechdynamics_team

    HCL
    resource "pantechdynamics_team" "staging" {
      name        = "Staging operators"
      description = "Developers who run staging"
    }
    Argument
    nameRequired. 1 to 64 characters, unique in the organization
    descriptionOptional. Up to 255 characters
    Attribute
    idteam_…
    member_countMembers in the team

    pantechdynamics_team_membership

    HCL
    resource "pantechdynamics_team_membership" "ada" {
      team_id = pantechdynamics_team.staging.id
      user_id = "usr_06gk3x9tq7m2v8r4y1c5d0zp8w"
    }
    Argument
    team_idRequired. Changing it replaces the membership
    user_idRequired. A member of the organization. Changing it replaces the membership

    Destroying it removes the member from the team; the member stays in the organization.

    pantechdynamics_access_policy

    HCL
    resource "pantechdynamics_access_policy" "staging_operators" {
      name        = "staging-operators"
      description = "Restart and resize staging machines"
    
      statement {
        sid       = "OperateStaging"
        effect    = "allow"
        actions   = ["instances:Read", "instances:Start", "instances:Stop", "instances:Reboot", "instances:Resize"]
        resources = ["name:staging-*"]
    
        conditions = {
          source_ip = ["<office-cidr>"]
        }
      }
    }
    Argument
    nameRequired. Unique in the organization: 1 to 64 letters, digits, spaces, ., _ or -, starting with a letter or digit. Names starting pantech_ are reserved
    descriptionOptional. Up to 255 characters
    statement1 to 20 blocks. Each has effect (allow or deny), actions and resources (1 to 50 each), and optionally sid and conditions = { source_ip = [...], mfa = ... } (up to 20 CIDRs)
    policy_jsonInstead of statement blocks: the statements as JSON, {"statements": [...]}. Set one or the other. With blocks, it shows them in normal form
    Attribute
    idpol_…
    versionBumped on every change. The provider sends it as If-Match, so a change made in the console since your last plan is refused instead of overwritten

    Actions, resources, CIDRs and the limits are checked at plan time, actions also against the published catalogue. Statements are compared by meaning, so reordering actions or writing a bare address for the same address with /32 shows no change. Writing policies explains actions, resources and conditions. Managed policies (pol_pantech_…) are not resources: attach them by id.

    pantechdynamics_access_policy_attachment

    HCL
    resource "pantechdynamics_access_policy_attachment" "staging" {
      policy_id      = pantechdynamics_access_policy.staging_operators.id
      principal_type = "team"
      principal_id   = pantechdynamics_team.staging.id
    }
    
    resource "pantechdynamics_access_policy_attachment" "no_prod_deletes" {
      policy_id      = "pol_pantech_deny_delete"
      principal_type = "team"
      principal_id   = pantechdynamics_team.staging.id
    }
    Argument
    policy_idRequired. One of yours, or a managed pol_pantech_…
    principal_typeRequired. member or team
    principal_idRequired. A usr_… id for a member, or a team_… id

    Changing any argument replaces the attachment, and destroying it detaches the policy. A member and a team can each have 10 policies. Only an owner may attach a policy to an admin, or to a team that holds one.

    pantechdynamics_access_settings

    HCL
    resource "pantechdynamics_access_settings" "this" {
      member_baseline = "none"
    }
    Argument
    member_baselineRequired. What members (not owners or admins) may do without a policy: read (view everything, the default for an organization) or none (only what their policies allow)

    Declare it once per organization; it needs an owner's key. Destroying it leaves the setting as it is.

    Import

    Terminal
    $ terraform import pantechdynamics_team.staging team_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_team_membership.ada team_06gk3x9tq7m2v8r4y1c5d0zp8w/usr_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_access_policy.staging_operators pol_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_access_policy_attachment.staging pol_06gk3x9tq7m2v8r4y1c5d0zp8w/team/team_06gk3x9tq7m2v8r4y1c5d0zp8w$ terraform import pantechdynamics_access_settings.this access_settings

    Was this page helpful?

    Updated