feat(aws): add ignore_tags to preserve customer-applied resource tags#352
Draft
Lytol wants to merge 2 commits into
Draft
feat(aws): add ignore_tags to preserve customer-applied resource tags#352Lytol wants to merge 2 commits into
Lytol 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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