scalr_policy_group

Resource: scalr_policy_group

Manage the state of policy groups in Scalr. Create, update and destroy.

Example Usage

resource "scalr_policy_group" "example" {
  name            = "instance_types"
  opa_version     = "0.29.4"
  account_id      = "acc-xxxxxxxxxx"
  vcs_provider_id = "vcs-xxxxxxxxxx"
  vcs_repo {
    identifier = "org/repo"
    path       = "policies/instance"
    branch     = "dev"
  }
}

# Pinned to a Git tag: pushes to the repository do not change the policies
# until the tag is replaced with another one.
resource "scalr_policy_group" "pinned" {
  name            = "instance_types_pinned"
  account_id      = "acc-xxxxxxxxxx"
  vcs_provider_id = "vcs-xxxxxxxxxx"
  vcs_repo {
    identifier = "org/repo"
    path       = "policies/instance"
    tag        = "v1.4.0"
  }
}

Schema

Required

  • name (String) The name of a policy group.
  • vcs_provider_id (String) The identifier of a VCS provider, in the format vcs-<RANDOM STRING>.

Optional

  • account_id (String) The identifier of the Scalr account, in the format acc-<RANDOM STRING>.
  • common_functions_folder (String) An absolute path from the repository root to the folder that contains common rego functions.
  • environments (Set of String) A list of the environments the policy group is linked to. Use ["*"] to enforce in all environments. To manage a linkage use either this attribute or the scalr_policy_group_linkage resource.
  • evaluate_on (String) The stage of the run the policy group is evaluated at. Valid values are pre-plan and post-plan. If omitted on creation, defaults to post-plan. Changing this forces a resource to be re-created.
  • opa_version (String) The version of Open Policy Agent to run policies against. If omitted, the system default version is assigned.
  • vcs_repo (Block List) (Required) The VCS meta-data to create the policy from. (see below for nested schema)

Read-Only

  • error_message (String) A detailed error if Scalr failed to process the policy group.
  • id (String) The ID of this resource.
  • policies (List of Object) A list of the OPA policies the group verifies each run. (see below for nested schema)
  • status (String) A system status of the Policy group.

Nested Schema for vcs_repo

Required:

  • identifier (String) The reference to the VCS repository in the format :org/:repo, this refers to the organization and repository in your VCS provider.

Optional:

  • branch (String) The branch of a repository the policy group is associated with. Every push to this branch updates the policies. If omitted, the repository default branch will be used. Empty while the policy group is pinned to a tag. Conflicts with tag.
  • path (String) The subdirectory of the VCS repository where OPA policies are stored. If omitted or submitted as an empty string, this defaults to the repository's root.
  • tag (String) The Git tag the policy group is pinned to. While pinned, the policy group tracks no branch: the policies stay at this tag and pushes to the repository do not change them. Set another tag to promote the policy group, or remove the attribute to go back to tracking a branch. Conflicts with branch.

Nested Schema for policies

Read-Only:

  • enabled (Boolean)
  • enforced_level (String)
  • name (String)

Import

Import is supported using the following syntax:

terraform import scalr_policy_group.example pgrp-xxxxxxxxxx

Did this page help you?