I have this task definition code, which has a problem:
{
"family": "ikg-api",
"taskRoleArn": "",
"executionRoleArn": "arn:aws:iam::913xxxx371:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"containerDefinitions": [
{
"name": "ikg-api",
"image": "913xxxx371.dkr.ecr.us-west-2.amazonaws.com/ikg_api:fda0b49f8",
"cpu": 512,
"memory": 1024,
"memoryReservation": 1024,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp"
}
],
"essential": true,
"environment": [
{
"name": "is_docker",
"value": "yes"
}
],
"secrets": [
{
"name": "bitbucket_password",
"valueFrom": "arn:aws:ssm:us-west-1:913xxxx0371:parameter/bitbucket_pwd"
}
],
"startTimeout": 10,
"stopTimeout": 19,
"user": "root",
"workingDirectory": "/apps",
"disableNetworking": false,
"privileged": false,
"readonlyRootFilesystem": false,
"interactive": false,
"pseudoTerminal": false,
"healthCheck": {
"command": [
"curl",
"localhost"
],
"interval": 30,
"timeout": 20,
"retries": 1,
"startPeriod": 50
}
}
],
"networkConfiguration": {
"awsvpcConfiguration": {
"assignPublicIp": "ENABLED",
"securityGroups": [
"sg-0a6e7d4a5238fe3c6"
],
"subnets": [
"subnet-05a6557c"
]
}
},
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "512",
"memory": "1024",
"tags": [
{
"key": "Project",
"value": "IKG"
}
]
}
when I upload the definition using:
aws ecs run-task --cluster tutorial --task-definition ikg-api:1 --count 1
I get this error:
An error occurred (InvalidParameterException) when calling the RunTask operation: Network Configuration must be provided when networkMode 'awsvpc' is specified.
for the life of me I cannot figure out how to resolve it..I tried putting the most sane values for networkConfiguration that I can find...no dice. Anybody know how I resolve this?
You will need something like the below (snapshot from what I have at work)
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
SecurityGroups:
- !Ref ECSServicesSecurityGroup
Subnets:
- Fn::ImportValue: !Sub ${VPCStack}-SubnetPrivateA
- Fn::ImportValue: !Sub ${VPCStack}-SubnetPrivateB
- Fn::ImportValue: !Sub ${VPCStack}-SubnetPrivateC