Skip to content

Instantly share code, notes, and snippets.

@yano3nora
Last active January 6, 2022 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yano3nora/ceaaaa5888fe6a1195a5ef07864cadfd to your computer and use it in GitHub Desktop.
Save yano3nora/ceaaaa5888fe6a1195a5ef07864cadfd to your computer and use it in GitHub Desktop.
[dev: Amplify Container-based deployments] #aws

Overview

Amplify CLIを使い、労力ゼロでGraphQL/REST APIやウェブホスティング用にコンテナをデプロイする
Amplify CLIでFargateを利用したサーバーレスコンテナのデプロイが可能になりました

amplify の api 機能に api gateway + ecs (fargate) なコンテナデプロイ環境ができる。

ただし、あくまでも api エンドポイントとしてコンテナを動かせるというだけなのでカスタムドメインやら何やら hosting 依存の機能は使えない = それだけで単体 web site としては運用しづらいので注意。

Getting Started

$ 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 を超えるとエラーになった

Custom (Docker-Compose)

AWS Amplify の API 機能が Fargate 対応したので PHP のフレームワーク (Laravel) を動かしてみた

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment