Skip to content
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

feat(sns): addSubscription returns the created Subscription #16785

Merged
merged 10 commits into from Oct 26, 2021

Conversation

amirfireeye
Copy link
Contributor

@amirfireeye amirfireeye commented Oct 4, 2021

Allow creating dependencies on the subscription by returning it from addSubscription(). Before this change the subscription resource was inaccessible. Creating a dependency required manually creating the subscription resource.

Our current workaround is:

        topic = sns.Topic(self, "topic")
        subscription_req = subs.SqsSubscription(queue)
        subscription_data = subscription_req.bind(topic)
        subscription = sns.Subscription(
            self,
            "Subscription",
            topic=topic,
            endpoint=subscription_data.endpoint,
            protocol=subscription_data.protocol,
            region=subscription_data.region,
            raw_message_delivery=subscription_data.raw_message_delivery,
            filter_policy=subscription_data.filter_policy,
            dead_letter_queue=subscription_data.dead_letter_queue,
        )

        something.add_dependency(subscription)

And it would be much simpler as:

topic = sns.Topic(self, "topic")
subscription = topic.add_subscription(subs.SqsSubscription(queue))
something.add_dependency(subscription)

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

Allow creating dependencies on the subscription by return it from addSubscription(). Before this change the subscription resource was hidden. Creating a dependency required manually creating the subscription resource.
@gitpod-io
Copy link

gitpod-io bot commented Oct 4, 2021

@peterwoodworth peterwoodworth changed the title feat(sns): return subscription when adding feat(sns): return subscription when adding Oct 21, 2021
@github-actions github-actions bot added the @aws-cdk/aws-sns Related to Amazon Simple Notification Service label Oct 21, 2021
@njlynch njlynch changed the title feat(sns): return subscription when adding feat(sns): addSubscription returns the created Subscription Oct 25, 2021
@njlynch njlynch added the pr-linter/exempt-readme The PR linter will not require README changes label Oct 25, 2021
njlynch
njlynch previously approved these changes Oct 25, 2021
Copy link
Contributor

@njlynch njlynch left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

@mergify mergify bot dismissed njlynch’s stale review October 25, 2021 15:01

Pull request has been modified.

njlynch
njlynch previously approved these changes Oct 25, 2021
@njlynch njlynch added the pr-linter/exempt-test The PR linter will not require test changes label Oct 25, 2021
@mergify mergify bot dismissed njlynch’s stale review October 25, 2021 15:07

Pull request has been modified.

@amirfireeye
Copy link
Contributor Author

Sorry @njlynch seems like we were stepping on each other's toes here. I already started to work on a basic test to make CodeBuild happy. I'll ping you when it's ready. Right now I'm fighting with GitPod. I keep getting weird unrelated errors about CloudWatch when trying to run the test.

@amirfireeye
Copy link
Contributor Author

GitPod wouldn't even start up for me anymore 🤷
I was able to get it working based on the failed test logs.

@njlynch it's ready. The test is a bit simplistic, but it does convey why I created the PR in the first place. I can remove it if you think it doesn't add much value and we can stick with the exempt-tests label.

@mergify
Copy link
Contributor

mergify bot commented Oct 26, 2021

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: a527d54
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 62f389e into aws:master Oct 26, 2021
@mergify
Copy link
Contributor

mergify bot commented Oct 26, 2021

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

njlynch added a commit that referenced this pull request Oct 26, 2021
mergify bot pushed a commit that referenced this pull request Oct 26, 2021
…ption (#16785)" (#17166)

This reverts commit 62f389e.

Changing the return type from void to Subscription is a breaking change for F# customers, where the return type changes from "unit" to "Subscription", potentially breaking `do` statements.

Example:
https://github.com/aws/aws-cdk/blob/62f389ea0522cbaefca5ca17080228031d401ce6/packages/aws-cdk/lib/init-templates/v1/sample-app/fsharp/src/%25name.PascalCased%25/%25name.PascalCased%25Stack.template.fs#L14

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@amirfireeye
Copy link
Contributor Author

@njlynch I just see this get released with v2.0.0-rc.28. Does that mean it will be in v2.x but not in v1.x?

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Allow creating dependencies on the subscription by returning it from `addSubscription()`. Before this change the subscription resource was inaccessible. Creating a dependency required manually creating the subscription resource.

Our current workaround is:

```
        topic = sns.Topic(self, "topic")
        subscription_req = subs.SqsSubscription(queue)
        subscription_data = subscription_req.bind(topic)
        subscription = sns.Subscription(
            self,
            "Subscription",
            topic=topic,
            endpoint=subscription_data.endpoint,
            protocol=subscription_data.protocol,
            region=subscription_data.region,
            raw_message_delivery=subscription_data.raw_message_delivery,
            filter_policy=subscription_data.filter_policy,
            dead_letter_queue=subscription_data.dead_letter_queue,
        )

        something.add_dependency(subscription)
```

And it would be much simpler as:

```
topic = sns.Topic(self, "topic")
subscription = topic.add_subscription(subs.SqsSubscription(queue))
something.add_dependency(subscription)
```

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ption (aws#16785)" (aws#17166)

This reverts commit 62f389e.

Changing the return type from void to Subscription is a breaking change for F# customers, where the return type changes from "unit" to "Subscription", potentially breaking `do` statements.

Example:
https://github.com/aws/aws-cdk/blob/62f389ea0522cbaefca5ca17080228031d401ce6/packages/aws-cdk/lib/init-templates/v1/sample-app/fsharp/src/%25name.PascalCased%25/%25name.PascalCased%25Stack.template.fs#L14

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sns Related to Amazon Simple Notification Service pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants