Skip to content

fix(sns): forward CloudFormation subscription roles - #7683

Merged
pgermosen merged 2 commits into
floci-io:mainfrom
AndreKurait:fix/sns-cfn-subscription-role-20261106
Nov 7, 2026
Merged

pgermosen merged 2 commits into
floci-io:mainfrom
AndreKurait:fix/sns-cfn-subscription-role-20261106

Conversation

@AndreKurait

@AndreKurait AndreKurait commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7672. CloudFormation now resolves and forwards SubscriptionRoleArn when creating an AWS::SNS::Subscription. Role updates use the existing SNS attribute operation and preserve the subscription ARN. Removes the corresponding writable-property gap.

Type of change

  • Bug fix (fix:)
  • Breaking change

AWS Compatibility

CloudFormation documents SubscriptionRoleArn for Firehose subscriptions with no-interruption updates. The SDK regression creates a subscription with an intrinsic role ARN, changes the role, and checks attribute readback and unchanged subscription identity. Unit coverage also preserves explicit-null omission. This does not claim general property-removal semantics or Firehose delivery authorization.

Fresh Java 25 qualification: 163 tests across four classes, zero failures, errors or skips; clean package, full Checkstyle and five repository gates pass. Includes the SNS service, provisioner, CloudFormation SDK regression and schema coverage. Retained prior unchanged-production controls fail the two new create/update regressions, with 144 existing positives. Those controls were not repeated because the affected source is unchanged.

Retained prior AWS comparison covered create and role update in two regions, preserving subscription identity; fourteen owned resources and two stacks were deleted and verified absent. That prior comparison was not reexecuted for publication. No native, Firehose delivery, full repository suite or complete dev-graph qualification claim.

Checklist

  • Relevant Java 25 tests and package/Checkstyle pass
  • AWS SDK integration regression added
  • Conventional commit and DCO
  • Full repository test suite executed for this change

Current Signer and ECS contributor changes touch different rows of the shared property-gap inventory.

Namespace and subscription-reuse follow-up

Rebased on 7cf443fcee499f707453990099b9e0442aab72d7 using the maintainer package migration tool. All four original feature files are preserved byte-for-byte after package replacement; the original message and DCO remain.

Repeated Subscribe now rejects conflicting RawMessageDelivery and FilterPolicy while preserving the existing subscription. Nonempty filter-policy strings compare exactly, including whitespace and ordering. Omission, observed empty/default values, ignored FilterPolicyScope changes and explicit attribute updates retain their behavior. This does not silently assign a different Firehose role during initial reuse.

Fresh Java 25 qualification at tree 61108e85d8479b9a1f0201e37a2bc23a237874a4: 224 tests across 8 SNS and CloudFormation classes, zero failures/errors/skips. Package, full Checkstyle and five repository gates pass. SDK Query and JSON conflict/state-preservation controls cover the combined source. Against the exact old SNS service, the regression control has 10 assertion failures and two positives, zero errors or skips. The prior separate 14 local SDK and 34 AWS Subscribe controls remain scoped evidence, not new execution in this rebase. No role-equality/removal, captured CloudFormation execution identity/PassRole, delivery, native-image or full-suite proof is claimed.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Forward CloudFormation SNS subscription roles on create and update

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Resolve and forward subscription role ARNs so CloudFormation-created Firehose subscriptions retain
 their configured role.
• Apply role changes without replacing the subscription or changing its ARN.
• Add create/update regression coverage and remove the resolved writable-property gap.
Diagram

graph TD
  A["Subscription template"] --> B["Intrinsic resolution"] --> C["SNS provisioner"] --> D["SNS service"] --> E[("Subscription record")]
Loading
High-Level Assessment

Using the existing SNS subscribe and attribute operations is appropriate: subscribe forwards the role at creation, while the attribute setter changes an existing subscription without replacing it. No new service abstraction is needed.

Files changed (4) +108 / -1

Bug fix (1) +7 / -0
SnsCfnProvisioner.javaForward resolved subscription roles to SNS +7/-0

Forward resolved subscription roles to SNS

• Resolves non-null SubscriptionRoleArn properties and includes them in subscription attributes. On updates, writes the role with setSubscriptionAttribute while retaining the subscription ARN.

src/main/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SnsCfnProvisioner.java

Tests (3) +101 / -1
CloudFormationSnsFirehoseRoleIntegrationTest.javaCover Firehose role creation and in-place updates through the SDK +68/-0

Cover Firehose role creation and in-place updates through the SDK

• Creates and updates a CloudFormation Firehose subscription with an intrinsic role ARN. Checks SNS attribute readback and verifies that the physical subscription ARN does not change.

src/test/java/io/github/hectorvent/floci/services/cloudformation/CloudFormationSnsFirehoseRoleIntegrationTest.java

SnsCfnProvisionerTest.javaCover resolved role forwarding and explicit-null omission +33/-0

Cover resolved role forwarding and explicit-null omission

• Verifies that a resolved role ARN reaches SNS subscribe and that an explicit null role is omitted from the attribute map.

src/test/java/io/github/hectorvent/floci/services/cloudformation/provisioners/SnsCfnProvisionerTest.java

writable-property-gaps.tsvRemove the resolved subscription-role property gap +0/-1

Remove the resolved subscription-role property gap

• Removes SubscriptionRoleArn from the inventory of CloudFormation subscription properties accepted but ignored.

src/test/resources/cloudformation/writable-property-gaps.tsv

@qodo-code-review

qodo-code-review Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Stack authors can bypass role permissions ⊘ Outdated
Description
provisionSubscription forwards a template-supplied SubscriptionRoleArn directly to SNS without
checking the stack caller's iam:PassRole permission. When IAM enforcement is enabled, a caller
allowed to create or update a stack but not pass the role can still assign a valid role ARN, because
CloudFormation's request filter checks only the request-level RoleARN and internal provisioning
bypasses the SNS request filter.


