You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clarify stack policy timing in CrossGuard documentation (#15367)
Add detailed explanation of when stack policies execute during preview vs update operations. Clarify that stack policies are most useful during preview operations since they can catch violations before actual resource provisioning occurs.
Fixes#11508
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: content/docs/iac/crossguard/core-concepts.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,20 +91,29 @@ There are no restrictions on which policies you combine within a pack, and you s
91
91
92
92
There are two broad types of policies:
93
93
94
-
1.*Resource Policies*: These validate a particular resource in a stack or account before the resource is created or updated, looking at the resource's _input_ properties.
95
-
2.*Stack Policies*: These validate all resources in the stack after they've been created/updated, but before the Pulumi preview/update has completed, looking at each resource's _output_ properties.
94
+
1.**Resource Policies:** These validate a particular resource in a stack or account before the resource is created or updated, looking at the resource's *input* properties.
95
+
1.**Stack Policies:** These validate all resources in the stack after the Pulumi operation has processed all resources, looking at each resource's *output* properties. Stack policies are most useful during preview operations.
96
96
97
97
This table summarizes the primary differences between the two types:
| What does it check? | Individual resources | All resources in the stack |
102
-
| When is the check performed? | Before resources are created/modified | After all stack resources have been created/modified |
102
+
| When is the check performed? | Before resources are created/modified | After all stack resources have been created/modified (see note below)|
103
103
| Can it remediate? | Yes | No |
104
-
| What information is available? | Resource _input_ properties | Resource _output_ properties (Note: inputs are propagated to outputs during preview) |
104
+
| What information is available? | Resource *input* properties | Resource *output* properties (Note: inputs are propagated to outputs during preview) |
105
105
| What is the type name? |`ResourceValidationPolicy`|`StackValidationPolicy`|
106
106
| Supported for Insights? | Yes | No - IaC-specific feature |
107
107
108
+
{{% notes type="info" %}}
109
+
**Stack Policy Timing**: The timing of stack policy execution differs between `pulumi preview` and `pulumi update`:
110
+
111
+
- During `pulumi preview`: Stack policies run after the preview completes, using whatever output values are already known from previously provisioned resources. Since no new resources are actually created during preview, stack policies are typically most useful when run during `preview` for catching violations before any resource provisioning occurs.
112
+
- During `pulumi update`: Stack policies run after all resources have been provisioned, but before the update operation completes. This means non-compliant resources may already be created by the time the policy violation is detected.
113
+
114
+
For this reason, stack policies are most often used with `pulumi preview` to identify issues before resources are actually provisioned.
115
+
{{% /notes %}}
116
+
108
117
### Enforcement Levels
109
118
110
119
A policy has one of the following *enforcement levels*:
@@ -407,7 +416,7 @@ In this example, the `password` property will be encrypted using the stack's sec
407
416
408
417
### Stack Policies with IaC
409
418
410
-
Policies of `StackValidationPolicy` are run against all the resources in a stack. These policies are run after all stack resources are registered and thus *do not* block an out-of-compliance resource from being created, but do fail the preview or update. To avoid creating out-of-compliance resources, we recommend always running a preview command before an update. This allows you to write policies where one resource depends on the state or existence of another resource.
419
+
Policies of `StackValidationPolicy` are run against all the resources in a stack. These policies are run after all stack resources are processed and thus *do not* block an out-of-compliance resource from being created during an update, but do fail the preview or update operation. Stack policies are most useful during preview operations, as they can catch violations before any actual resource provisioning occurs. To avoid creating out-of-compliance resources, we recommend always running a preview command before an update. This allows you to write policies where one resource depends on the state or existence of another resource.
411
420
412
421
The below example requires that all dynamoDB tables have an App Autoscaling Policy associated with it.
0 commit comments