Attaching a Policy to Multiple Stacks
Last updated: November 10, 2024
Overview
Spacelift allows you to efficiently attach a policy to multiple stacks or modules using automatic labeling. This feature lets you control which stacks or modules a policy applies to without needing to configure each one individually.
Steps to Automatically Attach a Policy
Use Auto-Attach Labels
You can automatically attach a policy to specific stacks or modules by adding a label in the formatautoattach:<label>to the policy. Then, assign that same<label>to any stack or module that should inherit the policy.Example:
Add
autoattach:security-checksas a label on your policy.Apply the
security-checkslabel to any stack or module that should use this policy.
Use a Wildcard for Universal Attachment
To attach a policy to all stacks and modules in your account, use a wildcard label:Set
autoattach:*on the policy to apply it universally across all stacks and modules.
This method is ideal for policies that should apply broadly, like global security or compliance policies.