i try to create a task definition with two containers in AWS. The json of the task definition is the following
{
"taskDefinitionArn": "arn:aws:ecs:eu-north-1:637423633568:task-definition/goals-task-definition:1",
"containerDefinitions": [
{
"name": "goals-backend",
"image": "xflamant/goals-node",
"cpu": 0,
"portMappings": [
{
"name": "goals-backend-80-tcp",
"containerPort": 80,
"hostPort": 80,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"command": [
"node",
"app.js"
],
"environment": [
{
"name": "MONGODB_PASSWORD",
"value": "secret"
},
{
"name": "MONGODB_USERNAME",
"value": "max"
},
{
"name": "MONGODB_URL",
"value": "localhost"
}
],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"ulimits": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/goals-task-definition",
"awslogs-create-group": "true",
"awslogs-region": "eu-north-1",
"awslogs-stream-prefix": "ecs"
},
"secretOptions": []
},
"systemControls": []
},
{
"name": "mongodb",
"image": "mongo",
"cpu": 0,
"portMappings": [
{
"name": "mongodb-27017-tcp",
"containerPort": 27017,
"hostPort": 27017,
"protocol": "tcp"
}
],
"essential": false,
"environment": [
{
"name": "MONGO_INITDB_ROOT_USERNAME",
"value": "max"
},
{
"name": "MONGO_INITDB_ROOT_PASSWORD",
"value": "secret"
}
],
"environmentFiles": [],
"mountPoints": [],
"volumesFrom": [],
"systemControls": []
}
],
"family": "goals-task-definition",
"taskRoleArn": "arn:aws:iam::637423633568:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::637423633568:role/ecsTaskExecutionRole",
"networkMode": "awsvpc",
"revision": 1,
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"cpu": "1024",
"memory": "3072",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2024-06-28T14:55:33.825Z",
"registeredBy": "arn:aws:iam::637423633568:root",
"tags": []
}
I don’t see what is wrong in my task definition, there is a username/password defined for mongodb and the message error seems to be the fact that the username/password credential is wrong. Could it be another reason ?
And when I try to deploy it, I have a mongodb authentication error. The print screen of the message error is the following. Can you help me ?