Skip to content

feat(core): PropertyMergeStrategy now supports array merge strategies#37841

Merged
mergify[bot] merged 2 commits into
mainfrom
mrgrain/feat/core/cfn-props-mixin-enhancements
May 12, 2026
Merged

feat(core): PropertyMergeStrategy now supports array merge strategies#37841
mergify[bot] merged 2 commits into
mainfrom
mrgrain/feat/core/cfn-props-mixin-enhancements

Conversation

@mrgrain
Copy link
Copy Markdown
Contributor

@mrgrain mrgrain commented May 12, 2026

Issue # (if applicable)

N/A

Reason for this change

The combine merge strategy always replaced arrays wholesale. There was no way to append, prepend, or selectively update array elements when applying property mixins — a common need for tags, rules, and other list-typed CloudFormation properties.

Description of changes

PropertyMergeStrategy.combine() now accepts an optional arrays option powered by a new ArrayMergeStrategy class. Available strategies are:

  • replace — replace the target array entirely (default, preserves existing behavior)
  • append — add source elements after target elements
  • prepend — add source elements before target elements
  • replaceByIndex — overwrite target elements positionally from the front
  • replaceByKey(key) — match object elements by a shared key field, replacing matches and appending new ones

Array elements are never deep-merged regardless of strategy.

Additionally, CfnPropsMixin gains a static of<T>() factory to avoid circular imports when referencing L1 classes across module boundaries.

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Unit tests for all array merge strategies and the CfnPropsMixin.of() factory. All existing tests continue to pass.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…fnPropsMixin now supports a static `of()` factory that accepts a\nresource type name string instead of the class constructor, avoiding\ncircular dependency issues. The type parameter is enforced (defaults\nto `never`) so autocomplete works correctly.\n\nPropertyMergeStrategy.combine() now accepts an `arrays` option with\nstrategies: replace (default), append, prepend, replaceByIndex, and\nreplaceByKey. Array elements are never deep-merged.
@mrgrain mrgrain requested a review from a team as a code owner May 12, 2026 10:41
@github-actions github-actions Bot added the p2 label May 12, 2026
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label May 12, 2026
@mergify mergify Bot temporarily deployed to automation May 12, 2026 10:41 Inactive
@mergify mergify Bot temporarily deployed to automation May 12, 2026 10:42 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

👋 It looks like your PR description follows the template but is missing a valid issue number in the first section.

PRs without a linked issue will receive lower priority for review and merging. Please update the description to include a reference like Closes #123. If no existing issue matches your change, create one first.

Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@mrgrain mrgrain added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels May 12, 2026
@mrgrain mrgrain changed the title feat(core): enhance CfnPropsMixin and add array merge strategies feat(core): PropertyMergeStrategy now supports array merge strategies May 12, 2026
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 12, 2026 10:52

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 12, 2026
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 12, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 12, 2026

Merge Queue Status

  • Entered queue2026-05-12 14:42 UTC · Rule: default-squash
  • Checks passed · in-place
  • Merged2026-05-12 15:17 UTC · at 4907b2bb973dfa86927a763347b00b82aaf21f15 · squash

This pull request spent 35 minutes 37 seconds in the queue, including 1 hour 6 minutes 42 seconds running CI.

Required conditions to merge

@mergify mergify Bot temporarily deployed to automation May 12, 2026 14:42 Inactive
@mergify mergify Bot temporarily deployed to automation May 12, 2026 14:42 Inactive
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 12, 2026

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label May 12, 2026
@mergify mergify Bot merged commit 701305d into main May 12, 2026
25 of 26 checks passed
@mergify mergify Bot deleted the mrgrain/feat/core/cfn-props-mixin-enhancements branch May 12, 2026 15:17
@github-actions
Copy link
Copy Markdown
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants