2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS SAMデプロイエラー時の対応

Posted at

経緯

  • AWS SAM CLIでデプロイ実行したところ、エラーで停止しました(初回デプロイ)
  • CloudFormationスタックを確認すると、 ROLLBACK_COMPLETE で停止しています
  • 失敗となった原因を修正し、再度デプロイを実行したのですが、下記のようなメッセージが表示され、デプロイされません
$ sam deploy

(snip)

Initiating deployment
=====================

File with same data already exists at sam-app/xxx.template, skipping upload
Error: Failed to create changeset for the stack: sam-app, An error occurred (ValidationError) when calling the CreateChangeSet operation: Stack:arn:aws:cloudformation:(...snip...) is in ROLLBACK_COMPLETE state and can not be updated.

原因と対処

初回デプロイで失敗し、CloudFormationスタックのステータスが ROLLBACK_COMPLETE となった場合は更新できない仕様のようです。

対処としては、削除後、再度デプロイします。
初回デプロイ失敗、つまりデプロイ不完全であり、削除することで問題になることは無さそうです。
(デプロイ成功し、動作後はアプリケーションによって出力されたデータ等の保全の考慮が必要になる可能性がありますが、初回デプロイで失敗しているのでその点については考慮不要)

削除

CloudFormationスタックが削除されます

$ sam delete
        Are you sure you want to delete the stack sam-app in the region ap-northeast-1 ? [y/N]: y
        Are you sure you want to delete the folder sam-app in S3 which contains the artifacts? [y/N]: y
        - Deleting S3 object with key sam-app/xxx
        - (snip)
        - Deleting S3 object with key sam-app/xxx.template
        - Deleting Cloudformation stack sam-app
Deleted successfully

再度デプロイ

成功しました

$ sam deploy --config-env dev

(snip)

Successfully created/updated stack - sam-app in ap-northeast-1

環境

  • Ubuntu 20.04 on WSL2
  • SAM CLI, version 1.82.0
2
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?