Skip to content

Commit

Permalink
Check if url is unresolved
Browse files Browse the repository at this point in the history
  • Loading branch information
spg committed Jun 20, 2019
1 parent 651d5a0 commit 11929e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-sns-subscriptions/lib/url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sns = require('@aws-cdk/aws-sns');
import { Construct } from '@aws-cdk/cdk';
import { Construct, Token } from '@aws-cdk/cdk';

/**
* Options for URL subscriptions.
Expand All @@ -24,10 +24,13 @@ export interface UrlSubscriptionProps {
*/
export class UrlSubscription implements sns.ITopicSubscription {
constructor(private readonly url: string, private readonly protocol: sns.SubscriptionProtocol, private readonly props: UrlSubscriptionProps = {}) {
if (!Token.isUnresolved(url)) {
throw new Error(`url: ${url} must be resolved`);
}
}

public bind(scope: Construct, topic: sns.ITopic): void {
new sns.Subscription(scope, this.url, {
new sns.Subscription(scope, topic.node.uniqueId + 'Url', {
topic,
endpoint: this.url,
protocol: this.protocol,
Expand Down

0 comments on commit 11929e2

Please sign in to comment.