MCPcopy
hub / github.com/serverless/serverless / getTopicId

Method getTopicId

packages/serverless/lib/plugins/aws/dev/index.js:806–818  ·  view source on GitHub ↗

* Given a topic name, constructs the full topic identifier for the IoT endpoint. * The topic identifier is used to subscribe to the IoT endpoint and listen for incoming events. * The topic identifier is constructed as "sls/region/serviceName/stageName/functionName". * @param {string} topicN

(topicName)

Source from the content-addressed store, hash-verified

804 * @returns {string} topicId - The full topic identifier for the IoT endpoint.
805 */
806 getTopicId(topicName) {
807 const region = this.serverless.getProvider('aws').getRegion()
808 const stage = this.serverless.getProvider('aws').getStage()
809 const serviceName = this.serverless.service.getServiceName()
810
811 let topicId = `sls/${region}/${serviceName}/${stage}`
812
813 if (topicName) {
814 topicId += `/${topicName}`
815 }
816
817 return topicId
818 }
819
820 /**
821 * Parses the dev mode function identifier into an object containing its constituent components.

Callers 1

connectMethod · 0.95

Calls 4

getServiceNameMethod · 0.80
getRegionMethod · 0.45
getProviderMethod · 0.45
getStageMethod · 0.45

Tested by

no test coverage detected