Amplify CLIを使い、労力ゼロでGraphQL/REST APIやウェブホスティング用にコンテナをデプロイする
Amplify CLIでFargateを利用したサーバーレスコンテナのデプロイが可能になりました
amplify の api 機能に api gateway + ecs (fargate) なコンテナデプロイ環境ができる。
ただし、あくまでも api エンドポイントとしてコンテナを動かせるというだけなのでカスタムドメインやら何やら hosting 依存の機能は使えない = それだけで単体 web site としては運用しづらいので注意。
$ amplify init # すべて default でもよき
$ amplify configure project
? Which setting do you want to configure?
Project information
AWS Profile setting
❯ Advanced: Container-based deployments # 選択
$ amplify add api
? Please select from one of the below mentioned services:
> REST # REST を選択
? Which service would you like to use
> API Gateway + AWS Fargate (Container-based) # API Gateway + AWS Fargate を選択
? Provide a friendly name for your resource to be used as a label for this category in the project:
> container # なんでもいいけど container とかが無難そう
? What image would you like to use:
> Custom (bring your own Dockerfile or docker-compose.yml) # なんか後から修正すると壊れるので Custom 一択かも
? Do you want to restrict API access (Y/n) n # Cognito で API 認証したいときだけ Y に
- ビルドフローの中で lambda で
src/
配下ファイルを upload するらしく、250MB を超えるとエラーになったnode_modules/
を入れてて、全上げされちゃった- 多分関連してる => aws-amplify/amplify-js#2902
AWS Amplify の API 機能が Fargate 対応したので PHP のフレームワーク (Laravel) を動かしてみた