How to use the @aws-cdk/aws-sns.SubscriptionProtocol function in @aws-cdk/aws-sns

To help you get started, we’ve selected a few @aws-cdk/aws-sns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / @aws-cdk / aws-sns-subscriptions / lib / url.ts View on Github external
constructor(private readonly url: string, private readonly props: UrlSubscriptionProps = {}) {
    this.unresolvedUrl = Token.isUnresolved(url);
    if (!this.unresolvedUrl && !url.startsWith('http://') && !url.startsWith('https://')) {
      throw new Error('URL must start with either http:// or https://');
    }

    if (this.unresolvedUrl && props.protocol === undefined) {
      throw new Error('Must provide protocol if url is unresolved');
    }

    if (this.unresolvedUrl) {
      this.protocol = props.protocol!;
    } else {
      this.protocol = this.url.startsWith('https:') ? sns.SubscriptionProtocol.HTTPS : sns.SubscriptionProtocol.HTTP;
    }
  }
github aws / aws-cdk / packages / @aws-cdk / aws-sns-subscriptions / lib / lambda.ts View on Github external
// Create subscription under *consuming* construct to make sure it ends up
    // in the correct stack in cases of cross-stack subscriptions.
    if (!Construct.isConstruct(this.fn)) {
      throw new Error(`The supplied lambda Function object must be an instance of Construct`);
    }

    this.fn.addPermission(`AllowInvoke:${topic.node.uniqueId}`, {
      sourceArn: topic.topicArn,
      principal: new iam.ServicePrincipal('sns.amazonaws.com'),
    });

    return {
      subscriberScope: this.fn,
      subscriberId: topic.node.id,
      endpoint: this.fn.functionArn,
      protocol: sns.SubscriptionProtocol.LAMBDA,
      filterPolicy: this.props.filterPolicy,
    };
  }
}
github aws / aws-cdk / packages / @aws-cdk / aws-sns-subscriptions / lib / email.ts View on Github external
public bind(_topic: sns.ITopic): sns.TopicSubscriptionConfig {
    return {
      subscriberId: this.emailAddress,
      endpoint: this.emailAddress,
      protocol: this.props.json ? sns.SubscriptionProtocol.EMAIL_JSON : sns.SubscriptionProtocol.EMAIL,
      filterPolicy: this.props.filterPolicy,
    };
  }
}

@aws-cdk/aws-sns

The CDK Construct Library for AWS::SNS

Apache-2.0
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis