feat(aws): add ignore_tags to preserve customer-applied resource tags#352
feat(aws): add ignore_tags to preserve customer-applied resource tags#352Lytol wants to merge 2 commits into
Conversation
Add a per-target `ignore_tags` list (exact AWS tag keys) wired into the Pulumi AWS provider's ignoreTags so customer-applied tags are not stripped by our IaC. Requires optrefresh.RunProgram(true) on refresh (scoped to stacks that set ignoreTags) so the setting is honored during `ensure --refresh`; provider ignoreTags is otherwise inert on refresh (pulumi/pulumi#13860). AWS-only.
Document that ignoreTags only takes effect after a state-persisting ensure registers it on the provider, so adopting it on a target that already has a matching tag in state would strip that tag on the first apply. Add the dry-run pre-check and register-while-clean rollout procedure.
PR Review: feat(aws): add ignore_tags to preserve customer-applied resource tagsTasks
Overall this is a clean, well-scoped implementation. The path-config approach is correct, and the Important: Stale path-config entries when keys are removed
Important: Silently dropped
|
Description
Adds a per-target
ignore_tagsoption: a flat list of exact AWS tag keys thatPTD's IaC must never add or remove on managed resources. This lets customers (or
an org-wide tagging policy) apply their own tags to resources PTD manages without
our
ptd ensurereverting them.AWS-only. Azure config is intentionally not given the field (the
azure-nativeprovider has no equivalent, and
aws:ignoreTagsis provider-namespaced so itcannot affect Azure resources).
Code Flow
IgnoreTags []string(ignore_tags) added toAWSWorkloadConfigand
AWSControlRoomConfig(lib/types). Exposed on theTargetinterface asIgnoreTags(); implemented on the AWS target (threaded throughNewTarget),the Azure target returns
nil. Plumbed from config incmd/internal/legacy/ptd_config.go.ConfigureStackRegion(lib/pulumi/common.go) setsaws:ignoreTags.keys[i]as nested path config, fed fromStackConfig.IgnoreTagsin
inline.go. Applies to every resource on the ambient AWS provider.use1(us-east-1) provider getsIgnoreTagson its args when set.RefreshStack(lib/pulumi/pulumi.go) passesoptrefresh.RunProgram(true)only when the stack hasaws:ignoreTagsconfigured. Required: without re-running the program,
pulumi refreshreusesthe provider config from the last
up, soignoreTagsis inert on refresh(Use new provider version or config during refresh pulumi/pulumi#13860). The gate leaves refresh behavior unchanged for every
workload that does not use the feature.
Rollout / adoption caveats
ignoreTagsis enforced at the AWS-provider level and only takes effect once astate-persisting
ptd ensure(an apply) has registered it on the target'sprovider — the run that first registers it still plans against the previous
provider ("one operation late"). Consequences, verified end-to-end on staging:
ignoreTagswhile the target's statehas no matching tag is a no-op for resources; afterwards, customer tags added
out-of-band are filtered on every
ptd ensure(including--refresh) — neveradded, removed, or pulled into state.
apply (a prior
--refreshis how such a tag gets into state). This isdetectable:
ptd ensure <target> --dry-runshows- <key>for exactly thesetargets. Handle them by clearing the key from state first (a state-only
ensure --refresh, which does not touch AWS), then apply.ptd ensureacross targets while their state is cleanof the configured keys (use the
--dry-runcheck to catch any that are not).ignore_tagslater needs another registeringptd ensureonthen-clean state before it is protected.
See the "Adopting
ignore_tagson an existing target" section indocs/CONFIGURATION.mdfor the step-by-step runbook.Category of change
Checklist