Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS App Runner with AWS Copilot

AWS App Runner with AWS Copilot

https://nakanoshima-dev.connpass.com/event/214547/
[Online]nakanoshima.dev#17 Let's start App Runner!
2021/06/09(水) 18:30 〜 20:15

owaranai_dobby

June 09, 2021
Tweet

More Decks by owaranai_dobby

Other Decks in Programming

Transcript

  1. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 1 光吉 隆雄 アマゾンウェブサービスジャパン株式会社 技術統括本部西日本ソリューション部 ソリューションアーキテクト AWS App Runner with AWS Copilot
  2. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 2 光吉 隆雄(Mitsuyoshi Takao) アマゾンウェブサービスジャパン株式会社 技術統括本部西日本ソリューション部 ソリューションアーキテクト 経歴: 大手ゲーム会社基盤開発・DevOps推進 Infrastructure as Code, CI/CD, Container 好きなサービス: AWS CodeBuild AWS App Runner 自己紹介
  3. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 3 AWS App Runnerを実際に運用する ソースコード リポジトリ 既存ツールを用いた イメージビルド コンテナイメージを AmazonECR にプッシュ 開発チーム AWS App Runner による アプリケーションのビルド自動実行 アプリケーションの デプロイ イメージすら管理しない コードベースの手法 ECRのターゲットイメージを 指定するだけの簡単な手法 AWS Copilot CLI からのデプロイにも対応
  4. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 4 AWS Copilot とは?
  5. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 5 AWS Copilot q AWS が開発した OSS の CLI ツール q https://github.com/aws/copilot-cli/ q Amazon ECS でのコンテナアプリケーションの構築・リリース・ 運⽤を容易に q インフラではなくアプリケーション開発に集中できる q ECS クラスターや CI/CD パイプラインの対話的作成 q 宣⾔的マニフェストによる「アーキテクチャ」の定義 プロダクションレディな AWS コンテナ環境の構築・リリース・運用
  6. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 6 AWS Copilot の考え方 Application・Environment・Service に抽象化 Environment Service Service Application • Application (app) n Environment と Service をまとめて管理 • Environment (env) n Service を動かすのに必要なインフラ Ø VPC, ECS Clusterなど • Service (svc) n Request-Driven Web Service(new!) n Load Balanced Web Service n Backend Service n Scheduled Job
  7. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 7 AWS App Runner with AWS Copilot
  8. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 8 AWS App Runner with AWS Copilot 開発チーム copilot CLI AWS Cloud9 開発環境 AWS App Runner Amazon ECR AWS CloudFormation Dockerfile or Amazon ECR Public Registry
  9. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 9 事前準備 on AWS CodeCommit • Git ベースのリポジトリをホストするマ ネージドなソース管理サービス • 今回はAWS CodeCommitを使用している が、Githubでもよい • AppRunnerで動かしたいDockerfileを含 むリポジトリを作成 • ROOTに配置しなくても良い • 今回はシンプルなDockerfileを置く だけ
  10. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 10 事前準備 on AWS Cloud9 • AWS App Runnerを実行できる権限を割 り当て • Credentialsのtemporary credentialsをオフに する • AWS Cloud9のEC2インスタンスに割り当て れるIAM RoleにAWS AppRunnerやAWS CodeCommitが実行許可されるロールを割 り当てる • AWS Copilotのインストール • AWS Copilotは手動でインストール • git clone ${CodeCommit URL} インストールについて https://aws.github.io/copilot-cli/docs/getting-started/install/
  11. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 11 copilot init • Application名を入力
  12. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 12 copilot init • どのワークロードタイプを選択するか?(今回はApp Runner)
  13. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 13 copilot init • Serviceの名前を入力
  14. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 14 copilot init • AWS App Runnerで動かすソースの選択 • 今回はAWS CodeCommitリポジトリのROOTにあるDockerfileなので 「./Dockerfile」を選択
  15. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 15 copilot init • トラフィックを流すport番号を入力 • 今回はnginxイメージなので80番ポートのまま
  16. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 16 copilot init • test 環境でデプロイするか? • 環境を任意に作成したい場合は別途「copilot env init」で環境を作成 • 作成した環境で「copilot svc deploy」で特定環境にサービスをデプロイ
  17. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 17 Hello AWS App Runner!! AppRunnerのサービス名 application名-env名-service名
  18. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 18 manifest.yml • 「copilot init」でローカルにmanifest.yml が生成される • App Runnerのマネジメントコンソールで 設定できる項目と同等の内容が設定可能 • Auto Scalingに関する設定は不可 • Copilot独特の設定 • 環境ごとに環境変数をオーバーライ ドできる • ヘルスチェックの確認パスを任意に 設定できる
  19. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 19 AWS App Runner with Copilot pipeline
  20. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 20 copilot pipeline を利用した AWS App Runner 開発チーム copilot CLI AWS Cloud9 開発環境 AWS CodePipeline AWS CodeCommit AWS CodeBuild AWS App Runner Amazon ECR AWS CloudFormation Githubでも可能 Testなどのフェーズ追加も 可能
  21. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 21 copilot pipeline init • pipelineでデプロイするenvを選択
  22. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 22 copilot pipeline init • 変更検知するリポジトリを選択
  23. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 23 copilot pipeline init • pipeline.ymlとbuildspec.ymlが新たに生成されるのでcommitしてpush • その後「copilot pipeline update」を実行
  24. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 24 Hello AWS CodePipeline!!
  25. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 25 copilot pipeline init の注意点 • 生成される pipeline.yml のbranch指定が デフォルトで「master」となっている。 • CodeCommitのデフォルトのブラン チが「main」なので手作業で修正す る必要がある
  26. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 26 AWS App Runner 作成時の設定項目の違い App Runner API Copilot AutoScaling ◯ ✕ ヘルスチェック ◯ (マネジメントコンソールから一部不可) ◯ ソース(public image) ECR Public Image ECR Public Image ソース(private image) ECR Private Image ローカルのDockerfileからビルド CodePipelineによるビルド ソース(Github) Github ✕ ソースの変更検知 ECR Private Image Github CodePipelineが行う その他 - `copilot svc exec` is not supported ※2021/06現時点でのものです
  27. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 27 まとめ • CopilotでのApp Runner実行はApp Runnerの強みであるシンプルなマネージ ドサービスにCopilotが持つ環境ごとのデプロイやパイプライン実行などの 「プロダクションレディ」な運用構成を享受できる仕組みを提供する。 • ECSやFargateなどで既にCopilotを利用しているユーザーやチームは、今ま での運用感覚のままに更に容易にアプリケーションの構築を行える手段とし てApp Runnerを候補のひとつとして加えることができる。
  28. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 28 参考情報 • AWS Copilot CLI を使用した永続性を持つ AWS App Runner サービスの継続 的ワークフローの実現 • https://aws.amazon.com/jp/blogs/news/enabling-continuous-workflows- for-aws-app-runner-service-with-persistency-using-aws-copilot-cli/ • AWS Copilot ドキュメント • https://aws.github.io/copilot-cli/ • AWS App Runnerドキュメント • https://docs.aws.amazon.com/apprunner/
  29. © 2021, Amazon Web Services, Inc. or its Affiliates. All

    rights reserved. Amazon Confidential and Trademark. 29 Thank You!