Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Sns topic update functionality #12777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

michalisfot
Copy link

@michalisfot michalisfot commented Jun 19, 2025

Related PR: #12768

Motivation

This PR implements comprehensive update support for the AWS::SNS::Topic CloudFormation resource, addressing the core requirement to enable updates for DisplayName, TopicName, and Tags properties. The implementation follows AWS CloudFormation's update semantics, including resource replacement when immutable properties change.

Changes

Enhanced Resource Provider (aws_sns_topic.py)

  • Implemented complete update() method with support for:

    • In-place updates: DisplayName attribute changes
    • Resource replacement: TopicName changes (recreates topic with new name)
    • Tag management: Add/remove/update tags with proper diffing
    • State preservation: Maintains subscriptions and existing tags during topic replacement
  • Key features:

    • Proper ARN handling and validation
    • Graceful error handling for subscription/tag preservation
    • Follows AWS update semantics (replacement vs. in-place)
    • Resource cleanup (deletes old topic after successful replacement)

Comprehensive Test Coverage (test_sns.py)

  • Created test_sns_topic_update_attributes() with in-place updates (no resource replacement):

    • DisplayName updates: Verifies DisplayName attribute changes are applied correctly
    • Tag updates: Tests adding, modifying, and removing tags
    • Same topic preservation: Ensures TopicArn remains unchanged during in-place updates
    • Snapshot validation: Captures before/after state for attribute and tag changes
  • Created test_sns_topic_update_name() with resource replacement:

    • Tag preservation validation: Verifies existing tags are preserved during replacement
    • Subscription preservation validation: Ensures subscriptions are migrated to new topic
    • ARN format validation: Builds and validates new ARN using proper AWS format
    • Resource replacement verification: Confirms old topic deletion and new topic creation
    • Comprehensive snapshots: Captures before/after state for all operations

Added new entries to the Snapshot File (test_sns.snapshot.json)

Testing

  • On AWS and ocally both test pass.

TODO

  • Test against AWS and find out why test_sns_topic_update_name test fails on AWS but not locally.
  • Find a proper way to validate the snapshot against the tags rather than manually checking each tag

Proposed Next Steps

1: Complete Core Properties

  1. Archive Policy Support
  2. Access Policy Support
  3. KMS Key Management
  4. FIFO Topic Properties
  5. ContentBasedDeduplication

2: Advanced Update Capabilities

  1. Subscription Management
  2. Data Protection Policy
  3. Delivery Policy Configuration

3: Robustness & Edge Cases

  1. Error Handling Enhancement - Improve rollback scenarios for failed updates
  2. Performance Optimizations

4: Testing

  1. Multi account and region testing
  2. Other types of testing as mentioned in the docs

@localstack-bot
Copy link
Collaborator

localstack-bot commented Jun 19, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@simonrw simonrw added the semver: patch Non-breaking changes which can be included in patch releases label Jun 19, 2025
@michalisfot
Copy link
Author

recheck

1 similar comment
@michalisfot
Copy link
Author

recheck

@michalisfot
Copy link
Author

I have read the CLA Document and I hereby sign the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants