in src/experimental/patterns/sns-lambda.ts [68:90]
constructor(scope: GuStack, id: string, props: GuSnsLambdaProps) {
super(scope, id, {
...props,
errorPercentageMonitoring: props.monitoringConfiguration.noMonitoring ? undefined : props.monitoringConfiguration,
});
const { account, region } = scope;
const { existingSnsTopic } = props;
this.snsTopic = existingSnsTopic
? Topic.fromTopicArn(
scope,
`${id}-SnsExistingIncomingEventsTopic`,
`arn:aws:sns:${region}:${account}:${existingSnsTopic.externalTopicName}`,
)
: AppIdentity.taggedConstruct(props, new Topic(scope, "SnsIncomingEventsTopic"));
// If we have an alias, use this to ensure that all events are sent to a published Lambda version.
// Otherwise, send all events to the latest unpublished version ($LATEST)
const eventSourceTarget = this.alias ?? this;
eventSourceTarget.addEventSource(new SnsEventSource(this.snsTopic));
new CfnOutput(this, "TopicName", { value: this.snsTopic.topicName });
}