AWS Copilot?

作業環境

  • macOS Catalina(10.15.5)
  • 以下の通りCopilotはAWS CLIの認証情報を参照するため、設定は事前に実施しておきます
    • Copilot uses the same credentials as the AWS CLI (引用元)

インストール

インストール方法
・MacとLinuxのInstall方法が記載されています
・Windows環境は手元にないため確認できていないですが
 バイナリの配置で使用できそうなのでWSLとかであれば使えるかもしれませんが…わかりません。

brew install aws/tap/copilot-cli

一旦オプション等何も確認せず、サンプルを動かしてみます

git clone https://github.com/aws-samples/aws-copilot-sample-service.git demo-appcd 
cd demo-app
copilot init --app demo                                                                                                                   --svc api                              
--svc-type 'Load Balanced Web Service' 
--dockerfile './Dockerfile'            
--deploy
  • 以下の通り、実行に失敗したようです(exit status 1)
    • 実行状況を見るとAWSのリソースは作られているようです
      • copilotを導入後、個別でAWSの認証情報は設定していないので、やはりAWSCLIの認証情報を使用している
      • 実行に際しCloudFormationにスタックが追加されていたので、環境構築のベースはCloudFormation
    • 異常終了の原因はローカルのPCでDockerプロセスを起動していなかったため、Buildができずにコンテナイメージが作れなかったようです
Note: It's best to run this command in the root of your Git repository.
Welcome to the Copilot CLI! We're going to walk you through some questions
to help you get set up with an application on ECS. An application is a collection of
containerized services that operate together.

Ok great, we'll set up a Load Balanced Web Service named api in application demo listening on port 80.

✔ Created the infrastructure to manage services under application demo.

✔ Wrote the manifest for service api at copilot/api/manifest.yml
Your manifest contains configurations like your container size and port (:80).

✔ Created ECR repositories for service api.


✔ Created the infrastructure for the test environment.
- Virtual private cloud on 2 availability zones to hold your services     [Complete]
- Virtual private cloud on 2 availability zones to hold your services     [Complete]
  - Internet gateway to connect the network to the internet               [Complete]
  - Public subnets for internet facing services                           [Complete]
  - Private subnets for services that can't be reached from the internet  [Complete]
  - Routing tables for services to talk with each other                   [Complete]
- ECS Cluster to hold your services                                       [Complete]
- Application load balancer to distribute traffic                         [Complete]
✔ Linked account xxxxxxx and region ap-northeast-1 to application demo.

✔ Created environment test in region ap-northeast-1 under application demo.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
✘ build Dockerfile at ./Dockerfile with tag f8d65d4: building image: exit status 1

DockerDesktopプロセスを起動して再度実行してみます

  • アカウント情報やエンドポイント等マスクが必要な情報が増えてしまったので、実行内容を要約します
    • 1回目にCloudFromationで作成されたAWSリソースは”already exists”と表示され作成はスキップされていました(スタックのテンプレートに変更は生じていないので)
    • DockerImageのビルド処理が実行され、ビルド後ECRにPushされていました
    • Push後、デプロイが行われたようでALBのエンドポイントが表示されました
✔ Deployed api, you can access it at http://demo-Publi-xxxxxx.ap-northeast-1.elb.amazonaws.com.

・ALBのエンドポイントにアクセスすると以下のような画面が表示されました

copilot.png

作られたリソース

  • Sampleのreadmeに記載されていましたが今回のinitコマンドは動作確認向け(チュートリアル向け)にある程度定められた構成をCloudFormationで作成しているようです
Copilot will set up the following resources in your account:
* A VPC
* Subnets/Security Groups
* Application Load Balancer
* Amazon ECR Repositories
* ECS Cluster & Service running on AWS Fargate

環境の掃除

copilot app delete

所感・感想

  • 今回使用したinitコマンドはチュートリアル目的と思われるためcopilotの実力を確認するためには十分ではないことはわかった。もっと触らないといけない
  • 「便利なものを使う」ことは「どのような課題が解消されたかを言語化できる」ことと「便利さに隠蔽された短所とのトレードオフを把握した上で使用する判断ができている」ことが大前提だと改めて感じた。そうでないと使っている気でいるツールに置いてけぼりを食らうように思います
  • 置行堀は本所(東京都墨田区)を舞台とした本所七不思議と呼ばれる奇談・怪談の1つ
TOP