task definition
以下はインスタンスのcpuinfoとメモリの情報をチェックするtaskのdefinition
{ "family": "get_fargate_cpu_info", "containerDefinitions": [ { "name": "get_fargate_cpu_info", "image": "#{AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/get_fargate_cpu_info", "entryPoint": ["bash", "-c", "cat /proc/cpuinfo && free -h"], "essential": true, "memoryReservation": 512, "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "get-fargate-cpu-info", "awslogs-region": "us-east-1", "awslogs-stream-prefix": "cpuinfo" } } } ], "requiresCompatibilities": ["FARGATE"], "networkMode": "awsvpc", "cpu": "256", "memory": "512", "executionRoleArn": "arn:aws:iam::#{AWS_ACCOUNT_ID}:role/ecsTaskExecutionRole" }
- requiresCompatibilities :
FARGATE
が必要 - cpu, memory : 必須
- networkMode : Fargateの場合
awsvpc
が必須 - executionRoleArn : ecs task を実行する権限を持つIAMが必要
aws ecs run-task
{ "taskDefinition": "get_fargate_cpu_info", "cluster": "get-fargate-cpu-info", "networkConfiguration": { "awsvpcConfiguration": { "subnets": ["subnet-********"], "securityGroups": ["sg-********"], "assignPublicIp": "ENABLED" } }, "launchType": "FARGATE" }
- launchType :
FARGATE
必須 - networkConfiguration :
awsvpcConfiguration
の定義が必要- assignPublicIp:
ENABLED
にして、外に出れるようにしないと、ECRからコンテナを取りにいけない
- assignPublicIp: