Application name: copilot-test ✔ Created the infrastructure to manage services and jobs under application copilot-test. ✔ The directory copilot will hold service manifests for application copilot-test. ❯ copilot app ls copilot-test 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Which credentials would you like to use to create test? [Use arrows to move, type to filter, ? for more help] > Enter temporary credentials [profile default] [profile env-test] 1 2 3 4 5 6 7 8 9
Credential source: [profile env-test] Would you like to use the default configuration for a new environment? - A new VPC with 2 AZs, 2 public subnets and 2 private subnets - A new ECS Cluster - New IAM Roles to manage services and jobs in your environment [Use arrows to move, type to filter] > Yes, use default. Yes, but I'd like configure the default resources (CIDR ranges, AZs). No, I'd like to import existing resources (VPC, subnets). 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Credential source: [profile env-test] Default environment configuration? Yes, use default. ✔ Linked account xxxxxxxxx and region ap-northeast-1 to application copilot-test. ✔ Proposing infrastructure changes for the copilot-test-test environment. - Creating the infrastructure for the copilot-test-test environment. [create complete] [105.3s] - An IAM Role for AWS CloudFormation to manage resources [create complete] [36.1s] - An ECS cluster to group your services [create complete] [8.7s] - An IAM Role to describe resources in your environment [create complete] [37.7s] - A security group to allow your containers to talk to each other [create complete] [6.0s] - An Internet Gateway to connect to the public internet [create complete] [18.0s] - Private subnet 1 for resources with no internet access [create complete] [6.0s] - Private subnet 2 for resources with no internet access [create complete] [6.0s] - A custom route table that directs network traffic for the public subnets [create complete] [15.1s] - Public subnet 1 for resources that can access the internet [create complete] [6.0s] - Public subnet 2 for resources that can access the internet [create complete] [6.0s] - A private DNS namespace for discovering services within the environment [create complete] [49.2s] - A Virtual Private Cloud to control networking of your AWS resources [create complete] [12.6s] ✔ Created environment test in region ap-northeast-1 under application copilot-test. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
( 今回はLoad Balanced Web Service を選択) copilot/[svcName]/manifest.yml ファイルが作られる Service ⽤のECR Repo とメタデータParameter Store が 中央アカウントに作られる ALB がEnvironment に紐付いて作られる 別途デプロイしない限りコンテナは起動しない
run this command in the root of your workspace. Which service type best represents your service's architecture? [Use arrows to move, type to filter, ? for more help] Request-Driven Web Service (App Runner) > Load Balanced Web Service (Internet to ECS on Fargate) Backend Service (ECS on Fargate) Worker Service (Events to SQS to ECS on Fargate) 1 2 3 4 5 6 7 8 9 10
run this command in the root of your workspace. Service type: Load Balanced Web Service Service name: api Which Dockerfile would you like to use for api? [Use arrows to move, type to filter, ? for more help] > docker/Dockerfile Enter custom path for your Dockerfile Use an existing image instead 1 2 3 4 5 6 7 8 9 10 11
run this command in the root of your workspace. Service type: Load Balanced Web Service Service name: api Dockerfile: docker/Dockerfile parse EXPOSE: no EXPOSE statements in Dockerfile docker/Dockerfile Port: 80 ✔ 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. 1 2 3 4 5 6 7 8 9 10 11
remote detected. Your pipeline will follow '[email protected]:leaner-co-jp/copilot-test'. Your pipeline will follow branch 'develop'. Pipeline name: copilot-test-pipeline Which environment would you like to add to your pipeline? [Use arrows to move, type to filter, ? for more help] > test [No additional environments] 1 2 3 4 5 6 7 8 9 10 11 12
remote detected. Your pipeline will follow '[email protected]:leaner-co-jp/copilot-test'. Your pipeline will follow branch 'develop'. Pipeline name: copilot-test-pipeline 1st stage: test ✔ Wrote the pipeline manifest for copilot-test at 'copilot/pipelines/copilot-test-pipeline/manifest.yml' The manifest contains configurations for your pipeline. Update the file to add stages, change the tracked branch, add test commands or manual approval actions. ✔ Wrote the buildspec for the pipeline's build stage at 'copilot/pipelines/copilot-test-pipeline/buildspec.yml' The buildspec contains the commands to push your container images, and generate CloudFormation templates. Update the "build" phase to unit test your services before pushing the images. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
develop repository: https://github.com/leaner-co-jp/copilot-test stages: name: test # Optional: flag for manual approval action before deployment. # requires_approval: true # Optional: use test commands to validate this stage of your build. # test_commands: [echo 'running tests', make test] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
pipeline; defaulting to: copilot-test-pipeline ✔ Successfully added pipeline resources to your application: copilot-test ⠋ Creating a new pipeline: copilot-test-pipelineACTION REQUIRED! Go to https://console.aws.amazon.com/codesuite/settings/connections to update the status of connection copilot-leane-leaner-purchasing- from PENDING to AVAILABLE. ⠸ Creating a new pipeline: copilot-test-pipeline 1 2 3 4 5 6 7 8 9
pipeline; defaulting to: copilot-test-pipeline ✔ Successfully added pipeline resources to your application: copilot-test ⠋ Creating a new pipeline: copilot-test-pipelineACTION REQUIRED! Go to https://console.aws.amazon.com/codesuite/settings/connections to update the status of connection copilot-leane-leaner-purchasing- from PENDING to AVAILABLE. ✔ Successfully created a new pipeline: copilot-test-pipeline 1 2 3 4 5 6 7 8 9
service would you like to execute? [Use arrows to move, type to filter, ? for more help] api (staging) api (production) > api (develop) Service: api Execute `/bin/sh` in container api in task 03020538d7b1482790d362faa1979d9a. Starting session with SessionId: ecs-execute-command-00e6b3ab703b08eb1 # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 サービスと環境を選んで、そのコンテナ内でコマンド実⾏できる ( 内部的にはSessonManager で接続する)