1
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?

Deploy Amplify Gen 2 with npm workspaces

Posted at

雨の Tokyo

Amplify Gen 2 ( Amplify ) の deploy について。

この文章を書くにあたり前提は以下の通り。

  • Amplify である。
  • Monorepo である。
  • npm workspaces を採用している。
  • Backend は Amazon ECS である。

tl;dr

  • npm-scriptsnpx ampx pipeline-deploy を実行できる。-w option を指定する。

Case1: cd コマンドで対象のディレクトリに遷移し実行する

  • FAILED
  • package-lock.json が見つからないため。
CodeBuild
[Container] 2024/06/26 09:13:10.885476 Running command npx ampx pipeline-deploy --branch $BRANCH_NAME --app-id $AMPLIFY_APP_ID --debug
npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-06-26T09_13_11_097Z-debug-0.log

[Container] 2024/06/26 09:13:12.185043 Command did not exit successfully npx ampx pipeline-deploy --branch $BRANCH_NAME --app-id $AMPLIFY_APP_ID --debug exit status 1
[Container] 2024/06/26 09:13:12.190205 Phase complete: BUILD State: FAILED
[Container] 2024/06/26 09:13:12.190234 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npx ampx pipeline-deploy --branch $BRANCH_NAME --app-id $AMPLIFY_APP_ID --debug. Reason: exit status 1
[Container] 2024/06/26 09:13:12.229527 Entering phase POST_BUILD

Case2: npm-scripts で実行する

  • SUCCEEDED
  • アドバイスをいただいた同僚に感謝。
CodeBuild
[Container] 2024/06/27 04:19:45.254696 Running command npm run amplify:deploy -w api

> api@0.0.1 amplify:deploy
> npx ampx pipeline-deploy --branch $BRANCH_NAME --app-id $AMPLIFY_APP_ID --debug true

[DEBUG] 2024-06-27T04:19:56.991Z: Bundling asset amplify-yyyy-BPD168-branch-xxxx/AmplifyBranchLinker/CustomResourceLambda/Code/Stage...

[DEBUG] 2024-06-27T04:19:57.571Z: 
  ...xxxxx/index.js  1002.4kb

⚡ Done in 143ms

[DEBUG] 2024-06-27T04:19:58.125Z: 


[DEBUG] 2024-06-27T04:19:58.762Z: error TS5057: Cannot find a tsconfig.json file at the specified directory: 'amplify'.

[DEBUG] 2024-06-27T04:19:59.775Z: 
✨  Synthesis time: 0.03s



✨  Synthesis time: 0.03s
api/package.json
{
  "name": "api",
  "version": "0.0.1",
  "description": "",
  "private": true,
  "scripts": {
    "amplify:deploy": "npx ampx pipeline-deploy --branch $BRANCH_NAME --app-id $AMPLIFY_APP_ID --debug true"
  },
  "dependencies": {
  },
  "devDependencies": {
  }
}
buildspec.yml
version: 0.2

phases:
  build:
    commands:
      - echo Build started on `date`
      - echo set up the build-spec when using CodeBuild...
      - export CI=1
      - npm ci
      - npm run amplify:deploy -w api

Conclusion

やりたいことをやれているか。

わたしは、やりたいことはやれているが、自分のスキルと時間が足りない。

1
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
1
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?