Remediation recommended

2. Existing subscriptions keep the wrong role ⊘ Outdated
Description
provisionSubscription supplies the requested role to subscribe, but its role setter runs only
when ctx.isUpdate() is true. If a subscription with the same topic, protocol and endpoint already
exists when a stack is created, SNS returns that subscription without applying the supplied
attributes, so the stack succeeds while its requested role is not installed.

3. Removed roles remain on subscriptions ⊘ Outdated
Description
provisionSubscription omits SubscriptionRoleArn from the attribute map when the updated property
is absent or null, and its update setter then has nothing to write. For a non-Firehose subscription
previously given a role by CloudFormation, an update removing that property returns the existing
subscription without changing its stored role.

Grey Divider

Context sources
✅ Compliance rules (platform): 16 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Small, localized SNS provisioner fix, but it changes stack-update behavior, so not trivial.

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@hectorvent

Copy link
Copy Markdown
Member

Floci's Java package moved from io.github.hectorvent.floci to io.floci.aws in #7689, so this PR's files now live under a new path and it will show conflicts against main. There is no need to resolve them by hand. From any checkout of the repository, run:

git fetch origin
bash <(git show origin/main:tools/rename/rebase_across_rename.sh) <your-branch>

The script applies the same rename to your branch and replays your change onto the new main, so only real conflicts remain (changes main made to the same lines you changed). Your commits become one commit with their messages and sign-offs kept, and your old tip is saved as <your-branch>-before-rename. Nothing is pushed: check the result, build it, then run

git push --force-with-lease origin <your-branch>

It needs only git, bash and python3 (on Windows, Git Bash or WSL). If it stops on a conflict, or anything looks off, reply here and we will help. More context in https://github.com/orgs/floci-io/discussions/6590.

Resolve SubscriptionRoleArn for SNS subscriptions and update the role without replacing the subscription. Remove the covered CloudFormation property gap.

Validate RawMessageDelivery and FilterPolicy when Subscribe reuses an existing subscription; preserve omitted/default attributes and explicit updates.

Signed-off-by: Andre Kurait <akurait@amazon.com>
@AndreKurait
AndreKurait force-pushed the fix/sns-cfn-subscription-role-20261106 branch from 8a35def to 20e6fef Compare November 6, 2026 15:46
@AndreKurait

Copy link
Copy Markdown
Contributor Author

Rebased across the namespace migration in 20e6fef, preserving all four original feature files after exact package replacement and the original message/DCO. The source-backed Subscribe reuse follow-up now rejects conflicting raw delivery and filter policies without mutating the existing subscription; explicit updates remain supported. Fresh 224 affected tests, package, full Checkstyle and repository gates pass. The separate Firehose role/PassRole/removal proof limits remain open.

@pgermosen pgermosen added bug Something isn't working cloudformation AWS CloudFormation sns Amazon Simple Notification Service (SNS) labels Nov 6, 2026

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AndreKurait thanks, the role now reaches SNS on create and update. It's not quite ready yet, though.

As far as I can tell, the new check in subscribe also meets CloudFormation's own updates. FilterPolicy and RawMessageDelivery update in place, and provisionSubscription sends an update through subscribe, which finds the stack's own subscription with the old values and now refuses it. So an UpdateStack that changes either one fails, where it used to succeed without applying the change. Could the update set the changed attributes on the existing subscription, as it now does for the role, with a test that updates FilterPolicy?

@pgermosen pgermosen added the waiting-author Review posted; waiting on the PR author to respond label Nov 6, 2026
Update the stack subscription by its prior physical identity when topic, protocol and endpoint are unchanged. Preserve Subscribe validation for creates and target replacements, reset dropped declared attributes and validate firehose roles before other attribute writes. Cover FilterPolicy and raw delivery updates/removal through CloudFormation and SNS SDKs.

Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
@AndreKurait

Copy link
Copy Markdown
Contributor Author

@pgermosen Fixed in 56bc16f. Updates now use the prior subscription ARN when topic, protocol and endpoint are unchanged, then apply the mutable attributes through SetSubscriptionAttributes. Creates and target replacements retain Subscribe validation. Dropped declared policies/raw delivery are reset; attributes never declared by the stack are preserved, and firehose role validation precedes other writes.

The new CloudFormation/SNS SDK regression changes FilterPolicy and RawMessageDelivery, removes them, and asserts the same subscription ARN throughout. With the exact original provisioner it reaches UPDATE_ROLLBACK_COMPLETE; the fixed version passes.

Validation: Java 25 clean package and full Checkstyle, 253 tests across 10 affected SNS/CloudFormation classes with zero failures/errors/skips, plus five static gates. The exact old-source control set fails six of nine cases with three positives; all nine pass on the fixed source. This is local SDK/service coverage, not live AWS or native qualification. Replacement CI remains separate.

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AndreKurait thanks, an update on the same topic, protocol and endpoint now sets the changed attributes on the stack's own subscription and resets the ones it dropped, so FilterPolicy and RawMessageDelivery updates apply in place instead of meeting the new Subscribe check.

@pgermosen pgermosen removed the waiting-author Review posted; waiting on the PR author to respond label Nov 7, 2026
@pgermosen
pgermosen merged commit 7656472 into floci-io:main Nov 7, 2026
26 checks passed
@hectorvent

Copy link
Copy Markdown
Member

🎉 This PR is included in version 2.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cloudformation AWS CloudFormation released sns Amazon Simple Notification Service (SNS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] cloudformation: AWS::SNS::Subscription with Protocol firehose fails, SubscriptionRoleArn not forwarded

3 participants