I'm trying to send container logs to aws cloudwatch using terrfaorm. Here's the ECS role I'm using for IAM:
{
"Version": "2008-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": ["ecs.amazonaws.com", "ec2.amazonaws.com"]
},
"Effect": "Allow"
}
]
}
the ECS service role policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"elasticloadbalancing:Describe*",
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"ec2:Describe*",
"ec2:AuthorizeSecurityGroupIngress",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"*"
]
}
]
}
the task definition for docker container contains this for cloudwatch logging
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "awslog-mylogs",
"awslogs-region": "eu-west-1",
"awslogs-stream-prefix": "awslogs-mylogs-stream"
}
}
(I have the awslog-mylogs log group pre-created via AWS console).
Now, when I run an aws instance without the shown logging config for the container, everything runs(except logs being send to cloudwatch). If I add the logging config, ec2 starts but the container does not start properly. It seems that the docker container bails out. Anything that I can do to get the logs to cloudwatch?