I am trying to add an existing log group to my ECS scheduled task to avoid creation of new log groups with random name. But the aws-cdk (typescript) keeps giving me error that the types are not assignable.
const myLogGroup = LogGroup.fromLogGroupArn(this, 'MyLogGroup', 'log-group-arn')
const logging = ecs.LogDrivers.awsLogs({
streamPrefix: 'mylg',
logGroup: myLogGroup
});
logGroup: myLogGroup
gives the error:
Type 'import("/Users/praveen/code/cron-cdk/node_modules/@aws-cdk/aws-logs/lib/log-group").ILogGroup' is not assignable to type 'import("/Users/praveen/code/cron-cdk/node_modules/@aws-cdk/aws-ec2/node_modules/@aws-cdk/aws-logs/lib/log-group").ILogGroup'.
The types of 'addStream(...).stack.tags' are incompatible between these types.
Type 'import("/Users/praveen/code/cron-cdk/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/tag-manager").TagManager' is not assignable to type 'import("/Users/praveen/code/cron-cdk/node_modules/@aws-cdk/core/lib/tag-manager").TagManager'.
Types have separate declarations of a private property 'tags'.ts(2322)
aws-log-driver.d.ts(51, 14): The expected type comes from property 'logGroup' which is declared here on type 'AwsLogDriverProps'
(property) AwsLogDriverProps.logGroup?: ILogGroup | undefined
Any thoughts how can I use my existing log group for this? My scheduled task definition is this -
new ScheduledFargateTask(this, 'cleanup', {
cluster,
scheduledFargateTaskImageOptions: {
image: ecs.ContainerImage.fromAsset('scripts/cleanup'),
memoryLimitMiB: 512,
logDriver: logging,
},
schedule: events.Schedule.expression('rate(12 hours)'),
platformVersion: ecs.FargatePlatformVersion.LATEST,
});