LoginSignup
0
0

More than 1 year has passed since last update.

sls deployでThe stack service name 〜〜 is not valid. と出た時の対処法

Posted at

概要

sls createして作ったサービスをデプロイしようとした時、
コマンドsls deployThe stack service name 〜〜 is not valid.というエラーが出たので、解決方法を書きます。

エラー

The stack service name "sls_go_project-dev" is not valid. A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldn't exceed 128 characters.

エラー文を読むとサービス名の制約が書かれていました。
* サービス名はアルファベットとハイフンだけである。
* アルファベットで始まり、128文字を超えないこと。

serverless.ymlの設定を見直しました。

原因

serverless.ymlのservice:以降にアンダーバーを入れていたことが原因でした。

sls createでディレクトリやその内部のファイルを一括で作成するはアラートは出ないのですが、deploy前にサービス名は変更しないといけなかったようです。

sls createした時は下記のようにエラーは出ませんでした。(sls_go_projectというのが今回指定したプロジェクト名でした。)

$ sls create -u https://github.com/serverless/serverless-golang/ -p sls_go_project

✔ Project successfully created in "sls_go_project"

解決策

serverless.ymlのservice:名のアンダーバーをハイフンに書き換えるとsls deployできました。

$ sls deploy

Deploying sls-go-project to stage dev (ap-northeast-1)

✔ Service deployed to stack sls-go-project-dev (113s)

functions:
  hello: sls-go-project-dev-hello (4.3 MB)

1 deprecation found: run 'serverless doctor' for more details
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0