# Assign policy groups by stack and account tags

DevFeed: [Assign policy groups by stack and account tags](<https://devfeed.tech/articles/assign-policy-groups-by-stack-and-account-tags-90411.md>)

Original publisher: [Read original article](<https://www.pulumi.com/blog/assign-policy-groups-by-tags/>)

Author: Dan Biwer

Published: 2026-10-19T00:00:00Z

Content type: release

Language: en

Sources: [Pulumi](<https://devfeed.tech/sources/pulumi.md>)

Topics: [policy-as-code](<https://devfeed.tech/topics/policy-as-code.md>), [pulumi](<https://devfeed.tech/topics/pulumi.md>), [pulumi-cloud](<https://devfeed.tech/topics/pulumi-cloud.md>)

Tags: [compliance](<https://devfeed.tech/tags/compliance.md>), [features](<https://devfeed.tech/tags/features.md>), [governance](<https://devfeed.tech/tags/governance.md>), [infrastructure](<https://devfeed.tech/tags/infrastructure.md>), [policy](<https://devfeed.tech/tags/policy.md>), [policy-as-code](<https://devfeed.tech/tags/policy-as-code.md>), [product](<https://devfeed.tech/tags/product.md>), [pulumi](<https://devfeed.tech/tags/pulumi.md>), [pulumi-cloud](<https://devfeed.tech/tags/pulumi-cloud.md>), [tag](<https://devfeed.tech/tags/tag.md>)

## AI overview

Pulumi Cloud now lets policy groups automatically include stacks and cloud accounts based on tag matching rules. Membership updates as tags change, and teams can define the rules in the console or with the Pulumi Service Provider while keeping existing individually assigned members.

## Source excerpt

Policy groups decide which policy packs apply to which stacks and cloud accounts. Until now, stacks and accounts were added to policy groups individually, so every new stack required opting into their correct group by hand. Policy groups membership can now be managed by tags, so new infrastructure gets the right policy coverage automatically as it's created. What's new Policy groups now support tag matching conditions. Every stack or cloud account whose tags match the condition joins the group, and membership stays current as tags change. Tag rules work alongside the stacks and accounts you add individually, so you can adopt them without restructuring your existing groups. To add one, open a policy group in Pulumi Cloud and select Match by tags. Or define it in code with the Pulumi Service Provider: import * as pulumiservice from "@pulumi/pulumiservice"; new pulumiservice.api.PolicyGroup("payments-production", { orgName: "my-org", name: "payments-production", mode: "preventative", stackMatchRule: pulumiservice.buildStackMatchRuleOutput({ rules: [{ conditions: [{ key: "env", value: "prod" }, { key: "team", value: "payments" }] }], }).matchRule, }); new pulumiservice.api.PolicyGroup("pci-accounts", { orgName: "my-org", name: "pci-accounts", mode: "audit", accountMatchRule: pulumiservice.buildAccountMatchRuleOutput({ rules: [{ conditions: [{ key: "env", value: "prod" }, { key: "compliance", value: "pci" }] }], }).matchRule, }); Example: enforcement by environment A common pattern is one policy group per environment tier, with stricter enforcement in production: A production preventative group with a rule matching env: prod, where critical policies are mandatory. A development preventative group with a rule matching env: dev, where the same packs are advisory. A new stack tagged env: prod joins your production policy group automatically, with no one editing the group. The same approach works for audit groups and cloud accounts, for example matching accounts tagged compl