Skip to content

Commit

Permalink
chore(sns): addSubscription does not return the subscription (#20819)
Browse files Browse the repository at this point in the history
----





### Description
Related to the following issue: #20657. Added a return statement to addSubscription to return the Subscription

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jonnekaunisto committed Jul 7, 2022
1 parent 0b40c25 commit e43e4f2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/@aws-cdk/aws-sns/lib/topic-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface ITopic extends IResource, notifications.INotificationRuleTarget
/**
* Subscribe some endpoint to this topic
*/
addSubscription(subscription: ITopicSubscription): void;
addSubscription(subscription: ITopicSubscription): Subscription;

/**
* Adds a statement to the IAM resource policy associated with this topic.
Expand Down Expand Up @@ -80,7 +80,7 @@ export abstract class TopicBase extends Resource implements ITopic {
/**
* Subscribe some endpoint to this topic
*/
public addSubscription(subscription: ITopicSubscription) {
public addSubscription(subscription: ITopicSubscription): Subscription {
const subscriptionConfig = subscription.bind(this);

const scope = subscriptionConfig.subscriberScope || this;
Expand All @@ -95,7 +95,7 @@ export abstract class TopicBase extends Resource implements ITopic {
throw new Error(`A subscription with id "${id}" already exists under the scope ${scope.node.path}`);
}

new Subscription(scope, id, {
return new Subscription(scope, id, {
topic: this,
...subscriptionConfig,
});
Expand Down

0 comments on commit e43e4f2

Please sign in to comment.