anomalyco/sst · error · VisibleError

Cannot access the AWS Cloud Map service name for the "${this

Error message

Cannot access the AWS Cloud Map service name for the "${this._name}" Service. Cloud Map is not configured for the cluster.

What it means

The `service` getter returns the Cloud Map service-discovery name (`<service>.<namespace>`), which is only available when the underlying cluster has Cloud Map configured. If the Service's cluster has no Cloud Map namespace (`cloudmapNamespace` is undefined), the getter throws this VisibleError because there is no discovery name to return.

Source

Thrown at platform/src/components/aws/service.ts:2860

    const errorMessage =
      "Cannot access the URL because no public ports are exposed.";
    if (this.dev) {
      if (!this.devUrl) throw new VisibleError(errorMessage);
      return this.devUrl;
    }

    if (!this._url) throw new VisibleError(errorMessage);
    return this._url;
  }

  /**
   * The name of the Cloud Map service. This is useful for service discovery.
   */
  public get service() {
    return all([this.cloudmapNamespace, this.cloudmapService]).apply(
      ([namespace, service]) => {
        if (!namespace)
          throw new VisibleError(
            `Cannot access the AWS Cloud Map service name for the "${this._name}" Service. Cloud Map is not configured for the cluster.`,
          );

        return this.dev
          ? interpolate`dev.${namespace}`
          : interpolate`${service!.name}.${namespace}`;
      },
    );
  }

  /**
   * The underlying [resources](/docs/components/#nodes) this component creates.
   */
  public get nodes() {
    const self = this;
    return {
      /**
       * The Amazon ECS Service.

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Configure Cloud Map on the cluster the Service runs in (set the cluster's cloudmap/namespace option) and redeploy.
  2. Use the default managed cluster, which sets up Cloud Map automatically.
  3. If discovery isn't needed, stop accessing `.service` and reference the ECS service or a URL/link directly.

Example fix

// before
const cluster = new sst.aws.Cluster("Cluster");
const svc = new sst.aws.Service("Svc", { cluster });
const name = svc.service; // throws
// after
const cluster = new sst.aws.Cluster("Cluster", {
  cloudmap: true
});
const svc = new sst.aws.Service("Svc", { cluster });
const name = svc.service; // "svc.cluster.local" style name
Defensive patterns

Strategy: validation

Validate before calling

if (!clusterArgs.cloudmap) {
  throw new Error("Cluster must have cloudmap configured before Service.service discovery names are available");
}

Type guard

function cloudmapConfigured(cluster: { cloudmap?: { namespace?: string } | boolean }): boolean {
  return cluster.cloudmap === true || (typeof cluster.cloudmap === "object" && !!cluster.cloudmap?.namespace);
}

Try / catch

let discoveryName: string;
try {
  discoveryName = svc.service;
} catch (e) {
  if (e instanceof VisibleError && e.message.includes("Cloud Map is not configured")) {
    throw new Error(`Enable cloudmap on the cluster used by "${svcName}" to use service discovery`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Accessing `myService.service` on a Service whose cluster (e.g. a Cluster component or the default cluster) was created without a Cloud Map namespace — typically when `cloudmap` was not configured on the cluster.

Common situations: Using a custom `Cluster` without enabling Cloud Map and then trying service discovery by name; switching from the default cluster (which configures Cloud Map) to a bare one; sharing cluster config across stacks where one omits cloudmap.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/89ea08d4086c3b68. Report an issue: GitHub.