(ecs): AwsLogDriver ignores log group's region
See original GitHub issueWhat is the problem?
ECS supports cross-region logging with awslogs with the awslogs-region
option.
When I pass a cross-region LogGroup
(constructed from an arn), the awslogs-region
option in the resulting template is always the current region, ignoring the log group’s region.
Reproduction Steps
Create a cross-region log group and pass it to ecs.AwsLogDriver
:
log_group = logs.LogGroup.from_log_group_arn(f"arn:aws:logs:eu-west-2:{self.account}:log-group:my_log_group")
container = ecs.ContainerDefinition(self, "container",
...
logging=ecs.AwsLogDriver(stream_prefix="my_prefix", log_group=log_group)
)
What did you expect to happen?
The logs are written to the specified log group.
What actually happened?
The task execution role is given the correct permissions for the log group (including the correct region).
But the awslogs-region
option in the container definition is always the same as the container’s region.
Task fails to start.
CDK CLI Version
1.134
Framework Version
No response
Node.js Version
17.1.0
OS
Linux
Language
Typescript, Python, .NET, Java, Go
Language Version
No response
Other information
I’m resorting to escape hatches to override Properties.ContainerDefinitions.0.LogConfiguration.Options.awslogs-region
on the task definition, but this doesn’t work if there are multiple containers.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)
Top GitHub Comments
It’s a bug in the
LogGroup.fromLogGroupArn()
method - you can see here that the region is not passed from the ARN to the returned Resource, like it should be (here’s a working example).I have submitted my fix for log group’s region: https://github.com/aws/aws-cdk/pull/18215