Policy Groups
List Policy Groups
/api/orgs/{orgName}/policygroupsReturns a list of all Policy Groups for the organization. Policy Groups define which Policy Packs are enforced on which stacks, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. Every organization has a default Policy Group, and additional groups can be created to apply different policy sets to different environments (e.g., stricter enforcement in production).
Request Parameters
orgNamestring path requiredThe organization name
Responses
- List of policy groups
- ↳
namestring requiredThe unique name of the policy group. - ↳
isOrgDefaultboolean requiredWhether this is one of the organization’s default policy groups. The default stacks group applies to every stack not in another group; the default accounts group applies to every Insights account not in another group. - ↳
numStacksinteger requiredNumber of stacks assigned to this policy group. - ↳
numAccountsinteger optionalNumber of cloud accounts assigned to this policy group. - ↳
entityTypeenum requiredDeprecated: a legacy label set when the policy group was created. It does not restrict which entities the group holds;modedoes.Values:stacks,accounts - ↳
modeenum requiredThe enforcement mode of the policy group.Values:audit,preventative - ↳
numEnabledPolicyPacksinteger requiredNumber of policy packs currently enabled in this group.
New Policy Group
/api/orgs/{orgName}/policygroupsCreates a new Policy Group for an organization. Policy Groups define which Policy Packs are enforced on which stacks or cloud accounts, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. This allows different policy strictness for different environments, such as advisory-only in development and mandatory in production.
Request Parameters
orgNamestring path requiredThe organization name
Request Body
namestring requiredThe name of the new policy group. Up to 100 characters, made up of letters, numbers, hyphens, underscores, periods, or spaces, and may not begin or end with a space.entityTypeenum optionalDeprecated: a legacy label,stacksoraccounts. Whenmodeis omitted it picks the mode (accounts→ audit,stacks→ preventative). When this is omitted, it is derived frommode. It does not restrict which entities the group can hold.Values:stacks,accountsmodeenum optionalThe enforcement mode for the policy group (audit or preventative). The mode decides what the group can hold: an audit group holds stacks and Insights accounts, a preventative group holds stacks only. Required unless the deprecatedentityTypeis sent. Fixed at creation; it cannot be changed later.Values:audit,preventativeagentPoolIdstring optionalAgent pool ID for policy evaluation. Defaults to Pulumi hosted pool if not specified.- Preview: a stack match rule to create the group with, a boolean expression over stack tags. Requires the tag-based policy groups feature.
- Preview: an account match rule to create the group with, a boolean expression over Insights account tags. Requires the tag-based policy groups feature; not allowed on preventative groups.
Responses
Get Policy Group
/api/orgs/{orgName}/policygroups/{policyGroup}Returns the details of a specific Policy Group, including the list of Policy Packs applied to it and their enforcement levels (advisory, mandatory, or disabled), as well as the stacks and cloud accounts added to the group. Policy Groups enable targeted policy enforcement by associating sets of policies with specific infrastructure resources.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group name
Responses
namestring requiredThe name of the policy group.isOrgDefaultboolean requiredTrue if this is either the default stacks or default accounts policy group for the organization.entityTypeenum requiredDeprecated: a legacy label set when the policy group was created. It does not restrict which entities the group holds;modedoes.Values:stacks,accountsmodeenum requiredThe enforcement mode for the policy group (audit or preventative).Values:audit,preventative- The stacks added to this policy group individually, with
addStack. - ↳
namestring requiredThe name - ↳
routingProjectstring requiredThe routing project - List of policy packs that are applied to this policy group.
- ↳
namestring requiredThe name - ↳
displayNamestring requiredThe display name - ↳
versioninteger requiredThe version number - ↳
versionTagstring requiredThe version tag - ↳
configmap[string]object optionalThe configuration that is to be passed to the Policy Pack. This map ties Policies with their configuration. - ↳
environmentsarray[string] optionalReferences to ESC environments to use for this policy pack. accountsarray[string] requiredThe Insights accounts added to this policy group individually, withaddInsightsAccount.agentPoolIdstring optionalAgent pool ID for audit policy evaluation. Defaults to Pulumi hosted pool if not specified.- Preview: the stack match rule, a boolean expression over stack tags. Stacks whose tags satisfy it are members of the group alongside the stacks added individually. Absent when the group has no rule.
- ↳
__typestring required - Preview: the account match rule, a boolean expression over Insights account tags. Accounts whose tags satisfy it are members of the group alongside the accounts added individually. Absent when the group has no rule.
- ↳
__typestring required
Update Policy Group
/api/orgs/{orgName}/policygroups/{policyGroup}Updates a Policy Group’s configuration. This multi-purpose endpoint supports several operations in a single request via different body fields:
newName: rename the policy groupaddStack/removeStack: add or remove stacks (withnameandroutingProjectfields)addPolicyPack/removePolicyPack: add or remove policy packs (withname,version,versionTag, and optionalconfig)addInsightsAccount/removeInsightsAccount: add or remove Insights accountsstackMatchRule/removeStackMatchRule: replace or remove the stack match ruleaccountMatchRule/removeAccountMatchRule: replace or remove the account match rule
Sending a match rule and its remove field in one request is rejected with a 400 error. Setting a match rule on one of the organization’s default Policy Groups is refused, and an account match rule is also refused on preventative Policy Groups. An invalid rule is rejected with a 400 error, and no other operation in the same request is applied.
Enforcement levels for policy packs are advisory, mandatory, or disabled.
An organization’s default Policy Groups cannot be renamed: sending newName for the default stack Policy Group or the default accounts Policy Group returns a 400 error, and no other operation in the same request is applied.
A Policy Group’s enforcement mode (audit or preventative) is fixed when the group is created and cannot be changed here. To use a different mode, create a new Policy Group.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group name
Request Body
agentPoolIdstring optionalAgent pool ID for audit policy evaluation. Set to empty string to clear, omit to leave unchanged.newNamestring optionalThe new name to assign to the policy group. Up to 100 characters, made up of letters, numbers, hyphens, underscores, periods, or spaces, and may not begin or end with a space. Rejected with a 400 error for an organization’s default Policy Groups, which cannot be renamed.- A stack to add to the policy group.
- Preview: a stack match rule, a boolean expression over stack tags, that replaces the policy group’s current rule. Omit to leave the rule unchanged. Setting a rule requires the tag-based policy groups feature and is refused on the organization’s default policy groups.
- A stack to remove from the policy group. Only stacks added with
addStackcan be removed. removeStackMatchRuleboolean optionalPreview: set to true to remove the policy group’s stack match rule. Cannot be combined withstackMatchRulein the same request. Removing the rule is always allowed.- Preview: an account match rule, a boolean expression over Insights account tags, that replaces the policy group’s current rule. Omit to leave the rule unchanged. Setting a rule requires the tag-based policy groups feature and is refused on the organization’s default policy groups and on preventative groups.
- A policy pack to enable for the policy group.
removeAccountMatchRuleboolean optionalPreview: set to true to remove the policy group’s account match rule. Cannot be combined withaccountMatchRulein the same request. Removing the rule is always allowed.- A policy pack to disable for the policy group.
- An Insights account to add to the policy group.
- An Insights account to remove from the policy group. Only accounts added with
addInsightsAccountcan be removed.
Responses
Delete Policy Group
/api/orgs/{orgName}/policygroups/{policyGroup}Deletes a Policy Group from an organization. A Policy Group defines which Policy Packs are enforced on which stacks, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. The organization’s default Policy Group cannot be deleted. Deleting a Policy Group removes all policy enforcement associations for the stacks that were assigned to it.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group name
Responses
List Policy Group Accounts
/api/orgs/{orgName}/policygroups/{policyGroup}/accountsLists one page of a policy group’s member Insights accounts that the caller can access, with how each became a member. Keep requesting until continuationToken is null.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group namecontinuationTokenstring query optionalContinuation token from a previous pagecountinteger query optionalAccounts per page, 1-500. Defaults to 500.sourcestring query optionalOnly members with this source. Omit for all members.
Responses
- The member accounts on this page that the caller can access, ordered by an internal account identifier.
- ↳
idstring requiredThe account ID. - ↳
namestring requiredThe account name. - ↳
sourceenum requiredHow the account became a member of the policy group.Values:explicit,rule - ↳
tagsmap[string]string requiredThe account’s tags. Team-access tags are left out. continuationTokenstring optionalContinuation token for the next page. Omitted when there are no more results.
Batch Update Policy Group
/api/orgs/{orgName}/policygroups/{policyGroup}/batchBatchUpdatePolicyGroup applies multiple update operations to the Policy Group efficiently. Each operation in the list uses the same fields as UpdatePolicyGroupRequest. Operations are grouped by type (adds, removes) and processed in batches for efficiency. For agentPoolId and for each match rule, the last request in the list that sets or removes it applies.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group name
Request Body
Responses
List Policy Group Stacks
/api/orgs/{orgName}/policygroups/{policyGroup}/stacksLists one page of a policy group’s member stacks that the caller can access, with how each became a member. Keep requesting until continuationToken is null.
Request Parameters
orgNamestring path requiredThe organization namepolicyGroupstring path requiredThe policy group namecontinuationTokenstring query optionalContinuation token from a previous pagecountinteger query optionalStacks per page, 1-500. Defaults to 500.sourcestring query optionalOnly members with this source. Omit for all members.
Responses
- The member stacks on this page that the caller can access, ordered by an internal stack identifier.
- ↳
namestring requiredThe stack name. - ↳
routingProjectstring requiredThe project the stack belongs to. - ↳
sourceenum requiredHow the stack became a member of the policy group.Values:explicit,rule - ↳
tagsmap[string]string requiredThe stack’s tags, including built-in ones such asvcs:repo. Team-access tags are left out. continuationTokenstring optionalContinuation token for the next page. Omitted when there are no more results.
Preview Account Match Rule
/api/orgs/{orgName}/policygroups/accountmatchrule/previewEvaluates an account match rule without saving it, returning one page of the Insights accounts it matches with their tags, and on the first page how many accounts it matches out of the total. Only accounts the caller can access are listed or counted. Keep requesting until continuationToken is null.
Request Parameters
orgNamestring path requiredThe organization namecontinuationTokenstring query optionalContinuation token from a previous pagecountinteger query optionalAccounts per page, 1-500. Defaults to 500.
Request Body
- The match rule, a boolean expression over account tags.
searchstring optionalOnly list accounts whose name contains this text, ignoring case. The counts are not narrowed.
Responses
- The matching accounts on this page that the caller can access, ordered by name, so a parent account comes before its child accounts.
- ↳
idstring requiredThe account ID. - ↳
namestring requiredThe account name. - ↳
tagsmap[string]string requiredThe account’s tags. Team-access tags are left out. matchedCountinteger optionalThe number of accounts the caller can access that the rule matches. Set on the first page only.totalCountinteger optionalThe number of live accounts in the organization the caller can access. Set on the first page only.continuationTokenstring optionalContinuation token for the next page. Omitted when there are no more results.
Get Policy Group Metadata
/api/orgs/{orgName}/policygroups/metadataReturns high-level policy protection metrics for an organization, including the number of stacks protected by policy enforcement, the total number of Policy Groups, and overall policy coverage statistics.
Request Parameters
orgNamestring path requiredThe organization name
Responses
ProtectedStacksinteger requiredNumber of unique stacks in any policy group (preventative or audit). Deprecated: Use PreventativeStacks and AuditStacks for breakdown by modeProtectedStackResourcesinteger requiredNumber of resources in unique stacks in any policy group (preventative or audit). Deprecated: Use PreventativeStackResources and AuditStackResources for breakdown by modePreventativeStacksinteger requiredNumber of stacks in preventative policy groupsPreventativeStackResourcesinteger requiredNumber of resources in stacks in preventative policy groupsAuditStacksinteger requiredNumber of stacks in audit policy groupsAuditStackResourcesinteger requiredNumber of resources in stacks in audit policy groupsTotalStacksinteger requiredTotal number of stacks in the organizationTotalStackResourcesinteger requiredTotal number of resources in all stacksProtectedAccountsinteger requiredNumber of accounts in policy groupsProtectedAccountResourcesinteger requiredNumber of resources in accounts in policy groupsTotalAccountsinteger requiredTotal number of accounts in the organizationTotalAccountResourcesinteger requiredTotal number of resources in all accounts
Preview Stack Match Rule
/api/orgs/{orgName}/policygroups/stackmatchrule/previewEvaluates a stack match rule without saving it, returning one page of the stacks it matches with their tags, and on the first page how many stacks it matches out of the total. Only stacks the caller can access are listed or counted. Keep requesting until continuationToken is null.
Request Parameters
orgNamestring path requiredThe organization namecontinuationTokenstring query optionalContinuation token from a previous pagecountinteger query optionalStacks per page, 1-500. Defaults to 500.
Request Body
- The match rule, a boolean expression over stack tags.
searchstring optionalOnly list stacks whose project or stack name contains this text, ignoring case. Text of the formproject/stacknarrows both parts. The counts are not narrowed.
Responses
- The matching stacks on this page that the caller can access, ordered by an internal stack identifier.
- ↳
namestring requiredThe stack name. - ↳
routingProjectstring requiredThe project the stack belongs to. - ↳
tagsmap[string]string requiredThe stack’s tags, including built-in ones such asvcs:repo. Team-access tags are left out. matchedCountinteger optionalThe number of stacks the caller can access that the rule matches. Set on the first page only.totalCountinteger optionalThe number of stacks in the organization the caller can access. Set on the first page only.continuationTokenstring optionalContinuation token for the next page. Omitted when there are no more results.